despite reading this tutorial, this question and the numpy docstring standard, I'm unable to get sphinx autodoc to play nicely with numpy docstrings.
In my conf.py
I have:
extensions = ['sphinx.ext.autodoc', 'numpydoc']
and in my doc file I have:
.. automodule:: python_file .. autoclass:: PythonClass :members:
where python_file.py
has:
class PythonClass(object): def do_stuff(x): """ This does good stuff. Here are the details about the good stuff it does. Parameters ---------- x : int An integer which has amazing things done to it Returns ------- y : int Some other thing """ return x + 1
When I run make html
I get ERROR: Unknown directive type "autosummary"
. When I add autosummary
to my extensions
thus:
extensions = ['sphinx.ext.autodoc', 'numpydoc', 'sphinx.ext.autosummary']
I get:
WARNING: toctree references unknown document u'docs/python_file.PythonClass.do_stuff'
As recommended by this question, I add numpydoc_show_class_members = False
to my conf.py
.
Now I can run make html
without errors, but the Parameters
and Returns
sections are not interpreted as being numpydoc sections.
Is there a way out of this mess?
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.
Napoleon interprets every docstring that Sphinx autodoc can find, including docstrings on: modules , classes , attributes , methods , functions , and variables . Inside each docstring, specially formatted Sections are parsed and converted to reStructuredText.
Try removing the whole previous html
output. Then regenerate the docs.
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