Skip to content

Commit 630bbc3

Browse files
authored
Merge pull request #21227 from meeseeksmachine/auto-backport-of-pr-20730-on-v3.5.x
Backport PR #20730 on branch v3.5.x (DOC: Add a release mode tag)
2 parents 2bd9d05 + 25338c0 commit 630bbc3

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

.circleci/config.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ commands:
123123
command: |
124124
# Set epoch to date of latest tag.
125125
export SOURCE_DATE_EPOCH="$(git log -1 --format=%at $(git describe --abbrev=0))"
126-
# Include analytics only when deploying to devdocs.
127-
if [ "$CIRCLE_PROJECT_USERNAME" != "matplotlib" ] || \
128-
[ "$CIRCLE_BRANCH" != "master" ] || \
129-
[[ "$CIRCLE_PULL_REQUEST" == https://github.com/matplotlib/matplotlib/pull/* ]]; then
130-
export ANALYTICS=False
131-
else
132-
export ANALYTICS=True
126+
# Set release mode only when deploying to devdocs.
127+
if [ "$CIRCLE_PROJECT_USERNAME" = "matplotlib" ] && \
128+
[ "$CIRCLE_BRANCH" = "master" ] && \
129+
[ "$CIRCLE_PR_NUMBER" = "" ]; then
130+
export RELEASE_TAG='-t release'
133131
fi
134-
make html O="-T -Ainclude_analytics=$ANALYTICS"
132+
make html O="-T $RELEASE_TAG"
135133
rm -r build/html/_sources
136134
working_directory: doc
137135
- save_cache:

doc/conf.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
from datetime import datetime
2323
import time
2424

25+
# Release mode enables optimizations and other related options.
26+
is_release_build = tags.has('release') # noqa
27+
2528
# are we running circle CI?
2629
CIRCLECI = 'CIRCLECI' in os.environ
2730

@@ -88,6 +91,7 @@ def _check_dependencies():
8891
"matplotlib": 'matplotlib',
8992
"numpydoc": 'numpydoc',
9093
"PIL.Image": 'pillow',
94+
"pydata_sphinx_theme": 'pydata_sphinx_theme',
9195
"sphinx_copybutton": 'sphinx_copybutton',
9296
"sphinx_gallery": 'sphinx_gallery',
9397
"sphinxcontrib.inkscapeconverter": 'sphinxcontrib-svg2pdfconverter',
@@ -175,10 +179,10 @@ def _check_dependencies():
175179
'remove_config_comments': True,
176180
'min_reported_time': 1,
177181
'thumbnail_size': (320, 224),
178-
'compress_images': () if CIRCLECI else ('thumbnails', 'images'),
182+
# Compression is a significant effort that we skip for local and CI builds.
183+
'compress_images': ('thumbnails', 'images') if is_release_build else (),
179184
'matplotlib_animations': True,
180-
# 3.7 CI doc build should not use hidpi images during the testing phase
181-
'image_srcset': [] if sys.version_info[:2] == (3, 7) else ["2x"],
185+
'image_srcset': ["2x"],
182186
'junit': '../test-results/sphinx-gallery/junit.xml' if CIRCLECI else '',
183187
}
184188

@@ -293,7 +297,9 @@ def _check_dependencies():
293297
html_logo = "_static/logo2.svg"
294298
html_theme_options = {
295299
"logo_link": "index",
296-
"collapse_navigation": True if CIRCLECI else False,
300+
# collapse_navigation in pydata-sphinx-theme is slow, so skipped for local
301+
# and CI builds https://github.com/pydata/pydata-sphinx-theme/pull/386
302+
"collapse_navigation": not is_release_build,
297303
"icon_links": [
298304
{
299305
"name": "gitter",
@@ -319,7 +325,7 @@ def _check_dependencies():
319325
"show_prev_next": False,
320326
"navbar_center": ["mpl_nav_bar.html"],
321327
}
322-
include_analytics = False
328+
include_analytics = is_release_build
323329
if include_analytics:
324330
html_theme_options["google_analytics_id"] = "UA-55954603-1"
325331

@@ -538,13 +544,30 @@ def _check_dependencies():
538544
# graphviz_output_format = 'svg'
539545

540546

547+
def reduce_plot_formats(app):
548+
# Fox CI and local builds, we don't need all the default plot formats, so
549+
# only generate the directly useful one for the current builder.
550+
if app.builder.name == 'html':
551+
keep = 'png'
552+
elif app.builder.name == 'latex':
553+
keep = 'pdf'
554+
else:
555+
return
556+
app.config.plot_formats = [entry
557+
for entry in app.config.plot_formats
558+
if entry[0] == keep]
559+
560+
541561
def setup(app):
542562
if any(st in version for st in ('post', 'alpha', 'beta')):
543563
bld_type = 'dev'
544564
else:
545565
bld_type = 'rel'
546566
app.add_config_value('releaselevel', bld_type, 'env')
547567

568+
if not is_release_build:
569+
app.connect('builder-inited', reduce_plot_formats)
570+
548571
# -----------------------------------------------------------------------------
549572
# Source code links
550573
# -----------------------------------------------------------------------------

doc/devel/release_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ build the docs from the ``ver-doc`` branch. An easy way to arrange this is::
345345
pip install -r requirements/doc/doc-requirements.txt
346346
git checkout v2.0.0-doc
347347
git clean -xfd
348-
make -Cdoc O="-Ainclude_analytics=True -j$(nproc)" html latexpdf LATEXMKOPTS="-silent -f"
348+
make -Cdoc O="-t release -j$(nproc)" html latexpdf LATEXMKOPTS="-silent -f"
349349

350350
which will build both the html and pdf version of the documentation.
351351

0 commit comments

Comments
 (0)