Use autosummary to generate API documentation recursively.

271 views
Skip to first unread message

Hameer Abbasi

unread,
Jan 3, 2018, 7:41:36 AM1/3/18
to sphinx-users
Hello, everyone. I have two issues:

First, autosummary does not seem to be finding my templates. When I delete or modify the modules file, the generated docs don't change at all. I want to use templates similar to module.rst below to generate API docs without listing everything out. I want to generate autosummaries that link to individual pages automatically. I have followed this SO answer to the letter. My directory structure looks like the following:
  • module1
    • Module code here
  • docs
    • conf.py
    • index.rst
    • modules.rst
    • _templates
      • autosummary
        • module.rst

Docs/index.rst looks like this:
.. sparse documentation master file, created by
   sphinx
-quickstart on Fri Dec 29 20:58:03 2017.
   
You can adapt this file completely to your liking, but it should at least
   contain the root
`toctree` directive.

Welcome to sparse's documentation!
==================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

docs/modules.rst:
API Reference
=============

Modules
-------

.. autosummary::
   
:toctree: _autosummary

   module1

docs/_templates/autosummary/module.rst
{{ fullname | escape | underline }}

Description
-----------

.. automodule:: {{ fullname | escape }}

{% if classes %}
Classes
-------
.. autosummary:
   
:toctree: _autosummary

   
{% for class in classes %}
       
{{ class }}
   
{% endfor %}

{% endif %}

{% if functions %}
Functions
---------
.. autosummary:
   
:toctree: _autosummary

   
{% for function in functions %}
       
{{ function }}
   
{% endfor %}

{% endif %}


Reply all
Reply to author
Forward
0 new messages