Skip to content

Commit

Permalink
Configure mystnb_config
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 10, 2024
1 parent c5cc011 commit 205e94b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import pathlib

from typing import Any

import param

param.parameterized.docstring_signature = False
Expand Down Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit 205e94b

Please sign in to comment.