Skip to content

Commit

Permalink
Improve Sphinx config for autodoc and autosummary (#132)
Browse files Browse the repository at this point in the history
While adding the new Qiskit addons, the docs team iterated on how best to configure Sphinx for more useful docs. You can see the result of this change at Qiskit/documentation#2342.
  • Loading branch information
Eric-Arellano authored Nov 19, 2024
1 parent fcd2fb3 commit 0427589
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 5 additions & 4 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

.. autoclass:: {{ objname }}
:no-members:
:no-inherited-members:
:no-special-members:
:show-inheritance:

{% block attributes_summary %}
{% set wanted_attributes = (attributes | reject('in', inherited_members) | list) %}
{% if wanted_attributes %}
{% if attributes %}
.. rubric:: Attributes
{% for item in wanted_attributes %}
{% for item in attributes %}
.. autoattribute:: {{ item }}
{%- endfor %}
{% endif %}
Expand All @@ -29,4 +30,4 @@
.. automethod:: {{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion docs/apidocs/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
***************************************
qiskit-ibm-transpiler API reference
``qiskit-ibm-transpiler`` API reference
***************************************

.. toctree::
Expand Down
12 changes: 10 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@
"qiskit_sphinx_theme",
]

# Move type hints from signatures to the parameter descriptions (except in overload cases, where
# that's not possible).
# Options for autodoc. These reflect the values from Qiskit SDK and Runtime.
autosummary_generate = True
autosummary_generate_overwrite = False
autoclass_content = "both"
autodoc_typehints = "description"
autodoc_default_options = {
"inherited-members": None,
"show-inheritance": True,
}
napoleon_google_docstring = True
napoleon_numpy_docstring = False

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
Expand Down

0 comments on commit 0427589

Please sign in to comment.