Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx Autodoc and NumpyDoc

Tags:

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?

like image 568
LondonRob Avatar asked Dec 02 '13 17:12

LondonRob


People also ask

What is Sphinx Autodoc?

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.

Does Sphinx support Google docstring?

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.


1 Answers

Try removing the whole previous html output. Then regenerate the docs.

like image 200
Maciek D. Avatar answered Sep 24 '22 23:09

Maciek D.