Simple function to get a python module's doc recursively.
Software licensed under ISC license.
pip install getdoc
http://python-getdoc.readthedocs.io/en/latest/
To run all the tests: tox
import some_module
from getdoc import get_module_doc
doc = get_module_doc(some_module)
# The result is a dictionnary: {type, name, doc, [nested_doc]},
# type being 'function', 'class', or 'module',
# and nested_doc being a list of dictionnaries as above.
You can get doc for just a class (and its contents), or just a function.
from getdoc import get_class_doc, get_function_doc
doc = get_class_doc(some_module.SomeClass)
doc = get_function_doc(some_module.SomeClass.some_function)
A bit more advanced...
# You can exclude modules, classes or functions with a Config instance.
from getdoc import Config, Ex, default_config, django_app_config
# The following is equal to django_app_config
custom_config = Config(
exclude_module=[
Ex('django', Ex.Method.EXACT),
Ex('django.')],
exclude_class=[
Ex('DoesNotExist', Ex.Method.EXACT),
Ex('MultipleObjectsReturned', Ex.Method.EXACT)],
exclude_function=[
Ex('_'),
Ex('ugettext', Ex.Method.EXACT)],
nested_class=False, # Don't get doc for nested class
missing_doc=True) # Still return items if no doc and no nested doc
doc = get_module_doc(some_module, config=custom_config)
Default method for exclusion is PREFIX. There is also SUFFIX, EXACT, CONTAINS, REGEX.