Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude module docstring in autodoc

I'm trying to use autodoc in Sphinx to print out the docstrings of every functions in a specific module but exclude the module's docstring. Is it possible?

The reason is that I'm using the modules docstring to specify command line options (with the lovely docopt).

like image 280
Jonatan Avatar asked Jul 29 '13 15:07

Jonatan


1 Answers

Add the following to conf.py:

def remove_module_docstring(app, what, name, obj, options, lines):
    if what == "module" and name == "yourmodule":
        del lines[:]

def setup(app):
    app.connect("autodoc-process-docstring", remove_module_docstring)

This code removes the module docstring in the yourmodule module by providing a handler for the autodoc-process-docstring event.

like image 162
mzjn Avatar answered Oct 24 '22 13:10

mzjn