From 205e94b3783ed70d57b40c09f6d39bdb5dc4feb1 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 10 Sep 2024 17:25:49 +0200 Subject: [PATCH] Configure mystnb_config --- doc/conf.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index cccdcfaf74..76681d882c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -2,6 +2,8 @@ import os import pathlib +from typing import Any + import param param.parameterized.docstring_signature = False @@ -270,6 +272,26 @@ def update_versions(app, docname, source): source[0] = source[0].replace(old, new) +def setup_mystnb(app): + from myst_nb.core.config import NbParserConfig + from myst_nb.sphinx_ext import create_mystnb_config + + _UNSET = "--unset--" + for name, default, field in NbParserConfig().as_triple(): + if not field.metadata.get("sphinx_exclude"): + # TODO add types? + app.add_config_value(f"nb_{name}", default, "env", Any) # type: ignore[arg-type] + if "legacy_name" in field.metadata: + app.add_config_value( + f"{field.metadata['legacy_name']}", + _UNSET, + "env", + Any, # type: ignore[arg-type] + ) + app.add_config_value("nb_render_priority", _UNSET, "env", Any) # type: ignore[arg-type] + create_mystnb_config(app) + + def setup(app) -> None: try: from nbsite.paramdoc import param_formatter, param_skip @@ -278,6 +300,8 @@ def setup(app) -> None: except ImportError: print('no param_formatter (no param?)') + app.connect('builder-inited', setup_mystnb) + app.connect('source-read', update_versions) nbbuild.setup(app) app.add_config_value('grid_item_link_domain', '', 'html')