|
12 | 12 |
|
13 | 13 | import datetime
|
14 | 14 | import importlib.metadata
|
| 15 | +from pathlib import Path |
15 | 16 |
|
16 | 17 | import jinja2.filters
|
17 | 18 | import numpy as np
|
|
23 | 24 | except TypeError:
|
24 | 25 | pass
|
25 | 26 |
|
| 27 | +from sphinx.application import Sphinx |
| 28 | + |
| 29 | +HERE = Path(__file__).parent |
| 30 | + |
| 31 | + |
| 32 | +def convert_md_to_ipynb(app: Sphinx, *args, **kwargs): |
| 33 | + import subprocess |
| 34 | + import sys |
| 35 | + print("Converting Markdown files to IPyNB...") |
| 36 | + subprocess.check_call( |
| 37 | + [ |
| 38 | + sys.executable, |
| 39 | + "-m", |
| 40 | + "jupytext", |
| 41 | + "--to", |
| 42 | + "ipynb", |
| 43 | + f"{HERE / "regression" / "*.md"}", |
| 44 | + ] |
| 45 | + ) |
| 46 | + |
| 47 | + |
| 48 | +def setup(app): |
| 49 | + app.connect("builder-inited", convert_md_to_ipynb) |
26 | 50 |
|
27 | 51 | # If extensions (or modules to document with autodoc) are in another directory,
|
28 | 52 | # add these directories to sys.path here. If the directory is relative to the
|
|
53 | 77 | templates_path = ['_templates']
|
54 | 78 |
|
55 | 79 | # The suffix of source filenames.
|
56 |
| -source_suffix = '.rst' |
| 80 | +source_suffix = { |
| 81 | + '.rst': 'restructuredtext', |
| 82 | + '.md': 'myst-nb', |
| 83 | + 'ipynb': None, # do not parse IPyNB files |
| 84 | +} |
57 | 85 |
|
58 | 86 | # The encoding of source files.
|
59 | 87 | source_encoding = 'utf-8'
|
|
276 | 304 |
|
277 | 305 | # List of patterns, relative to source directory, that match files and
|
278 | 306 | # directories to ignore when looking for source files.
|
279 |
| -exclude_patterns = ['substitutions.rst', ] |
| 307 | +exclude_patterns = [ |
| 308 | + 'substitutions.rst', |
| 309 | + 'regression/*.ipynb' # exclude IPyNB files from the build |
| 310 | +] |
280 | 311 |
|
281 | 312 | # numpydoc_show_class_members = False
|
282 | 313 | numpydoc_class_members_toctree = False
|
|
297 | 328 |
|
298 | 329 | # -- Options for JupyterLite -------------------------------------------------
|
299 | 330 |
|
| 331 | +jupyterlite_silence = False |
| 332 | + |
300 | 333 | global_enable_try_examples = True
|
301 | 334 | try_examples_global_button_text = "Try it in your browser!"
|
302 | 335 | try_examples_global_warning_text = (
|
|
0 commit comments