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

Show class members #702

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Conversation

Eric-Arellano
Copy link
Collaborator

We weren't showing class members (attributes & methods) for inlined classes. This is fixed by setting "inherited-members": None in autodoc_default_options.

Notably, we now show inherited members for classes like instructions.Move. I recommend this because users want to know every function/attribute defined on the object, and they don't really care about the origin of that functionality. Qiskit SDK takes this approach, which is useful with e.g. the circuit library.

With this change, some of the classes end up being much larger. So, we un-inline them and move them back to being their own pages in stubs/. This means we remove their client redirects.

This PR also makes some other enhancements:

  • Adds tox -e docs-clean
  • Displays type hints in the parameters section, rather than inline to the signature. This matches the style of the other API projects

@Eric-Arellano Eric-Arellano added the stable backport potential Suitable to be backported to most recent stable branch by Mergify label Oct 30, 2024
@coveralls
Copy link

coveralls commented Oct 30, 2024

Pull Request Test Coverage Report for Build 11667974979

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 11582107798: 0.0%
Covered Lines: 2330
Relevant Lines: 2330

💛 - Coveralls

@@ -0,0 +1,33 @@
{#
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 copied from Qiskit SDK, other than where I comment. I'm probably going to update Qiskit to mirror this

Comment on lines +12 to +13
:no-inherited-members:
:no-special-members:
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 have to set this to avoid the methods being duplicated. That's because we configured .. autoclass in conf.py to now show inherited members

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 was already unused


.. autoclass:: WeightType
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 class is tiny, so I think it's fine to keep inlined

Comment on lines +94 to +95
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 is a performance enhancement for build-time


For each element of the list, it means that the :class:`~qiskit.quantum_info.Pauli` is given by
the ``j``th commuting observable in the ``i``th group.
the ``j``-th commuting observable in the ``i``-th group.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The lack of - was causing a Sphinx error

allowlist_externals =
rm
commands =
rm -rf {toxinidir}/docs/stubs/ {toxinidir}/docs/_build/
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but also mostly noting: there is already some cleaning that goes on in the docs environment. We could potentially remove it with this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ack, I noticed that. It only deletes .doctrees inside html rather than the entire folder, however. I also think it's nice to have tox -e docs-clean to be consistent with the other addon repos - muscle memory.

Lmk if you want me to delete this though. I'm fine with that

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant that we could potentially remove those steps from the docs environment now that there is docs-clean.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, yeah I agree. There are many times where you do want the caching to be preserved. Updated

garrison
garrison previously approved these changes Nov 4, 2024
Copy link
Member

@garrison garrison left a comment

Choose a reason for hiding this comment

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

This looks good to me

@Eric-Arellano Eric-Arellano merged commit 0ecc244 into Qiskit:main Nov 4, 2024
11 checks passed
@Eric-Arellano Eric-Arellano deleted the EA/show-class-members branch November 4, 2024 16:47
mergify bot pushed a commit that referenced this pull request Nov 4, 2024
We weren't showing class members (attributes & methods) for inlined classes. This is fixed by setting `"inherited-members": None` in `autodoc_default_options`.

Notably, we now show inherited members for classes like `instructions.Move`. I recommend this because users want to know every function/attribute defined on the object, and they don't really care about the origin of that functionality. Qiskit SDK takes this approach, which is useful with e.g. the circuit library.

With this change, some of the classes end up being much larger. So, we un-inline them and move them back to being their own pages in `stubs/`. This means we remove their client redirects.

This PR also makes some other enhancements:

* Adds `tox -e docs-clean`
* Displays type hints in the `parameters` section, rather than inline to the signature. This matches the style of the other API projects

(cherry picked from commit 0ecc244)
Eric-Arellano added a commit that referenced this pull request Nov 4, 2024
We weren't showing class members (attributes & methods) for inlined classes. This is fixed by setting `"inherited-members": None` in `autodoc_default_options`.

Notably, we now show inherited members for classes like `instructions.Move`. I recommend this because users want to know every function/attribute defined on the object, and they don't really care about the origin of that functionality. Qiskit SDK takes this approach, which is useful with e.g. the circuit library.

With this change, some of the classes end up being much larger. So, we un-inline them and move them back to being their own pages in `stubs/`. This means we remove their client redirects.

This PR also makes some other enhancements:

* Adds `tox -e docs-clean`
* Displays type hints in the `parameters` section, rather than inline to the signature. This matches the style of the other API projects

(cherry picked from commit 0ecc244)

Co-authored-by: Eric Arellano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stable backport potential Suitable to be backported to most recent stable branch by Mergify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants