22
22
from datetime import datetime
23
23
import time
24
24
25
+ # Release mode enables optimizations and other related options.
26
+ is_release_build = tags .has ('release' ) # noqa
27
+
25
28
# are we running circle CI?
26
29
CIRCLECI = 'CIRCLECI' in os .environ
27
30
@@ -88,6 +91,7 @@ def _check_dependencies():
88
91
"matplotlib" : 'matplotlib' ,
89
92
"numpydoc" : 'numpydoc' ,
90
93
"PIL.Image" : 'pillow' ,
94
+ "pydata_sphinx_theme" : 'pydata_sphinx_theme' ,
91
95
"sphinx_copybutton" : 'sphinx_copybutton' ,
92
96
"sphinx_gallery" : 'sphinx_gallery' ,
93
97
"sphinxcontrib.inkscapeconverter" : 'sphinxcontrib-svg2pdfconverter' ,
@@ -175,10 +179,10 @@ def _check_dependencies():
175
179
'remove_config_comments' : True ,
176
180
'min_reported_time' : 1 ,
177
181
'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 (),
179
184
'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" ],
182
186
'junit' : '../test-results/sphinx-gallery/junit.xml' if CIRCLECI else '' ,
183
187
}
184
188
@@ -293,7 +297,9 @@ def _check_dependencies():
293
297
html_logo = "_static/logo2.svg"
294
298
html_theme_options = {
295
299
"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 ,
297
303
"icon_links" : [
298
304
{
299
305
"name" : "gitter" ,
@@ -319,7 +325,7 @@ def _check_dependencies():
319
325
"show_prev_next" : False ,
320
326
"navbar_center" : ["mpl_nav_bar.html" ],
321
327
}
322
- include_analytics = False
328
+ include_analytics = is_release_build
323
329
if include_analytics :
324
330
html_theme_options ["google_analytics_id" ] = "UA-55954603-1"
325
331
@@ -538,13 +544,30 @@ def _check_dependencies():
538
544
# graphviz_output_format = 'svg'
539
545
540
546
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
+
541
561
def setup (app ):
542
562
if any (st in version for st in ('post' , 'alpha' , 'beta' )):
543
563
bld_type = 'dev'
544
564
else :
545
565
bld_type = 'rel'
546
566
app .add_config_value ('releaselevel' , bld_type , 'env' )
547
567
568
+ if not is_release_build :
569
+ app .connect ('builder-inited' , reduce_plot_formats )
570
+
548
571
# -----------------------------------------------------------------------------
549
572
# Source code links
550
573
# -----------------------------------------------------------------------------
0 commit comments