|
17 | 17 | # add these directories to sys.path here. If the directory is relative to the
|
18 | 18 | # documentation root, use os.path.abspath to make it absolute, like shown here.
|
19 | 19 | #
|
20 |
| -# import os |
| 20 | +import os |
21 | 21 | # import sys
|
22 | 22 | # sys.path.insert(0, os.path.abspath('.'))
|
| 23 | +from pathlib import Path |
23 | 24 |
|
| 25 | +# are we running circle CI? |
| 26 | +CIRCLECI = 'CIRCLECI' in os.environ |
24 | 27 |
|
25 | 28 | # -- General configuration ------------------------------------------------
|
26 | 29 |
|
|
43 | 46 | 'matplotlib.sphinxext.plot_directive',
|
44 | 47 | 'numpydoc',
|
45 | 48 | 'sphinx_copybutton',
|
| 49 | + 'sphinx_gallery.gen_gallery', |
46 | 50 | ]
|
47 | 51 |
|
48 | 52 | # Configuration options for plot_directive. See:
|
49 | 53 | # https://github.com/matplotlib/matplotlib/blob/f3ed922d935751e08494e5fb5311d3050a3b637b/lib/matplotlib/sphinxext/plot_directive.py#L81
|
50 | 54 | plot_html_show_source_link = False
|
51 | 55 | plot_html_show_formats = False
|
52 | 56 |
|
| 57 | + |
53 | 58 | # Generate the API documentation when building
|
54 | 59 | autosummary_generate = True
|
55 | 60 | numpydoc_show_class_members = False
|
56 | 61 |
|
| 62 | +is_release_build = False |
| 63 | + |
| 64 | +# Sphinx gallery configuration |
| 65 | + |
| 66 | +def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf, |
| 67 | + **kwargs): |
| 68 | + """ |
| 69 | + Reduce srcset when creating a PDF. |
| 70 | +
|
| 71 | + Because sphinx-gallery runs *very* early, we cannot modify this even in the |
| 72 | + earliest builder-inited signal. Thus we do it at scraping time. |
| 73 | + """ |
| 74 | + from sphinx_gallery.scrapers import matplotlib_scraper |
| 75 | + |
| 76 | + if gallery_conf['builder_name'] == 'latex': |
| 77 | + gallery_conf['image_srcset'] = [] |
| 78 | + return matplotlib_scraper(block, block_vars, gallery_conf, **kwargs) |
| 79 | + |
| 80 | + |
| 81 | +sphinx_gallery_conf = { |
| 82 | + 'examples_dirs': ['../../examples', ], |
| 83 | + 'filename_pattern': '^((?!sgskip).)*$', |
| 84 | + 'gallery_dirs': ['gallery'], |
| 85 | + 'doc_module': ('data_prototype',), |
| 86 | + 'reference_url': { |
| 87 | + 'matplotlib': None, |
| 88 | + }, |
| 89 | + 'backreferences_dir': Path('api') / Path('_as_gen'), |
| 90 | + 'remove_config_comments': True, |
| 91 | + 'min_reported_time': 1, |
| 92 | + 'thumbnail_size': (320, 224), |
| 93 | + 'image_scrapers': (matplotlib_reduced_latex_scraper, ), |
| 94 | + # Compression is a significant effort that we skip for local and CI builds. |
| 95 | + 'compress_images': ('thumbnails', 'images') if is_release_build else (), |
| 96 | + 'matplotlib_animations': True, |
| 97 | + 'image_srcset': ["2x"], |
| 98 | + 'junit': '../test-results/sphinx-gallery/junit.xml' if CIRCLECI else '', |
| 99 | +} |
| 100 | + |
| 101 | +mathmpl_fontsize = 11.0 |
| 102 | +mathmpl_srcset = ['2x'] |
| 103 | + |
57 | 104 | # Add any paths that contain templates here, relative to this directory.
|
58 | 105 | templates_path = ['_templates']
|
59 | 106 |
|
|
105 | 152 | # The theme to use for HTML and HTML Help pages. See the documentation for
|
106 | 153 | # a list of builtin themes.
|
107 | 154 | #
|
108 |
| -html_theme = 'sphinx_rtd_theme' |
109 |
| -import sphinx_rtd_theme |
110 |
| -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] |
| 155 | +html_theme = "mpl_sphinx_theme" |
| 156 | + |
111 | 157 |
|
112 | 158 | # Theme options are theme-specific and customize the look and feel of a theme
|
113 | 159 | # further. For a list of options available for each theme, see the
|
|
0 commit comments