8000 Merge pull request #23870 from rcomer/skip-gallery-builds · matplotlib/matplotlib@89d625e · GitHub
[go: up one dir, main page]

Skip to content

Commit 89d625e

Browse files
authored
Merge pull request #23870 from rcomer/skip-gallery-builds
Implement Sphinx-Gallery's `make html-noplot`
2 parents 3c615b5 + 1374e34 commit 89d625e

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

doc/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ clean:
2828
show:
2929
@python -c "import webbrowser; webbrowser.open_new_tab('file://$(shell pwd)/build/html/index.html')"
3030

31+
html-noplot:
32+
$(SPHINXBUILD) -D plot_gallery=0 -b html $(SOURCEDIR) $(BUILDDIR)/html $(SPHINXOPTS) $(O)
33+
@echo
34+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
35+
3136
# Catch-all target: route all unknown targets to Sphinx using the new
3237
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
3338
%: Makefile

doc/conf.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# All configuration values have a default value; values that are commented out
1212
# serve to show the default value.
1313

14+
import logging
1415
import os
1516
from pathlib import Path
1617
import shutil
@@ -188,6 +189,7 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
188189
'junit': '../test-results/sphinx-gallery/junit.xml' if CIRCLECI else '',
189190
'matplotlib_animations': True,
190191
'min_reported_time': 1,
192+
'plot_gallery': 'True', # sphinx-gallery/913
191193
'reference_url': {'matplotlib': None},
192194
'remove_config_comments': True,
193195
'reset_modules': (
@@ -200,6 +202,25 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
200202
'within_subsection_order': gallery_order.subsectionorder,
201203
}
202204

205+
if 'plot_gallery=0' in sys.argv:
206+
# Gallery images are not created. Suppress warnings triggered where other
207+
# parts of the documentation link to these images.
208+
209+
def gallery_image_warning_filter(record):
210+
msg = record.msg
211+
for gallery_dir in sphinx_gallery_conf['gallery_dirs']:
212+
if msg.startswith(f'image file not readable: {gallery_dir}'):
213+
return False
214+
215+
if msg == 'Could not obtain image size. :scale: option is ignored.':
216+
return False
217+
218+
return True
219+
220+
logger = logging.getLogger('sphinx')
221+
logger.addFilter(gallery_image_warning_filter)
222+
223+
203224
mathmpl_fontsize = 11.0
204225
mathmpl_srcset = ['2x']
205226

doc/devel/documenting_mpl.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ Other useful invocations include
6767

6868
.. code-block:: sh
6969
70+
# Build the html documentation, but skip generation of the gallery images to
71+
# save time.
72+
make html-noplot
73+
7074
# Delete built files. May help if you get errors about missing paths or
7175
# broken links.
7276
make clean
@@ -86,7 +90,6 @@ You can use the ``O`` variable to set additional options:
8690

8791
* ``make O=-j4 html`` runs a parallel build with 4 processes.
8892
* ``make O=-Dplot_formats=png:100 html`` saves figures in low resolution.
89-
* ``make O=-Dplot_gallery=0 html`` skips the gallery build.
9093

9194
Multiple options can be combined, e.g. ``make O='-j4 -Dplot_gallery=0'
9295
html``.

0 commit comments

Comments
 (0)
0