From 30df1e27db814049ef68a6400f007f2324bac2db Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Fri, 30 Jun 2023 11:40:58 -0600 Subject: [PATCH 1/8] Upgrade to qiskit-sphinx-theme 1.13 --- docs/getting_started.rst | 53 +++++++------------------ docs/index.rst | 86 +++++++++++++++++----------------------- docs/tutorials.rst | 18 +-------- requirements-dev.txt | 4 +- 4 files changed, 54 insertions(+), 107 deletions(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 70a377e68d9c..55794b025406 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -75,34 +75,18 @@ going to run and install the packages. There are three main ways to do this: The following cloud vendors have Qiskit pre-installed in their environments: - .. raw:: html - -
-
-
-
-
- - .. qiskit-card-item:: + .. qiskit-card:: :header: IBM Quantum Lab :card_description: Build quantum applications and experiments with Qiskit in a cloud programming environment. - :image: images/ibm_qlab.png + :image: _static/images/ibm_qlab.png :link: https://quantum-computing.ibm.com/ - .. qiskit-card-item:: + .. qiskit-card:: :header: Strangeworks :card_description: A platform that enables users and organizations to easily apply quantum computing to their most pressing problems and research. - :image: images/strangeworks.png + :image: _static/images/strangeworks.png :link: https://strangeworks.com/ - .. raw:: html - -
- -
-
-
- .. tab-item:: Install from source Installing the elements from source allows you to access the most recently @@ -507,27 +491,20 @@ Tier 3 platforms are currently: Ready to get going?... ====================== -.. raw:: html - -
-
- -.. qiskit-call-to-action-item:: - :description: Learn how to build, execute, and post-process quantum circuits with Qiskit. - :header: Qiskit from the ground up - :button_link: intro_tutorial1.html - :button_text: Start learning Qiskit - +.. qiskit-call-to-action-grid:: -.. qiskit-call-to-action-item:: - :description: Find out how to leverage Qiskit for everything from single-circuits to full quantum application development. - :header: Dive into the tutorials - :button_link: tutorials.html - :button_text: Qiskit tutorials + .. qiskit-call-to-action-item:: + :description: Learn how to build, execute, and post-process quantum circuits with Qiskit. + :header: Qiskit from the ground up + :button_link: intro_tutorial1.html + :button_text: Start learning Qiskit -.. raw:: html + .. qiskit-call-to-action-item:: + :description: Find out how to leverage Qiskit for everything from single-circuits to full quantum application development. + :header: Dive into the tutorials + :button_link: tutorials.html + :button_text: Qiskit tutorials -
.. Hiding - Indices and tables :ref:`genindex` diff --git a/docs/index.rst b/docs/index.rst index be7689348470..7a4392f6d0b8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,63 +12,49 @@ them on real quantum computers or classical simulators. Qiskit is already in use around the world by beginners, hobbyists, educators, researchers, and commercial companies. -.. raw:: html +.. qiskit-call-to-action-grid:: -
+ .. qiskit-call-to-action-item:: + :header: Access to quantum systems + :description: Find out which Qiskit providers support execution on real quantum services. + :button_link: https://qiskit.org/providers + :button_text: Quantum providers - -.. qiskit-call-to-action-item:: - :header: Access to quantum systems - :description: Find out which Qiskit providers support execution on real quantum services. - :button_link: https://qiskit.org/providers - :button_text: Quantum providers - - -.. qiskit-call-to-action-item:: - :header: Qiskit ecosystem - :description: The Qiskit ecosystem consists of projects, tools, utilities, libraries and tutorials from a broad community of developers and researchers. - :button_link: https://qiskit.org/ecosystem/ - :button_text: Explore the Qiskit ecosystem - -.. raw:: html - -
+ .. qiskit-call-to-action-item:: + :header: Qiskit ecosystem + :description: The Qiskit ecosystem consists of projects, tools, utilities, libraries and tutorials from a broad community of developers and researchers. + :button_link: https://qiskit.org/ecosystem/ + :button_text: Explore the Qiskit ecosystem Main Qiskit-related projects ############################ -.. raw:: html - -
- -.. qiskit-call-to-action-item:: - :header: Qiskit Experiments - :description: Run characterization, calibration, and verification experiments - :button_link: https://qiskit.org/ecosystem/experiments/ - :button_text: Qiskit Experiments documentation - -.. qiskit-call-to-action-item:: - :header: Qiskit Dynamics - :description: Tools for building and solving models of quantum systems in Qiskit - :button_link: https://qiskit.org/ecosystem/dynamics/ - :button_text: Qiskit Dynamics documentation - -.. qiskit-call-to-action-item:: - :header: Qiskit IBM Runtime - :description: Qiskit Runtime is a cloud base implementation of the Qiskit primitives to effectively execute workloads on IBM Quantum systems. - :button_link: https://qiskit.org/ecosystem/ibm-runtime/ - :button_text: Qiskit Runtime documentation - -.. qiskit-call-to-action-item:: - :header: IBM Quantum Provider - :description: A Qiskit provider that allows accessing the IBM Quantum systems and cloud simulators. - :button_link: https://qiskit.org/ecosystem/ibm-runtime/ - :button_text: Qiskit IBM provider documentation - -.. raw:: html - -
+.. qiskit-call-to-action-grid:: + + .. qiskit-call-to-action-item:: + :header: Qiskit Experiments + :description: Run characterization, calibration, and verification experiments + :button_link: https://qiskit.org/ecosystem/experiments/ + :button_text: Qiskit Experiments documentation + + .. qiskit-call-to-action-item:: + :header: Qiskit Dynamics + :description: Tools for building and solving models of quantum systems in Qiskit + :button_link: https://qiskit.org/ecosystem/dynamics/ + :button_text: Qiskit Dynamics documentation + + .. qiskit-call-to-action-item:: + :header: Qiskit IBM Runtime + :description: Qiskit Runtime is a cloud base implementation of the Qiskit primitives to effectively execute workloads on IBM Quantum systems. + :button_link: https://qiskit.org/ecosystem/ibm-runtime/ + :button_text: Qiskit Runtime documentation + + .. qiskit-call-to-action-item:: + :header: IBM Quantum Provider + :description: A Qiskit provider that allows accessing the IBM Quantum systems and cloud simulators. + :button_link: https://qiskit.org/ecosystem/ibm-runtime/ + :button_text: Qiskit IBM provider documentation .. toctree:: diff --git a/docs/tutorials.rst b/docs/tutorials.rst index 2b71843bd834..40d63617bf62 100644 --- a/docs/tutorials.rst +++ b/docs/tutorials.rst @@ -9,28 +9,12 @@ Tutorials Introductory ============ -.. raw:: html - -
-
-
-
-
- -.. qiskit-card-item:: +.. qiskit-card:: :header: Qiskit warmup :card_description: An introduction to Qiskit and the primary user workflow. :image: _static/images/logo.png :link: intro_tutorial1.html -.. raw:: html - -
- -
-
- - Quantum circuits ================ diff --git a/requirements-dev.txt b/requirements-dev.txt index 4e5ba9862e1c..c214e9151a51 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ qiskit-ibmq-provider[visualization] numpy>=1.17 -Sphinx>=5.0 -qiskit-sphinx-theme~=1.12.0 +Sphinx>=6.0 +qiskit-sphinx-theme~=1.13.0rc1 pylatexenc>=1.4 sphinx-automodapi jupyter From c0e269036c4478aeb3463bee02586cf87c166ccc Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Fri, 30 Jun 2023 11:42:48 -0600 Subject: [PATCH 2/8] Use new qiskit-sphinx-theme based on Furo --- docs/conf.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 81e26f79ace8..5a7f1d76cd75 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -138,19 +138,7 @@ # -- Options for HTML output ------------------------------------------------- -html_theme = "qiskit_sphinx_theme" -html_theme_options = { - "logo_only": False, - "display_version": True, - "prev_next_buttons_location": "bottom", - "style_external_links": True, - # Toc options - "collapse_navigation": True, - "sticky_navigation": True, - "navigation_depth": 4, - "includehidden": True, - "titles_only": False, -} +html_theme = "qiskit" html_favicon = "images/favicon.ico" html_last_updated_fmt = "%Y/%m/%d" html_context = { From 21f90db36b298d1da54b0364d61271735a707431 Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Fri, 30 Jun 2023 11:52:13 -0600 Subject: [PATCH 3/8] Get rid of docutils constraint --- constraints.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/constraints.txt b/constraints.txt index f80df929966b..745ae9c18cb1 100644 --- a/constraints.txt +++ b/constraints.txt @@ -2,7 +2,6 @@ astroid==2.14.2 pylint==2.16.2 cryptography==39.0.1 decorator==4.4.2 -docutils==0.16 # importlib_metadata 5.0 is broken with stevedore, so pin to the last # functional version in the 4.x series. From b76efcacbbfaaa53559baa1cd3aeadc444061b2b Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Mon, 3 Jul 2023 13:24:44 -0600 Subject: [PATCH 4/8] Try no page per method --- .gitignore | 1 - docs/_templates/class.rst | 31 +++++++++++++++++++ .../_templates/class_no_inherited_members.rst | 28 +++++++++++++++++ docs/custom_extensions.py | 1 - tox.ini | 1 - 5 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 docs/_templates/class.rst create mode 100644 docs/_templates/class_no_inherited_members.rst diff --git a/.gitignore b/.gitignore index 104fd8cd3874..dbd0acf77030 100644 --- a/.gitignore +++ b/.gitignore @@ -78,7 +78,6 @@ docs/stubs docs/plot_directive docs/jupyter_execute/ docs/migration_guides -docs/_templates docs/source_images docs/.doctrees/ stubs/ diff --git a/docs/_templates/class.rst b/docs/_templates/class.rst new file mode 100644 index 000000000000..daff18c1e280 --- /dev/null +++ b/docs/_templates/class.rst @@ -0,0 +1,31 @@ +{# + We show all the class's methods and attributes on the same page. By default, we document + all methods, including those defined by parent classes. +-#} + +{{ objname | escape | underline }} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + :no-members: + :show-inheritance: + +{% block attributes_summary %} + {% if attributes %} + .. rubric:: Attributes + {% for item in attributes %} + .. autoattribute:: {{ item }} + {%- endfor %} + {% endif %} +{% endblock -%} + +{% block methods_summary %} + {% set wanted_methods = (methods | reject('==', '__init__') | list) %} + {% if wanted_methods %} + .. rubric:: Methods + {% for item in wanted_methods %} + .. automethod:: {{ item }} + {%- endfor %} + {% endif %} +{% endblock %} diff --git a/docs/_templates/class_no_inherited_members.rst b/docs/_templates/class_no_inherited_members.rst new file mode 100644 index 000000000000..269a89b70718 --- /dev/null +++ b/docs/_templates/class_no_inherited_members.rst @@ -0,0 +1,28 @@ +{# This is identical to class.rst, except for the filtering in `set wanted_methods`. -#} + +{{ objname | escape | underline }} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + :no-members: + :show-inheritance: + +{% block attributes_summary %} + {% if attributes %} + .. rubric:: Attributes + {% for item in attributes %} + .. autoattribute:: {{ item }} + {%- endfor %} + {% endif %} +{% endblock -%} + +{% block methods_summary %} + {% set wanted_methods = (methods | reject('in', inherited_members) | reject('==', '__init__') | list) %} + {% if wanted_methods %} + .. rubric:: Methods + {% for item in wanted_methods %} + .. automethod:: {{ item }} + {%- endfor %} + {% endif %} +{% endblock %} diff --git a/docs/custom_extensions.py b/docs/custom_extensions.py index 104d2f2d3484..a41b72aaf6b9 100644 --- a/docs/custom_extensions.py +++ b/docs/custom_extensions.py @@ -21,7 +21,6 @@ TERRA_DIRS = [ "apidoc", "migration_guides", - "_templates", "source_images", ] diff --git a/tox.ini b/tox.ini index be28bd879236..f5513551b448 100644 --- a/tox.ini +++ b/tox.ini @@ -71,7 +71,6 @@ commands = {toxinidir}/docs/tutorials \ {toxinidir}/docs/migration_guides \ {toxinidir}/docs/source_images \ - {toxinidir}/docs/_templates \ {toxinidir}/docs/plot_directive \ {toxinidir}/docs/jupyter_execute \ {toxinidir}/docs/.doctrees From bd67c9de913cec287ef9647fcf7ac8ccc08567c9 Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Fri, 7 Jul 2023 09:39:35 -0600 Subject: [PATCH 5/8] Try out trim_toctree --- docs/conf.py | 42 ++++++++++++++++++++++++++++++++++++++++++ requirements-dev.txt | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 5a7f1d76cd75..dc86a6151c7c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,9 @@ import datetime import os +import re import sys +from pathlib import Path import sphinx.ext.doctest @@ -199,8 +201,48 @@ # -- Extension configuration ------------------------------------------------- +def is_method_stub(stub_path: str) -> bool: + regex = re.compile(r"stubs/.*\.[A-Z][a-zA-Z0-9]*\.[a-z_0-9]+$") + return bool(re.match(regex, stub_path)) + + +def trim_toctree(_: sphinx.application.Sphinx, env) -> None: + """ + Remove method pages from the left table of contents because they dramatically slow down docs + builds and bloat HTML page size. + + See https://github.com/Qiskit/qiskit_sphinx_theme/issues/328 and + https://github.com/pradyunsg/furo/pull/674. + + Note that more robust is for repositories to reorganize their code to not have dedicated pages. + But this provides an escape hatch while migrating. + + Code inspired by sphinx-remove-toctrees (created by Chris Holdgraf) and used under the MIT + license. + """ + to_remove = [] + srcdir = Path(env.srcdir) + for stub in srcdir.glob("stubs/*"): + rel_path = str(stub.relative_to(srcdir).with_suffix("")) + if is_method_stub(rel_path): + to_remove.append(rel_path) + + for _, tocs in env.tocs.items(): + for toctree in tocs.traverse(sphinx.addnodes.toctree): + new_entries = [] + for entry in toctree.attributes.get("entries", []): + if entry[1] not in to_remove: + new_entries.append(entry) + # If there are no more entries, just remove the toctree. + if len(new_entries) == 0: + toctree.parent.remove(toctree) + else: + toctree.attributes["entries"] = new_entries + + def setup(app): custom_extensions.load_terra_docs(app) custom_extensions.load_tutorials(app) versionutils.setup(app) app.connect("build-finished", custom_extensions.clean_docs) + app.connect("env-updated", trim_toctree) diff --git a/requirements-dev.txt b/requirements-dev.txt index c214e9151a51..52f1acb1cca9 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ qiskit-ibmq-provider[visualization] numpy>=1.17 Sphinx>=6.0 -qiskit-sphinx-theme~=1.13.0rc1 +qiskit-sphinx-theme~=1.13.0rc2 pylatexenc>=1.4 sphinx-automodapi jupyter From 973cff162e2082cd9bc667389cc7251715b3a50c Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Fri, 7 Jul 2023 09:41:44 -0600 Subject: [PATCH 6/8] Revert "Try no page per method" This reverts commit b76efcacbbfaaa53559baa1cd3aeadc444061b2b. --- .gitignore | 1 + docs/_templates/class.rst | 31 ------------------- .../_templates/class_no_inherited_members.rst | 28 ----------------- docs/custom_extensions.py | 1 + tox.ini | 1 + 5 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 docs/_templates/class.rst delete mode 100644 docs/_templates/class_no_inherited_members.rst diff --git a/.gitignore b/.gitignore index dbd0acf77030..104fd8cd3874 100644 --- a/.gitignore +++ b/.gitignore @@ -78,6 +78,7 @@ docs/stubs docs/plot_directive docs/jupyter_execute/ docs/migration_guides +docs/_templates docs/source_images docs/.doctrees/ stubs/ diff --git a/docs/_templates/class.rst b/docs/_templates/class.rst deleted file mode 100644 index daff18c1e280..000000000000 --- a/docs/_templates/class.rst +++ /dev/null @@ -1,31 +0,0 @@ -{# - We show all the class's methods and attributes on the same page. By default, we document - all methods, including those defined by parent classes. --#} - -{{ objname | escape | underline }} - -.. currentmodule:: {{ module }} - -.. autoclass:: {{ objname }} - :no-members: - :show-inheritance: - -{% block attributes_summary %} - {% if attributes %} - .. rubric:: Attributes - {% for item in attributes %} - .. autoattribute:: {{ item }} - {%- endfor %} - {% endif %} -{% endblock -%} - -{% block methods_summary %} - {% set wanted_methods = (methods | reject('==', '__init__') | list) %} - {% if wanted_methods %} - .. rubric:: Methods - {% for item in wanted_methods %} - .. automethod:: {{ item }} - {%- endfor %} - {% endif %} -{% endblock %} diff --git a/docs/_templates/class_no_inherited_members.rst b/docs/_templates/class_no_inherited_members.rst deleted file mode 100644 index 269a89b70718..000000000000 --- a/docs/_templates/class_no_inherited_members.rst +++ /dev/null @@ -1,28 +0,0 @@ -{# This is identical to class.rst, except for the filtering in `set wanted_methods`. -#} - -{{ objname | escape | underline }} - -.. currentmodule:: {{ module }} - -.. autoclass:: {{ objname }} - :no-members: - :show-inheritance: - -{% block attributes_summary %} - {% if attributes %} - .. rubric:: Attributes - {% for item in attributes %} - .. autoattribute:: {{ item }} - {%- endfor %} - {% endif %} -{% endblock -%} - -{% block methods_summary %} - {% set wanted_methods = (methods | reject('in', inherited_members) | reject('==', '__init__') | list) %} - {% if wanted_methods %} - .. rubric:: Methods - {% for item in wanted_methods %} - .. automethod:: {{ item }} - {%- endfor %} - {% endif %} -{% endblock %} diff --git a/docs/custom_extensions.py b/docs/custom_extensions.py index a41b72aaf6b9..104d2f2d3484 100644 --- a/docs/custom_extensions.py +++ b/docs/custom_extensions.py @@ -21,6 +21,7 @@ TERRA_DIRS = [ "apidoc", "migration_guides", + "_templates", "source_images", ] diff --git a/tox.ini b/tox.ini index f5513551b448..be28bd879236 100644 --- a/tox.ini +++ b/tox.ini @@ -71,6 +71,7 @@ commands = {toxinidir}/docs/tutorials \ {toxinidir}/docs/migration_guides \ {toxinidir}/docs/source_images \ + {toxinidir}/docs/_templates \ {toxinidir}/docs/plot_directive \ {toxinidir}/docs/jupyter_execute \ {toxinidir}/docs/.doctrees From 217cce27576638d43d801bd055a8924d8baea1ee Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Sat, 8 Jul 2023 06:34:02 -0600 Subject: [PATCH 7/8] Revert "Try out trim_toctree" This reverts commit bd67c9de913cec287ef9647fcf7ac8ccc08567c9. --- docs/conf.py | 42 ------------------------------------------ requirements-dev.txt | 2 +- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a16a69b3a808..c3859fc08be7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,9 +18,7 @@ import datetime import os -import re import sys -from pathlib import Path import sphinx.ext.doctest @@ -210,48 +208,8 @@ # -- Extension configuration ------------------------------------------------- -def is_method_stub(stub_path: str) -> bool: - regex = re.compile(r"stubs/.*\.[A-Z][a-zA-Z0-9]*\.[a-z_0-9]+$") - return bool(re.match(regex, stub_path)) - - -def trim_toctree(_: sphinx.application.Sphinx, env) -> None: - """ - Remove method pages from the left table of contents because they dramatically slow down docs - builds and bloat HTML page size. - - See https://github.com/Qiskit/qiskit_sphinx_theme/issues/328 and - https://github.com/pradyunsg/furo/pull/674. - - Note that more robust is for repositories to reorganize their code to not have dedicated pages. - But this provides an escape hatch while migrating. - - Code inspired by sphinx-remove-toctrees (created by Chris Holdgraf) and used under the MIT - license. - """ - to_remove = [] - srcdir = Path(env.srcdir) - for stub in srcdir.glob("stubs/*"): - rel_path = str(stub.relative_to(srcdir).with_suffix("")) - if is_method_stub(rel_path): - to_remove.append(rel_path) - - for _, tocs in env.tocs.items(): - for toctree in tocs.traverse(sphinx.addnodes.toctree): - new_entries = [] - for entry in toctree.attributes.get("entries", []): - if entry[1] not in to_remove: - new_entries.append(entry) - # If there are no more entries, just remove the toctree. - if len(new_entries) == 0: - toctree.parent.remove(toctree) - else: - toctree.attributes["entries"] = new_entries - - def setup(app): custom_extensions.load_terra_docs(app) custom_extensions.load_tutorials(app) versionutils.setup(app) app.connect("build-finished", custom_extensions.clean_docs) - app.connect("env-updated", trim_toctree) diff --git a/requirements-dev.txt b/requirements-dev.txt index 52f1acb1cca9..c214e9151a51 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ qiskit-ibmq-provider[visualization] numpy>=1.17 Sphinx>=6.0 -qiskit-sphinx-theme~=1.13.0rc2 +qiskit-sphinx-theme~=1.13.0rc1 pylatexenc>=1.4 sphinx-automodapi jupyter From e30e273078827d529e1c31905354e368206799fc Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Sat, 8 Jul 2023 06:45:08 -0600 Subject: [PATCH 8/8] Experiment with Furo and sphinx-remove-toctrees --- docs/conf.py | 3 +++ requirements-dev.txt | 1 + 2 files changed, 4 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index c3859fc08be7..9e3584374fad 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -59,6 +59,7 @@ "qiskit_sphinx_theme", "sphinx.ext.doctest", "sphinx.ext.intersphinx", + "sphinx_remove_toctrees", ] nbsphinx_timeout = 300 @@ -84,6 +85,8 @@ """ +remove_from_toctrees = ["stubs/*", "tutorials/*"] + panels_css_variables = { "tabs-color-label-active": "rgb(138, 63, 252)", "tabs-color-label-inactive": "rgb(221, 225, 230)", diff --git a/requirements-dev.txt b/requirements-dev.txt index c214e9151a51..4f15d97750e3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,6 +2,7 @@ qiskit-ibmq-provider[visualization] numpy>=1.17 Sphinx>=6.0 qiskit-sphinx-theme~=1.13.0rc1 +sphinx-remove-toctrees pylatexenc>=1.4 sphinx-automodapi jupyter