Skip to content

Commit 6fbeca3

Browse files
committed
Update docs build - disable mermaid when using latex
1 parent 6d4dfa2 commit 6fbeca3

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

docs/conf.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Sphinx configuration."""
22

3+
from sphinx.application import Sphinx # type: ignore[import-not-found]
4+
35
project = "Odoo Data Flow"
46
author = "bosd"
57
copyright = "2025, bosd"
@@ -19,14 +21,32 @@
1921
#
2022
html_logo = "_static/icon.png"
2123

24+
2225
# The name of an image file (relative to this directory) to use as a favicon of
2326
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
2427
# pixels large.
2528
html_favicon = "_static/favicon.ico"
29+
html_static_path = ["_static"]
30+
31+
32+
def on_builder_inited(app: Sphinx) -> None:
33+
"""This function is connected to the 'builder-inited' event.
34+
35+
It removes the sphinx-mermaid extension if the builder is LaTeX, as it is
36+
not compatible with PDF output.
37+
"""
38+
if app.builder.name == "latex":
39+
if "sphinx_mermaid" in extensions:
40+
extensions.remove("sphinx_mermaid")
41+
42+
43+
# -- Setup function for builder-specific configuration ----------------------
44+
def setup(app: Sphinx) -> None:
45+
"""Called by Sphinx during the build process.
2646
27-
# -- Logic to disable mermaid for LaTeX output -----------------------------
28-
# The 'tags' object is automatically provided by Sphinx.
29-
tags = globals().get("tags")
30-
if tags and tags.has("latex"):
31-
# The sphinx-mermaid extension is not compatible with the LaTeX builder
32-
extensions.remove("sphinx_mermaid")
47+
We use this to disable extensions that are not compatible with certain
48+
builders, like LaTeX/PDF.
49+
"""
50+
# The sphinx-mermaid extension is not compatible with the LaTeX builder,
51+
# so we remove it from the extensions list only when building for PDF.
52+
app.connect("builder-inited", on_builder_inited)

0 commit comments

Comments
 (0)