Skip to content

Commit

Permalink
Replace sphinx napoleon for numpydoc (fatiando#492)
Browse files Browse the repository at this point in the history
Add numpydoc to requirements for building the docs. Add numpydoc to
Sphinx configuration file. Update Sphinx template for classes.
  • Loading branch information
santisoler authored May 31, 2024
1 parent c079fb3 commit 45c42ed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
20 changes: 5 additions & 15 deletions doc/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,18 @@

.. autoclass:: {{ objname }}

.. rubric:: Methods Summary

.. autosummary::
{% for item in members %}
{% if item in ['__call__'] %}
{{ objname }}.{{ item }}
{% endif %}
{% endfor %}
{% for item in methods %}
{% if item != '__init__' %}
{{ objname }}.{{ item }}
{% endif %}
{% endfor %}

----
{% if methods %}

{% for item in methods %}
{% if item != '__init__' %}
.. automethod:: {{ objname }}.{{ item }}
{% endif %}
{% endfor %}

{% endif %}

----

.. include:: backreferences/{{ fullname }}.examples

.. raw:: html
Expand Down
13 changes: 7 additions & 6 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"numpydoc",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.doctest",
"sphinx.ext.viewcode",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx_gallery.gen_gallery",
"sphinx_design",
"sphinx_copybutton",
Expand Down Expand Up @@ -67,11 +67,12 @@
# Autosummary pages will be generated by sphinx-autogen instead of sphinx-build
autosummary_generate = []

# Otherwise, the Return parameter list looks different from the Parameters list
napoleon_use_rtype = False
# Otherwise, the Attributes parameter list looks different from the Parameters
# list
napoleon_use_ivar = True
# Create cross-references for the parameter types in the Parameters, Other
# Returns and Yields sections of the docstring
numpydoc_xref_param_type = True

# Format the Attributes section like the Parameters section.
numpydoc_attributes_as_param_list = True

# Always show the source code that generates a plot
plot_include_source = True
Expand Down
1 change: 1 addition & 0 deletions env/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Documentation building requirements
sphinx==7.2.*
numpydoc==1.7.*
sphinx-book-theme==1.1.*
sphinx-gallery==0.15.*
sphinx-design==0.5.*
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies:
- boule
# Documentation requirements
- sphinx==7.2.*
- numpydoc==1.7.*
- sphinx-book-theme==1.1.*
- sphinx-gallery==0.15.*
- sphinx-design==0.5.*
Expand Down

0 comments on commit 45c42ed

Please sign in to comment.