Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Sphinx config for autodoc and autosummary #132

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

Eric-Arellano
Copy link
Collaborator

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.

:show-inheritance:

{% block attributes_summary %}
{% set wanted_attributes = (attributes | reject('in', inherited_members) | list) %}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be showing inherited attributes - they are useful for end users who don't care about inheritance chains. If you ever end up with too big of a class and want to leave off inherited members, you can set up this template

@@ -1,5 +1,5 @@
***************************************
qiskit-ibm-transpiler API reference
``qiskit-ibm-transpiler`` API reference
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it more clear that it's a PyPI package name

# Options for autodoc. These reflect the values from Qiskit SDK and Runtime.
autosummary_generate = True
autosummary_generate_overwrite = False
autoclass_content = "both"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring will be used for classes from both the class docstring and the constructor docstring

autodoc_typehints = "description"
autodoc_default_options = {
"inherited-members": None,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how you tell .. autoclass:: to include inherited members

autodoc_typehints = "description"
autodoc_default_options = {
"inherited-members": None,
"show-inheritance": True,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in classes saying which class they subclass

Comment on lines +42 to +43
napoleon_google_docstring = True
napoleon_numpy_docstring = False
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This avoids the risk of docstring being misinterpreted.

Copy link
Contributor

@jesus-talavera-ibm jesus-talavera-ibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Eric-Arellano

@Eric-Arellano Eric-Arellano merged commit 0427589 into main Nov 19, 2024
4 checks passed
@Eric-Arellano Eric-Arellano deleted the EA/sphinx-alignment branch November 19, 2024 16:06
Eric-Arellano added a commit that referenced this pull request Nov 19, 2024
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.
Eric-Arellano added a commit that referenced this pull request Nov 19, 2024
… (#133)

Improve Sphinx config for autodoc and autosummary (#132)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants