Skip to content

Commit 61a3a43

Browse files
Eric-ArellanoEric Arellano
andauthored
Speed up dev build of docs (Qiskit#10624)
* Speed up dev build of docs * empty commit * Fix tox issue --------- Co-authored-by: Eric Arellano <arellano@Erics-MacBook-Pro.local>
1 parent 8a180ee commit 61a3a43

4 files changed

Lines changed: 30 additions & 9 deletions

File tree

.github/workflows/docs_deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ jobs:
7777
QISKIT_ENABLE_ANALYTICS: "true"
7878
# We've already built them.
7979
QISKIT_DOCS_BUILD_TUTORIALS: "never"
80+
DOCS_PROD_BUILD: "true"
8081

8182
- name: Build translatable strings
82-
run: tox -e gettext
83+
run: tox run -e gettext
8384
env:
8485
# We've already built them.
8586
QISKIT_DOCS_BUILD_TUTORIALS: "never"
87+
DOCS_PROD_BUILD: "true"
8688

8789
- name: Store built documentation artifact
8890
uses: actions/upload-artifact@v3

docs/conf.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828
# The full version, including alpha/beta/rc tags
2929
release = "0.45.0"
3030

31-
# The language for content autogenerated by Sphinx or the default for gettext content translation.
3231
language = "en"
3332

34-
# For 'qiskit_sphinx_theme' tells it we're based at 'https://qiskit.org/<docs_url_prefix>'.
33+
# This tells 'qiskit_sphinx_theme' that we're based at 'https://qiskit.org/<docs_url_prefix>'.
3534
# Should not include the subdirectory for the stable version.
3635
docs_url_prefix = "documentation"
3736

@@ -42,15 +41,15 @@
4241
"sphinx.ext.autodoc",
4342
"sphinx.ext.autosummary",
4443
"sphinx.ext.mathjax",
45-
"sphinx.ext.viewcode",
4644
"sphinx.ext.extlinks",
4745
"sphinx.ext.intersphinx",
4846
"sphinx.ext.doctest",
49-
"reno.sphinxext",
50-
"sphinx_design",
47+
"nbsphinx",
5148
"matplotlib.sphinxext.plot_directive",
5249
"qiskit_sphinx_theme",
53-
"nbsphinx",
50+
"reno.sphinxext",
51+
"sphinx_design",
52+
"sphinx_remove_toctrees",
5453
]
5554

5655
templates_path = ["_templates"]
@@ -132,6 +131,11 @@
132131
} # enable segment analytics for qiskit.org/documentation
133132
html_static_path = ["_static"]
134133

134+
# This speeds up the docs build because it works around the Furo theme's slowdown from the left
135+
# sidebar when the site has lots of HTML pages. But, it results in a much worse user experience,
136+
# so we only use it in dev/CI builds.
137+
remove_from_toctrees = ["stubs/*"]
138+
135139
# ----------------------------------------------------------------------------------
136140
# Autodoc
137141
# ----------------------------------------------------------------------------------
@@ -225,6 +229,20 @@
225229
226230
"""
227231

232+
# ---------------------------------------------------------------------------------------
233+
# Prod changes
234+
# ---------------------------------------------------------------------------------------
235+
236+
if os.getenv("DOCS_PROD_BUILD"):
237+
# `viewcode` slows down docs build by about 14 minutes.
238+
extensions.append("sphinx.ext.viewcode")
239+
# Include all pages in the left sidebar in prod.
240+
remove_from_toctrees = []
241+
242+
243+
# ---------------------------------------------------------------------------------------
244+
# Custom extensions
245+
# ---------------------------------------------------------------------------------------
228246

229247
def add_versions_to_config(_app, config):
230248
"""Add a list of old documentation versions that should have links generated to them into the

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ ddt>=1.2.0,!=1.4.0,!=1.4.3
3434
Sphinx>=6.0
3535
qiskit-sphinx-theme~=1.14.0
3636
sphinx-design>=0.2.0
37+
sphinx-remove-toctrees
3738
nbsphinx~=0.9.2
3839
nbconvert~=7.7.1
3940
# TODO: switch to stable release when 4.1 is released

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ setenv =
7373
{[testenv]setenv}
7474
QISKIT_SUPPRESS_PACKAGING_WARNINGS=Y
7575
RUST_DEBUG=1 # Faster to compile.
76-
passenv = {[testenv]passenv}, QISKIT_DOCS_BUILD_TUTORIALS, QISKIT_CELL_TIMEOUT
76+
passenv = {[testenv]passenv}, QISKIT_DOCS_BUILD_TUTORIALS, QISKIT_CELL_TIMEOUT, DOCS_PROD_BUILD
7777
deps =
7878
setuptools_rust # This is work around for the bug of tox 3 (see #8606 for more details.)
7979
-r{toxinidir}/requirements-dev.txt
@@ -103,7 +103,7 @@ commands =
103103
[testenv:gettext]
104104
base = docs
105105
deps =
106-
{[testenv:docs]deps}
106+
{[testenv:docs]deps}
107107
sphinx-intl
108108
commands =
109109
sphinx-build -b gettext docs docs/_build/gettext {posargs}

0 commit comments

Comments
 (0)