简体   繁体   中英

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?

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)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM