Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx Autodoc skip member from docstring

Tags:

I am documenting a class with Sphinx and simple want to skip one of the classes members:

class StatusUpdateAdapter(logging.LoggerAdapter):     """     """     def __init__(self, status_update_func, logger, extra={}):         """         """         pass      def log(self, *args, **kwargs):         pass 

How can I cause sphinx NOT to document the log member? I would like to do this in the StatusUpdateAdapter or log docstring's if possible.

like image 671
Colton Leekly-Winslow Avatar asked Jan 29 '15 21:01

Colton Leekly-Winslow


People also ask

How does Sphinx Autodoc work?

autodoc provides several directives that are versions of the usual py:module , py:class and so forth. On parsing time, they import the corresponding module and extract the docstring of the given objects, inserting them into the page source under a suitable py:module , py:class etc. directive.

What is Toctree Sphinx?

toctree is a Sphinx-defined directive in which you explicitly list documents whose TOCs will be listed out.

What is Sphinx-Apidoc?

sphinx-apidoc is a tool for automatic generation of Sphinx sources that, using the autodoc extension, document a whole package in the style of other automatic API documentation tools. MODULE_PATH is the path to a Python package to document, and OUTPUT_PATH is the directory where the generated sources are placed.


1 Answers

You can now (as of version 0.6) use :exclude-members: to exclude specific members from the documentation:

The directives supporting member documentation also have a exclude-members option that can be used to exclude single member names from documentation, if all members are to be documented.

New in version 0.6.

Source: http://www.sphinx-doc.org/en/stable/ext/autodoc.html

In your specific case, you would add :exclude-members: log into your .rst file.

like image 112
vimist Avatar answered Oct 27 '22 00:10

vimist