这是indexloc提供的服务,不要输入任何密码
Skip to content

Improve documentation mermaid_init_js #172

@chenkins

Description

@chenkins

Default value is not as documented

Code says:

_MERMAID_INIT_JS_DEFAULT = "mermaid.initialize({startOnLoad:false});

wheras
Documentation says:

``mermaid_init_js``

  Mermaid initialization code. The Default initialization is set to

    mermaid.initialize({ startOnLoad: true})

Behaviour not as documented
Furthermore,

not setting mermaid_init_js generates (from markdown)

<script type="module">import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11.2.0/dist/mermaid.esm.min.mjs";import elkLayouts from "https://cdn.jsdelivr.net/npm/@mermaid-js/layout-elk@0.1.4/dist/mermaid-layout-elk.esm.min.mjs";mermaid.registerLayoutLoaders(elkLayouts);mermaid.initialize({startOnLoad:false});</script>

However, setting mermaid_init_js to

mermaid.initialize({startOnLoad:false});

only generates

<script type="module">mermaid.initialize({startOnLoad:false});
</script>

From the documentation, I would have expected that it does not side-affect loading the elkLayouts, only changing what is declared as "default intialization". More precisely, I would have expected

@pytest.mark.sphinx(
    "html", testroot="markdown", confoverrides={"mermaid_init_js": "custom script;"}
)
def test_mermaid_init_js_markdown(index):
    assert "mermaid.run()" in index
    assert '<script type="module">import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11.2.0/dist/mermaid.esm.min.mjs";import elkLayouts from "https://cdn.jsdelivr.net/npm/@mermaid-js/layout-elk@0.1.4/dist/mermaid-layout-elk.esm.min.mjs";mermaid.registerLayoutLoaders(elkLayouts);custom script;</script>' not in index
    assert '<script type="module">custom script;</script>' in index

not to fail. See test_mermaid_init_js

Related #170 #78.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions