10

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

1 Answer 1

9

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.

1
  • I chose to make the docstring to a variable by just adding docopt_string = .
    – Jonatan
    Aug 30, 2013 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.