Docstring Format¶
Back in the day, docstrings used to be just plain reStructuredText inside of docstrings.
- It was very gross.
- For everyone.
Solution¶
Numpy Project and Google defined a non-gross docstring formats that everyone accepts and Sphinx recognizes.
- Sphinx needs an addon called “Napoleon” to interpret them.
- It is not a problem. This is defined in the doc’s conf.py.
conf.py:
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx.ext.napoleon', # <- Here is Napoleon
]
See also: Google docstrings Example
The code in sphinxtest.alpha
and sphinxtest.beta
utilize this Docstring format and are automatically generated.