click_extra.sphinx.mermaid module

Let the page scroll over the class diagrams of autoclasstree.

With mermaid_d3_zoom = True, sphinxcontrib-mermaid attaches d3’s wheel and drag handlers to the <svg> of every diagram on a page. It has no per-diagram opt-out, and the zoom of its fullscreen viewer needs the same option. A class inheritance tree is often taller than the screen, and the wheel then zooms the diagram where the reader wants to scroll the page.

This module overrides the autoclasstree directive of sphinxcontrib-mermaid with a subclass that wraps each diagram in a container of the AUTOCLASSTREE_CLASS class. NO_ZOOM_CSS turns off the pointer events of the inline <svg> in that container: the events never reach it, d3’s handlers never fire, and the wheel scrolls the page. The fullscreen viewer clones the diagram outside the container, so its button and its zoom still work. The stylesheet is written into the build rather than packaged as a data file.

The module is inert on a project that does not load sphinxcontrib.mermaid, or that leaves mermaid_d3_zoom off.

click_extra.sphinx.mermaid.MERMAID_EXTENSION = 'sphinxcontrib.mermaid'

Module name of the extension whose autoclasstree directive is overridden.

click_extra.sphinx.mermaid.AUTOCLASSTREE_CLASS = 'autoclasstree'

HTML class of the container wrapping each autoclasstree diagram.

click_extra.sphinx.mermaid.NO_ZOOM_CSS = "/* With pointer events off, the inline <svg> never becomes an event target, so\n * d3's wheel and drag handlers never fire, and the wheel scrolls the page. The\n * fullscreen viewer clones the diagram outside the container, so its button\n * and its zoom keep working. */\n.autoclasstree pre.mermaid svg {\n  pointer-events: none;\n}\n"

Stylesheet keeping the pointer off the inline diagram of each container.

click_extra.sphinx.mermaid.STYLESHEET = 'click-extra-mermaid.css'

File name of the stylesheet, served from the _static folder.

click_extra.sphinx.mermaid.override_class_diagrams(app)[source]

Register the zoom-free autoclasstree and its stylesheet on app.

Connected to builder-inited, which fires once every extension is set up, whatever their order in extensions: the directive to override is then registered, and mermaid_d3_zoom holds the value of conf.py. Inert without sphinxcontrib.mermaid, or with mermaid_d3_zoom off. Only an HTML builder serves the stylesheet, so other builders get the directive alone.

Return type:

None

click_extra.sphinx.mermaid.setup(app)[source]

Register the class diagram override on app.

Called from click_extra.sphinx.setup() so projects only need to list "click_extra.sphinx" in their extensions.

Return type:

None