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
autoclasstreedirective is overridden.
- click_extra.sphinx.mermaid.AUTOCLASSTREE_CLASS = 'autoclasstree'¶
HTML class of the container wrapping each
autoclasstreediagram.
- 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
_staticfolder.
- click_extra.sphinx.mermaid.override_class_diagrams(app)[source]¶
Register the zoom-free
autoclasstreeand its stylesheet onapp.Connected to
builder-inited, which fires once every extension is set up, whatever their order inextensions: the directive to override is then registered, andmermaid_d3_zoomholds the value ofconf.py. Inert withoutsphinxcontrib.mermaid, or withmermaid_d3_zoomoff. Only an HTML builder serves the stylesheet, so other builders get the directive alone.- Return type:
- 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 theirextensions.- Return type: