diff --git a/extensions/rapids_notebook_files.py b/extensions/rapids_notebook_files.py index 66d68ef8..0e426f7a 100644 --- a/extensions/rapids_notebook_files.py +++ b/extensions/rapids_notebook_files.py @@ -6,9 +6,12 @@ import tempfile from functools import partial +import jinja2 + def template_func(app, match): - return app.builder.templates.render_string(match.group(), app.config.rapids_version) + template = jinja2.Template(match.group()) + return template.render(app.config.rapids_version) def walk_files(app, dir, outdir): diff --git a/extensions/rapids_version_templating.py b/extensions/rapids_version_templating.py index 51c25152..9a9b43d3 100644 --- a/extensions/rapids_version_templating.py +++ b/extensions/rapids_version_templating.py @@ -2,6 +2,7 @@ from copy import deepcopy from typing import TYPE_CHECKING +import jinja2 from docutils import nodes if TYPE_CHECKING: @@ -73,9 +74,8 @@ def template_func(self, match: re.Match) -> str: Replace template strings like ``{{ rapids_version }}`` with real values like ``24.10``. """ - return self.app.builder.templates.render_string( - source=match.group(), context=self.app.config.rapids_version - ) + template = jinja2.Template(match.group()) + return template.render(self.app.config.rapids_version) def version_template( diff --git a/pyproject.toml b/pyproject.toml index 8417297b..a510b8d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,9 +14,10 @@ dependencies = [ "sphinx-autobuild>=2024.9.19", "sphinx-copybutton>=0.5.2", "sphinx-design>=0.6.1", + "sphinx-llm>=0.1.4", "sphinxcontrib-mermaid>=1.0.0", "python-frontmatter>=1.1.0", - "sphinx-reredirects" + "sphinx-reredirects", ] [tool.codespell] @@ -43,7 +44,7 @@ select = [ # pyupgrade "UP", # flake8-bugbear - "B" + "B", ] [tool.ruff.lint.per-file-ignores] diff --git a/source/conf.py b/source/conf.py index c7dccc1f..346b8998 100644 --- a/source/conf.py +++ b/source/conf.py @@ -87,6 +87,7 @@ "rapids_version_templating", "rapids_admonitions", "sphinx_reredirects", + "sphinx_llm.txt", ] myst_enable_extensions = ["colon_fence", "dollarmath"] diff --git a/uv.lock b/uv.lock index 9b481550..5b4c021e 100644 --- a/uv.lock +++ b/uv.lock @@ -1047,6 +1047,7 @@ dependencies = [ { name = "sphinx-autobuild" }, { name = "sphinx-copybutton" }, { name = "sphinx-design" }, + { name = "sphinx-llm" }, { name = "sphinx-reredirects" }, { name = "sphinxcontrib-mermaid" }, ] @@ -1065,6 +1066,7 @@ requires-dist = [ { name = "sphinx-autobuild", specifier = ">=2024.9.19" }, { name = "sphinx-copybutton", specifier = ">=0.5.2" }, { name = "sphinx-design", specifier = ">=0.6.1" }, + { name = "sphinx-llm", specifier = ">=0.1.4" }, { name = "sphinx-reredirects" }, { name = "sphinxcontrib-mermaid", specifier = ">=1.0.0" }, ] @@ -1259,6 +1261,33 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c6/43/65c0acbd8cc6f50195a3a1fc195c404988b15c67090e73c7a41a9f57d6bd/sphinx_design-0.6.1-py3-none-any.whl", hash = "sha256:b11f37db1a802a183d61b159d9a202314d4d2fe29c163437001324fe2f19549c", size = 2215338 }, ] +[[package]] +name = "sphinx-llm" +version = "0.1.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "sphinx" }, + { name = "sphinx-markdown-builder" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b7/b5/194aeb37dfb66334653db836ebf45cf9bdab01bcf1906ed1fe5c6e63f381/sphinx_llm-0.1.4.tar.gz", hash = "sha256:be0032b62809548edc0131ecffffaba9617ff8aaebf19bf5c2c1d18d1b7af557", size = 263386 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8d/8c/f71906df31fb9ef6473b6ba74378c7e4ce314d4e3071addbce05fd7e32e5/sphinx_llm-0.1.4-py3-none-any.whl", hash = "sha256:f19ffdd6fba561af6acbe4f335f396d7af6c92de5fa5ccf29fbb7f74c4b87985", size = 13799 }, +] + +[[package]] +name = "sphinx-markdown-builder" +version = "0.6.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "docutils" }, + { name = "sphinx" }, + { name = "tabulate" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d2/f6/7566ba54c8b9744192bdf19ba01e62e1bb6cb1e8526447cdb29feb7cac7c/sphinx_markdown_builder-0.6.9.tar.gz", hash = "sha256:e89dc1b9eb837da430c2c230011fad95a3dfab0345ad503a32e35a31d284a722", size = 22707 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/ee/02f9986d7818be2ccc5bce76d388e73f5a163f604f682d1ad69e6bc0df7c/sphinx_markdown_builder-0.6.9-py3-none-any.whl", hash = "sha256:35b555760c48d4a38fe4b27813cb5ca636bbd22d8ef0742ac6959043f8000840", size = 16717 }, +] + [[package]] name = "sphinx-reredirects" version = "0.1.6"