-
Notifications
You must be signed in to change notification settings - Fork 127
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
Cleanup structure of option documentation #1077
Cleanup structure of option documentation #1077
Conversation
4afcec2
to
076a6e9
Compare
…te/analysis-class-doc
…archy. Add missing option documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great improvement! And thanks for updating docstrings, this also closes #1007.
docs/_ext/custom_styles/utils.py
Outdated
description = "inherited from the parent class" | ||
options_docstring_lines.extend( | ||
[ | ||
f"(Options {description} :class:`.{mro_cls.__name__}`)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the parentheses are necessary. What do you think about f"Options {description} :class:`.{mro_cls.__name__}`:"
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thinking of this. However, the structure of sections, i.e. Experiment Options, Transpiler Options, Run Options
, became difficult to understand because these section tiles (.. rubric::
) and added plain text are the same font size. Do you know better Sphinx directive for these section titles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, what about changing the .. rubric::
section titles to headings, and changing this line to .. rubric::
? Then it would look something like this:
I think it's nice to promote the section titles to headings so they can be linked to easily, and in theory the user can also quickly jump to a section using the sidebar.
Also, I wonder if we should move the default option value into the option description and remove the dropdown, would that look cleaner? Something like,
- max_circuits (Optional[int], default:
None
) – The maximum number of circuits per job when running an experiment on a backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good idea. Default value can be sometime very long (e.g. ndarray of length 100 to represent scanned value), sometime without pretty printing, and such value make documentation unnecessary long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just remembered I tried section heading before. The underline of section title breaks build in section of parameters (i.e. Args:
) because we are likely mixing up the Google style and Numpy style. As you posted, Parameter formatting is now broken and they are shown like type lengths:
in your screen shot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info, I was wondering why the parameters were all messed up after I converted the heading. I tried a bunch of things and setting napoleon_use_param = False
in conf.py
seems to work:
Also, for the default values, I agree they can be very long sometimes. There are also examples like plotter := <qiskit_experiments.visualization.plotters.iq_plotter.IQPlotter object at 0x1763b8c70>
which is confusing. Maybe we can just show the object type instead of the repr
in cases like these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this is close. I didn't consider the difference of :param:
role and single :parameters:
role. It indeed worked for parsing parameters under the section, but it broke other documentations with Type Annotations. We usually write type hints in the code, but they won't show up. I guess this is a bug though... For example this is constructor of StandardRB
. Note that documentation of raises also looks strange. There is no napoleon_use_raises
option. Probably we need to full scratch the documenter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess there's no easy fix then. We can leave it as possible future work.
For default values, I think showing numpy.linspace(-0.95, 0.95, 51)
is a lot more readable than that block. But is there a way to do that besides manually calculating the start end and step size from the array? Or we can add an optional field in the experiment options docstring allowing override of the default display value in cases like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's likely tough to get args for ndarray factory. I implemented truncation in b1936a3
Sphinx parser doesn't support line break during the type hint. Long type hint is not shown properly in the API doc. New logic is added to the Sphinx extension to remove these line feeds.
Co-authored-by: Helena Zhang <[email protected]>
…also injection that references superclasses.
b1936a3
to
577ff71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is really close! The truncated default values look nice. I noticed that InterleavedRB
is showing StandardRB
options as coming from itself instead, not sure why that's happening again.
Co-authored-by: Helena Zhang <[email protected]>
Co-authored-by: Helena Zhang <[email protected]>
…te/analysis-class-doc
…te/analysis-class-doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Summary
close #1076
Details and comments
Note that from end-user perspective subclass option and parent class option don't matter because one gets mixture of all inherited and subclass options when calling
analysis.options
for example.