From cfdebd9f51311b561617c573fdd6d239b40c1e3d Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 29 Jul 2022 09:34:23 -0400 Subject: [PATCH 1/2] DOC: use custom module reset function to fix unit registration As of sg 0.11 the unit registry is reset for each example. This also forces the basic_unit module to be fully re-imported to re-register in any example that use it. --- doc/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index f79ee1c27a68..f0e295b8003e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -191,6 +191,11 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf, 'matplotlib_animations': True, 'image_srcset': ["2x"], 'junit': '../test-results/sphinx-gallery/junit.xml' if CIRCLECI else '', + 'reset_modules': ( + 'matplotlib', + # clear basic_units module to re-register with unit registry on import + lambda gallery_conf, fname: sys.modules.pop('basic_units', None) + ), } mathmpl_fontsize = 11.0 From 5ff9f55081f1713563f7a24d0e2ea885dcc9e16f Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 29 Jul 2022 09:45:25 -0400 Subject: [PATCH 2/2] MNT: sort keys in sphinx_gallery_cof --- doc/conf.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index f0e295b8003e..84c283cac6e8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -172,30 +172,28 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf, sphinx_gallery_conf = { + 'backreferences_dir': Path('api') / Path('_as_gen'), + # Compression is a significant effort that we skip for local and CI builds. + 'compress_images': ('thumbnails', 'images') if is_release_build else (), + 'doc_module': ('matplotlib', 'mpl_toolkits'), 'examples_dirs': ['../examples', '../tutorials', '../plot_types'], 'filename_pattern': '^((?!sgskip).)*$', 'gallery_dirs': ['gallery', 'tutorials', 'plot_types'], - 'doc_module': ('matplotlib', 'mpl_toolkits'), - 'reference_url': { - 'matplotlib': None, - }, - 'backreferences_dir': Path('api') / Path('_as_gen'), - 'subsection_order': gallery_order.sectionorder, - 'within_subsection_order': gallery_order.subsectionorder, - 'remove_config_comments': True, - 'min_reported_time': 1, - 'thumbnail_size': (320, 224), 'image_scrapers': (matplotlib_reduced_latex_scraper, ), - # Compression is a significant effort that we skip for local and CI builds. - 'compress_images': ('thumbnails', 'images') if is_release_build else (), - 'matplotlib_animations': True, 'image_srcset': ["2x"], 'junit': '../test-results/sphinx-gallery/junit.xml' if CIRCLECI else '', + 'matplotlib_animations': True, + 'min_reported_time': 1, + 'reference_url': {'matplotlib': None}, + 'remove_config_comments': True, 'reset_modules': ( 'matplotlib', # clear basic_units module to re-register with unit registry on import lambda gallery_conf, fname: sys.modules.pop('basic_units', None) ), + 'subsection_order': gallery_order.sectionorder, + 'thumbnail_size': (320, 224), + 'within_subsection_order': gallery_order.subsectionorder, } mathmpl_fontsize = 11.0