I'm trying to clean up my python code documentation, and decided to use sphinx-doc because it looks good. I like how I can reference other classes and methods with tags like:
:class:`mymodule.MyClass` About my class.
:meth:`mymodule.MyClass.myfunction` And my cool function
I'm trying to figure out though how to document parameter names in a function, so that if I have a function like:
def do_this(parameter1, parameter2):
"""
I can describe do_this.
:something?:`parameter1` And then describe the parameter.
"""
What's the best practice for this?
Update:
The correct syntax is:
def do_this(parameter1, parameter2):
"""
I can describe do_this.
:something parameter1: And then describe the variable
"""
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.
To support Markdown-based documentation, Sphinx can use MyST-Parser. MyST-Parser is a Docutils bridge to markdown-it-py, a Python package for parsing the CommonMark Markdown flavor.
Typically "function variables" are called parameters ;).
It's documented here: http://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#signatures
And the answer is :param ________
EDIT Disclaimer: I've never used or heard of sphinx... This post is mostly a "what words to search for." Hope it helped.
Adding this answer to consolidate options:
pydoc is basic with no special formatting
epydoc uses the format '@param var:'
Doxygen is oriented for a larger range of languages
Sphinx uses the format ':param type var:'. Also see more examples. This was used to create the Python 3.5 documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With