Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1374e34

Browse files
committed
filter warnings
1 parent 55b3991 commit 1374e34

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

doc/conf.py

Lines changed: 20 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
@@ -201,6 +202,25 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
201202
'within_subsection_order': gallery_order.subsectionorder,
202203
}
203204

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+
204224
mathmpl_fontsize = 11.0
205225
mathmpl_srcset = ['2x']
206226

0 commit comments

Comments
 (0)