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

Always show type hints in docs #31

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

Eric-Arellano
Copy link
Collaborator

Before, we would only show type hints for parameters that had dedicated docstring. There are a lot of parameters that don't have docstring—and sometimes don't need it because it's obvious—so it's best to no matter what show the docstring.

This PR aligns the autodoc templates and config with the other addons like cutting.

@Eric-Arellano Eric-Arellano added the stable backport potential Label for mergify to open a backport PR label Oct 30, 2024
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure why this was added. None of the main Qiskit repos have it. It didn't change how qiskit/documentation works

Copy link
Member

Choose a reason for hiding this comment

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

This was added to ensure reasonable titles for docs pages which only contain a function.
Below is a before and after of the docs page for qiskit_addon_obp.backpropagate:

With function.rst present:
screenshot_1730796916

Without it:
screenshot_1730796909

Notice the change in both the title and the navigation column on the left. Especially the latter I find very cumbersome as the fully resolved module names can become very long.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. For what it's worth, it makes zero impact on how docs.quantum.ibm.com is rendered. I tested this out by first un-inlining a function & generating the docs w/o the template. Then I added back this custom template & regenerated - no change.

We show the full API name in the h1 for SEO purposes and so people know the import path. The left TOC looks like this:

Screenshot 2024-11-06 at 4 42 10 PM

So, I don't really have a preference because it doesn't impact docs.quantum.ibm.com. What would you prefer me to do?

Copy link
Member

Choose a reason for hiding this comment

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

Okay I see. If it has no effect I suppose it does not matter and you can leave it like this. I assume we won't be publishing the docs in two places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I assume we won't be publishing the docs in two places.

Exactly. There will be a transition period for ~1-2 months as we migrate your guides to docs.quantum.ibm.com. Once that's done, we'll redirect GitHub Pages to the IBM site.

autosummary_generate = True
autosummary_generate_overwrite = False
autoclass_content = "both"
autodoc_typehints = "description"
autodoc_typehints_description_target = "documented_params"
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 the main change

autosummary_generate = True
autosummary_generate_overwrite = False
autoclass_content = "both"
autodoc_typehints = "description"
autodoc_typehints_description_target = "documented_params"
autodoc_member_order = "bysource"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I got rid of this because I think the default of alphabetical is more sensical, and it's what all the other non-addon projects use. You can read more at https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_member_order. Feel free to disagree!

Copy link
Member

Choose a reason for hiding this comment

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

I don't remember for which specific case we added this but I am fine with going back to alphabetical

Comment on lines +85 to +86
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.

Small performance optimization & reduces risk of unintended behavior

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11603399486

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 11554634560: 0.0%
Covered Lines: 429
Relevant Lines: 429

💛 - Coveralls

Copy link
Member

@mrossinek mrossinek left a comment

Choose a reason for hiding this comment

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

Based on the discussion above, this is fine by me 👍

@Eric-Arellano Eric-Arellano merged commit a46b3d1 into Qiskit:main Nov 7, 2024
15 checks passed
@Eric-Arellano Eric-Arellano deleted the EA/always-type-hints branch November 7, 2024 16:58
mergify bot pushed a commit that referenced this pull request Nov 7, 2024
Before, we would only show type hints for parameters that had dedicated docstring. There are a lot of parameters that don't have docstring—and sometimes don't need it because it's obvious—so it's best to no matter what show the docstring.

This PR aligns the autodoc templates and config with the other addons like cutting.

(cherry picked from commit a46b3d1)
Eric-Arellano added a commit that referenced this pull request Nov 7, 2024
Before, we would only show type hints for parameters that had dedicated docstring. There are a lot of parameters that don't have docstring—and sometimes don't need it because it's obvious—so it's best to no matter what show the docstring.

This PR aligns the autodoc templates and config with the other addons like cutting.

(cherry picked from commit a46b3d1)

Co-authored-by: Eric Arellano <[email protected]>
Eric-Arellano added a commit to Qiskit/qiskit-addon-utils that referenced this pull request Nov 7, 2024
mergify bot pushed a commit to Qiskit/qiskit-addon-utils that referenced this pull request Nov 7, 2024
See Qiskit/qiskit-addon-obp#31 for context.

(cherry picked from commit eb1870d)
Eric-Arellano added a commit to Qiskit/qiskit-addon-utils that referenced this pull request Nov 7, 2024
See Qiskit/qiskit-addon-obp#31 for context.

(cherry picked from commit eb1870d)

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 Label for mergify to open a backport PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants