pythonboost-pythonpydoc

pydoc injecting python submodules content to main module


I have a module dlprim

dlprim/
  __init__.py
  netconfig.py
  _pydlprim.so

its __init__.py incldes:

from ._pydlprim import *
from .netconfig import *

where ._pydlprim is boost.pythom module and .netconfig is submodule.

If I generate a documentation with pydoc -w dlprim - it does not include classes from _pydlprim and netconfig.py so in order to generate them all I need to run pydoc -w dlprim dlprim.netconfig dlprim._pydlprim

But I get 3 separate files each in different namespace I want all of the classes to be found under dlprim module and namespace in pydoc.

How can I do it, or is there an alternative for this?


Solution

  • Put the names of those re-exported items in __all__.

    from ._pydlprim import *
    from .netconfig import *
    
    def _all_of(mod):
        try:
            yield from mod.__all__
            return
        except AttributeError:
            pass
        for item in dir(mod):
            if not item.startswith('_'):
                yield item
    
    __all__ = [*_all_of(_pydlprim), *_all_of(netconfig)]