use autosummary to generate most of the API Reference

- custom _template/autosummary/module.rst to include docs
  for all module :members" (shows up directly after the summary
  tables)
- module docs should *not* contain autodocs for members, only general
  descriptions and examples
- all files inside api/ are autogenerated whenever sphinx is run
  (no need to add to the repository, hence excluded in .gitignore)
This commit is contained in:
Oliver Beckstein
2020-06-19 15:15:32 -07:00
parent 2bf031fd65
commit 65856b39fb
3 changed files with 75 additions and 1 deletions

9
.gitignore vendored
View File

@@ -4,4 +4,11 @@
# PIP stuff
*.egg-info
# Visual studio code
.vscode
.vscode
# editor files
*~
# generated files
docs/build
docs/source/api/*.rst

View File

@@ -0,0 +1,61 @@
{{ fullname | escape | underline}}
.. automodule:: {{ fullname }}
:members:
{% block attributes %}
{% if attributes %}
.. rubric:: Module Attributes
.. autosummary::
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}
.. autosummary::
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}
.. autosummary::
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}
.. autosummary::
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block modules %}
{% if modules %}
.. rubric:: Modules
.. autosummary::
:toctree:
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

View File

@@ -38,6 +38,7 @@ release = '3.2.0'
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
'sphinx.ext.mathjax', 'sphinx.ext.viewcode',
'sphinx.ext.napoleon', 'sphinx.ext.todo',
'sphinx.ext.autosummary',
## 'sphinx_sitemap',
'sphinx_rtd_theme']
@@ -55,6 +56,11 @@ templates_path = ['_templates']
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# https://www.sphinx-doc.org/en/master/usage/extensions/autosummary.html
# We use a customized _templates/autosummary/module.rst to document members, too.
autosummary_generate = True
autosummary_imported_members = False
autosummary_generate_overwrite = True
# -- Options for HTML output -------------------------------------------------