Skip to content

Commit eca6ce2

Browse files
authored
Documentation fixes and formatting (#1095)
### Summary This PR is essentially the documentation fixes from #1080 since the lint CI pipeline needs more work. ### Details and comments - The docs are no longer incompatible with the newest sphinx-autodoc-typehints so the version pin from #1017 has been removed. This closes #1018. - Updates curve analysis tutorial to the newest version (#983 had accidentally reverted to an older version) - Changes arxiv autolinks from pdfs to abstract page to be more user friendly - Renames the new ExperimentData how-to to rerunning analysis and adds additional info on using `add_data` - Moved functions from `curve_analysis/data_processing.py` to `utils.py` - Changes benchmarking experiments to verification experiments on the manual page to match the library API page - Added referenced classes and functions that weren't included in the docs - Various formatting fixes for passing Sphinx nitpick mode
1 parent 116689d commit eca6ce2

File tree

63 files changed

+791
-732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+791
-732
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
### Summary
22

3-
Please describe what this PR changes as concisely as possible. Link to the issue(s)
4-
that this addresses, if any.
3+
Please describe what this PR changes as concisely as possible. Link to the issue(s) that this addresses, if any.
54

65
### Details and comments
76

@@ -12,15 +11,11 @@ Some details that should be in this section include:
1211
- What tests and documentation have been added/updated
1312
- What do users and developers need to know about this change
1413

15-
Note that this entire PR description field will be used as the commit message upon
16-
merge, so please keep it updated along with the PR. Secondary discussions, such as
17-
intermediate testing and bug statuses that do not affect the final PR, should be in the
18-
PR comments.
14+
Note that this entire PR description field will be used as the commit message upon merge, so please keep it updated along with the PR. Secondary discussions, such as intermediate testing and bug statuses that do not affect the final PR, should be in the PR comments.
1915

2016
### PR checklist (delete when all criteria are met)
2117

2218
- [ ] I have read the contributing guide `CONTRIBUTING.md`.
2319
- [ ] I have added the tests to cover my changes.
2420
- [ ] I have updated the documentation accordingly.
25-
- [ ] I have added a release note file using `reno` if this change needs to be
26-
documented in the release notes.
21+
- [ ] I have added a release note file using `reno` if this change needs to be documented in the release notes.

CONTRIBUTING.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,18 @@ should look something like:
227227
```yaml
228228
features:
229229
- |
230-
Introduced a new feature foo, that adds support for doing something to
231-
``QuantumCircuit`` objects. It can be used by using the foo function,
230+
Introduced a new feature foo that adds support for doing something to
231+
:class:`~qiskit.circuit.QuantumCircuit` objects. It can be used by using the foo function,
232232
for example::
233233
234234
from qiskit import foo
235235
from qiskit import QuantumCircuit
236236
foo(QuantumCircuit())
237237
238238
- |
239-
The ``qiskit.QuantumCircuit`` module has a new method ``foo()``. This is
240-
the equivalent of calling the ``qiskit.foo()`` to do something to your
241-
QuantumCircuit. This is the equivalent of running ``qiskit.foo()`` on
239+
The :class:`~qiskit.circuit.QuantumCircuit` class has a new method :meth:`.foo`. This is
240+
the equivalent of calling :func:`qiskit.foo` to do something to your
241+
QuantumCircuit. This is the equivalent of running :func:`qiskit.foo` on
242242
your circuit, but provides the convenience of running it natively on
243243
an object. For example::
244244
@@ -249,11 +249,11 @@ features:
249249
250250
deprecations:
251251
- |
252-
The ``qiskit.bar`` module has been deprecated and will be removed in a
253-
future release. Its sole function, ``foobar()`` has been superseded by the
254-
``qiskit.foo()`` function which provides similar functionality but with
252+
The :mod:`qiskit.bar` module has been deprecated and will be removed in a
253+
future release. Its sole function, :func:`foobar` has been superseded by the
254+
:func:`qiskit.foo` function which provides similar functionality but with
255255
more accurate results and better performance. You should update your calls
256-
``qiskit.bar.foobar()`` calls to ``qiskit.foo()``.
256+
:func:`qiskit.bar.foobar` calls to :func:`qiskit.foo`.
257257
```
258258
259259
You can also look at existing release notes for more examples.
@@ -348,9 +348,12 @@ There are a few other build options available:
348348
Qiskit Experiments is part of Qiskit and, therefore, the [Qiskit Deprecation
349349
Policy](https://qiskit.org/documentation/contributing_to_qiskit.html#deprecation-policy)
350350
fully applies here. We have a deprecation decorator for showing deprecation warnings. To
351-
deprecate a function:
351+
deprecate a function, for example:
352352

353353
```python
354+
355+
from qiskit_experiments.warnings import deprecated_function
356+
354357
@deprecated_function(last_version="0.3", msg="Use new_function instead.")
355358
def old_function(*args, **kwargs):
356359
pass
@@ -361,6 +364,8 @@ deprecate a function:
361364
To deprecate a class:
362365

363366
```python
367+
from qiskit_experiments.warnings import deprecated_class
368+
364369
@deprecated_class(last_version="0.3", new_cls=NewCls)
365370
class OldClass:
366371
pass
@@ -408,5 +413,5 @@ following steps:
408413
4. Generate a PR on the meta-repository to bump the qiskit-experiments version and
409414
meta-package version.
410415

411-
The `stable/*` branches should only receive changes in the form of bug fixes.
416+
The `stable/*` branches should only receive changes in the form of bug fixes. If you're making a bug fix PR that you believe should be backported to the current stable release, tag it with `backport stable potential`.
412417

docs/GUIDELINES.md

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Contents:
66
- [Guidelines for writing documentation](#guidelines-for-writing-documentation)
77
- [Introduction](#introduction)
88
- [General formatting guidelines](#general-formatting-guidelines)
9+
- [Writing code](#writing-code)
10+
- [Referencing objects](#referencing-objects)
911
- [Tutorials](#tutorials)
1012
- [How-to guides](#how-to-guides)
1113
- [Experiment manuals](#experiment-manuals)
@@ -23,6 +25,22 @@ Qiskit Experiments documentation is split into four sections:
2325
- Experiment manuals for information on specific experiments
2426
- API reference for technical documentation
2527

28+
### General formatting guidelines
29+
30+
* For experiments, the documentation title should be just the name of the experiment. Use
31+
regular capitalization
32+
* Use headers, subheaders, subsubheaders etc. for hierarchical text organization. No
33+
need to number the headers
34+
* Use present progressive for subtitles, such as "Saving experiment data to the
35+
database" instead of "Save experiment data to the database"
36+
* Use math notation as much as possible (e.g. use $\frac{\pi}{2}$ instead of pi-half or
37+
pi/2)
38+
* Use device names as shown in the IBM Quantum Services dashboard, e.g. `ibmq_lima`
39+
instead of IBMQ Lima
40+
* put identifier names (e.g. osc_freq) in code blocks using double backticks, i.e. `osc_freq`
41+
42+
### Writing code
43+
2644
All documentation is written in reStructuredText format and then built into formatted
2745
text by Sphinx. Code cells can be written using `jupyter-execute` blocks, which will be
2846
automatically executed, with both code and output shown to the user:
@@ -31,36 +49,29 @@ automatically executed, with both code and output shown to the user:
3149

3250
# write Python code here
3351

34-
Your code should use the appropriate mock backend to show what expected experiment
35-
results might look like for the user. To instantiate a mock backend without exposing it
36-
to the user, use the `:hide-code:` and `:hide-output:` directives:
37-
38-
.. jupyter-execute::
39-
:hide-code:
40-
:hide-output:
41-
42-
from qiskit.test.ibmq_mock import mock_get_backend
43-
backend = mock_get_backend('FakeLima')
44-
4552
To display a block without actually executing the code, use the `.. jupyter-input::` and
4653
`.. jupyter-output::` directives. To ignore an error from a Jupyter cell block, use the
4754
`:raises:` directive. To see more options, consult the [Jupyter Sphinx documentation](https://jupyter-sphinx.readthedocs.io/en/latest/).
4855

49-
### General formatting guidelines
56+
### Referencing objects
57+
58+
Modules, classes, methods, functions, and attributes mentioned in the documentation
59+
should link to their API documentation whenever possible using the `:mod:`, `:class:`,
60+
`:meth:`, `:func:`, and `:attr:` directives followed by the name of the object in single
61+
backticks. Here are some common usage patterns:
62+
63+
- `` :class:`.CurveAnalysis` ``: This will render a link to the curve analysis class
64+
`CurveAnalysis` if its name is unique.
65+
- `` :class:`qiskit_experiments.curve_analysis.CurveAnalysis` ``: This will render the
66+
full path to the object with a link as long as the path is correct.
67+
- `` :class:`~qiskit_experiments.curve_analysis.CurveAnalysis` ``: This will render only
68+
the object name itself instead of the full path. It's simpler to use the first pattern
69+
instead if the name is unique.
70+
71+
Consult the [Sphinx documentation](https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html) for more detailed syntax.
5072

51-
* For experiments, documentation title should be just the name of the experiment. Use
52-
regular capitalization.
53-
* Use headers, subheaders, subsubheaders etc. for hierarchical text organization. No
54-
need to number the headers
55-
* Use present progressive for subtitles, such as "Saving experiment data to the
56-
database" instead of "Save experiment data to the database"
57-
* Use math notation as much as possible (e.g. use $\frac{\pi}{2}$ instead of pi-half or
58-
pi/2)
59-
* Use device names as shown in the IBM Quantum Services dashboard, e.g. `ibmq_lima`
60-
instead of IBMQ Lima
61-
* put identifier names (e.g. osc_freq) in code blocks using double backticks, i.e. `osc_freq`
6273

63-
Below we provide templates and guidelines for each of these types of documentation.
74+
Below are templates and guidelines for each of these types of documentation.
6475

6576
### Tutorials
6677

docs/_ext/autoref.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class WebSite(Directive):
3030
.. ref_website:: qiskit-experiments, https://github.com/Qiskit/qiskit-experiments
3131
3232
"""
33+
3334
required_arguments = 1
3435
optional_arguments = 0
3536
final_argument_whitespace = True
@@ -67,6 +68,7 @@ class Arxiv(Directive):
6768
If an article is not found, no journal information will be shown.
6869
6970
"""
71+
7072
required_arguments = 2
7173
optional_arguments = 0
7274
final_argument_whitespace = False
@@ -95,7 +97,7 @@ def run(self):
9597
if journal:
9698
ret_node += nodes.Text(journal)
9799
ret_node += nodes.Text(" ")
98-
ret_node += nodes.reference(text="(open)", refuri=paper.pdf_url)
100+
ret_node += nodes.reference(text="(open)", refuri=paper.entry_id)
99101

100102
return [ret_node]
101103

docs/conf.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010
# copyright notice, and modified files need to carry a notice indicating
1111
# that they have been altered from the originals.
1212

13-
# pylint: disable=invalid-name
14-
# Configuration file for the Sphinx documentation builder.
15-
#
16-
# This file does only contain a selection of the most common options. For a
17-
# full list see the documentation:
18-
# http://www.sphinx-doc.org/en/master/config
19-
2013
"""
2114
Sphinx documentation builder.
2215
"""
@@ -53,13 +46,6 @@
5346

5447
# -- General configuration ---------------------------------------------------
5548

56-
# If your documentation needs a minimal Sphinx version, state it here.
57-
#
58-
# needs_sphinx = '1.0'
59-
60-
# Add any Sphinx extension module names here, as strings. They can be
61-
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
62-
# ones.
6349
extensions = [
6450
"sphinx.ext.napoleon",
6551
"sphinx.ext.autodoc",
@@ -94,11 +80,11 @@
9480
# These should ideally be automatically generated using a custom macro to specify
9581
# chosen cells for thumbnails, like the nbsphinx-gallery tag
9682
nbsphinx_thumbnails = {
97-
"manuals/benchmarking/quantum_volume": "_images/quantum_volume_2_0.png",
83+
"manuals/verification/quantum_volume": "_images/quantum_volume_2_0.png",
9884
"manuals/measurement/readout_mitigation": "_images/readout_mitigation_4_0.png",
99-
"manuals/benchmarking/randomized_benchmarking": "_images/randomized_benchmarking_3_1.png",
85+
"manuals/verification/randomized_benchmarking": "_images/randomized_benchmarking_3_1.png",
10086
"manuals/measurement/restless_measurements": "_images/restless_shots.png",
101-
"manuals/benchmarking/state_tomography": "_images/state_tomography_3_0.png",
87+
"manuals/verification/state_tomography": "_images/state_tomography_3_0.png",
10288
"manuals/characterization/t1": "_images/t1_0_0.png",
10389
"manuals/characterization/t2ramsey": "_images/t2ramsey_4_0.png",
10490
"manuals/characterization/tphi": "_images/tphi_5_1.png",
@@ -121,11 +107,7 @@
121107
# strings that are used for format of figure numbers. As a special character,
122108
# %s will be replaced to figure number.
123109
numfig_format = {"table": "Table %s"}
124-
# The language for content autogenerated by Sphinx. Refer to documentation
125-
# for a list of supported languages.
126-
#
127-
# This is also used if you do content translation via gettext catalogs.
128-
# Usually you set "language" from the command line for these cases.
110+
129111
language = "en"
130112

131113
# List of patterns, relative to source directory, that match files and
@@ -185,9 +167,6 @@
185167

186168
if os.getenv("EXPERIMENTS_DEV_DOCS", None):
187169
rst_prolog = """
188-
.. raw:: html
189-
190-
<br><br><br>
191170
.. note::
192171
This is the documentation for the current state of the development branch
193172
of Qiskit Experiments. The documentation or APIs here can change prior to being

docs/howtos/cloud_service.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ backend and not a simulator to be able to save the experiment data. This is done
3636

3737
t1_delays = np.arange(1e-6, 600e-6, 50e-6)
3838

39-
exp = T1(qubit=0, delays=t1_delays)
39+
exp = T1(physical_qubits=(0,), delays=t1_delays)
4040

4141
t1_expdata = exp.run(backend=backend).block_for_results()
4242
t1_expdata.save()
@@ -131,7 +131,7 @@ The :meth:`~.ExperimentData.auto_save` feature automatically saves changes to th
131131

132132
.. jupyter-input::
133133

134-
exp = T1(qubit=0, delays=t1_delays)
134+
exp = T1(physical_qubits=(0,), delays=t1_delays)
135135

136136
t1_expdata = exp.run(backend=backend, shots=1000)
137137
t1_expdata.auto_save = True

docs/howtos/job_splitting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can set the ``max_circuits`` option manually when running an experiment:
1515

1616
.. jupyter-input::
1717

18-
exp = Experiment([0])
18+
exp = Experiment((0,))
1919
exp.set_experiment_options(max_circuits=100)
2020

2121
The experiment class will split its circuits into jobs such that no job has more than

docs/howtos/new_experimentdata.rst

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)