getdoc

Simple function to get a python module's doc recursively


Keywords
docstrings, python
License
MPL-2.0
Install
pip install getdoc==0.3.0

Documentation

Python getdoc

Travis-CI Build Status PyPI Package latest release PyPI Wheel Updates Join the chat at https://gitter.im/Pawamoy/python-getdoc

Simple function to get a python module's doc recursively.

License

Software licensed under ISC license.

Installation

pip install getdoc

Documentation

http://python-getdoc.readthedocs.io/en/latest/

Development

To run all the tests: tox

Usage

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.