I currently have a use case where I am creating Python classes in modules using the following code.
...
module = type.ModuleType(module_name)
...
klass = type(name, (object, ), dict(__doc__='docstring'))
...
setattr(module, name, klass)
...
However Sphinx is not able to generate documentation for these classes. It is not even able to find the classes. Is there a way to add an extension to Sphinx to handle this use case? Thoughts?
The full minimum working example for this is located here .
You have the following automodule
directive in modules.rst:
.. automodule:: modules
:members:
:undoc-members:
:show-inheritance:
But the qualified names of the dynamic modules are modules.Module1
and modules.Module2
(these names are added to sys.modules
in _factory.py).
The following works for me:
.. automodule:: modules.Module1
:members:
:undoc-members:
:show-inheritance:
.. automodule:: modules.Module2
:members:
:undoc-members:
:show-inheritance:
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.