Skip to content

feat(docs): draw Mermaid diagrams on the docs site #4755

Open

Description

@dan-petty

Problem or Motivation

The docs site shows 14 Mermaid blocks on 5 pages as code, not as diagrams. In the repository, 24 of 40 Mermaid blocks use the old graph keyword (10 use flowchart). src/devops_cli/ai/diagram.py writes graph TD and graph LR.

Proposed Solution & Architectural Design

  • On the docs site: load the newest mermaid release that the docs site supports (12.3.0 of 2026-11-03 on 2026-11-11; no minimum release age) from jsDelivr with an SRI hash in docs/_layouts/default.html. Use the theme base with themeVariables that read the token CSS variables through getComputedStyle: background color-bg, primaryColor color-surface, primaryBorderColor color-border-strong, primaryTextColor color-fg, lineColor color-fg-muted, secondaryColor color-bg, tertiaryColor color-surface, fontFamily font-family-sans, fontSize 14px. Draw the diagrams again when the theme changes. Do not use the built-in Mermaid themes.
  • On github.com: no init directive, no classDef, no style and no hex in a block, because a fixed theme does not follow the GitHub dark mode. GitHub draws its own light and dark themes.
  • Change graph to flowchart in the 24 blocks and in ai/diagram.py. Use sentence-case labels, 15 nodes or fewer, and one direction for each diagram.
  • Add a pre-commit pygrep hook that rejects a Mermaid block that starts with graph.

Target Subsystem

Documentation (docs/_layouts/default.html, Markdown files) and src/devops_cli/ai/diagram.py.

Existing Tool Considered

Mermaid (MIT) has the base theme with themeVariables as its standard interface. pre-commit pygrep (in use) covers the keyword check. Custom code: about 20 lines of JavaScript for the init and the redraw. Cost (estimate): about 80,000 tokens and 0.5 day.

Acceptance Criteria

  • A headless browser check finds 14 rendered SVG diagrams on the 5 pages in both themes, and the node fill equals the color.surface token.
  • The hook finds 0 graph headers.
  • The ai/diagram.py tests expect flowchart.

Dependencies

Source: #4735

Alternatives check of 2026-11-29: in-use.
The repository already uses this tool.
Tool: zensical/zensical (https://github.com/zensical/zensical), MIT, last activity 2026-11-28, maintained.
Reason: Zensical, the generator the docs site already uses, renders Mermaid fences to SVG and redraws them on a theme change, so it covers the rendering and token-theme part. It does not migrate the 24 graph blocks, change ai/diagram.py, or add the pre-commit hook.

Covers:

  • Renders Mermaid fences as SVG on built pages
  • Redraws diagrams when the light/dark theme changes
  • Takes diagram colors from the theme token CSS variables
  • Already builds the docs site, so no new dependency

Lacks:

  • No migration of the 24 graph blocks to flowchart
  • No change to the graph TD/graph LR output of ai/diagram.py
  • No pre-commit pygrep hook that rejects graph headers
  • No test asserting node fill equals color.surface

Proposed design

Problem statement

The docs site shows 14 Mermaid blocks on 5 pages as code, not as diagrams. 24 of 40 Mermaid blocks in the repository use the old graph keyword. src/devops_cli/ai/diagram.py writes graph TD and graph LR. The change uses Zensical Mermaid support, migrates graph to flowchart, and adds a pre-commit check.

Acceptance criteria

Requirement: Docs site renders Mermaid diagrams

The docs site SHALL render each Mermaid code block as an SVG diagram in the light theme and in the dark theme.

Scenario: Headless browser check of the built docs site

  • WHEN uv run devops docs site build builds the site, and a headless browser loads each of the 5 pages that contain a Mermaid block in the light theme and in the dark theme.
  • THEN Each Mermaid block is an SVG element, and no Mermaid block remains as text.

Requirement: Diagram node fill follows the surface token

Each Mermaid diagram on the docs site SHALL take its node fill color from the color.surface token CSS variable.

Scenario: Node fill matches the surface token

  • WHEN uv run devops docs site build builds the site, and a headless browser reads the computed fill of a diagram node in the light theme.
  • THEN The computed fill equals the computed color of the color.surface CSS variable.

Requirement: Mermaid flowchart keyword migration

Every Mermaid flowchart block in tracked Markdown files SHALL start with the flowchart keyword and MUST NOT start with the graph keyword.

Scenario: Repository scan finds no graph headers

  • WHEN A test scans all tracked Markdown files for Mermaid block headers.
  • THEN The scan finds 0 Mermaid block headers that start with graph.

Requirement: Diagram generator emits flowchart

src/devops_cli/ai/diagram.py SHALL generate Mermaid code that starts with flowchart TD for the architecture diagram and flowchart LR for the threat diagram.

Scenario: Generator tests assert flowchart headers

  • WHEN The tests call generate_architecture_diagram and generate_threat_diagram.
  • THEN Each returned mermaid_code starts with the expected flowchart header and contains no graph header.

Requirement: Pre-commit hook rejects graph headers

The pre-commit configuration SHALL reject a Mermaid block whose first line starts with graph.

Scenario: Hook rejects a graph block

  • WHEN A test adds a temporary Markdown file with a Mermaid block that starts with graph TD and runs uv run pre-commit run pygrep-mermaid-graph --files <file>.
  • THEN The command exits with a nonzero status and names the offending file.

Existing Tool Considered

Zensical (zensical/zensical, MIT, maintained) has the in-use verdict in the Alternatives check of 2026-11-23 in the issue body. The check lists what Zensical covers and lacks. The proposal adds the keyword migration in the 24 Markdown blocks and src/devops_cli/ai/diagram.py, and the pre-commit pygrep hook, which the check lists as lacks.

Key questions

  • Which tool renders Mermaid diagrams on the docs site?: Use Zensical's built-in Mermaid fence. The Alternatives check of 2026-11-23 gives the in-use verdict for zensical/zensical. The proposal uses Zensical and adds the migration and hook. (best practice) [sources: docs/DESIGN.md:255]
    • Chosen: Zensical built-in Mermaid support. It is already in use. It renders the fences and redraws on a theme change. It reads the CSS variables.
    • Rejected: jsDelivr load with a custom init and redraw script. It duplicates Zensical. It needs an SRI pin. It adds code to keep and fix.
    • Rejected: Mermaid built-in themes. A fixed theme does not follow the token CSS variables or the GitHub dark mode.
  • Should diagram colors come from CSS variables or from Mermaid themeVariables in JavaScript?: Use the token CSS variables through the Zensical theme. Do not set themeVariables in JavaScript. (best practice) [sources: docs/DESIGN.md:255]
    • Chosen: Token CSS variables through the Zensical theme. The theme toggle updates the variables. Zensical redraws the diagrams. The colors follow both themes.
    • Rejected: Mermaid themeVariables in JavaScript. It adds a custom init script. It does not follow the theme CSS variables directly.
    • Rejected: Mermaid built-in themes. A fixed theme does not follow the docs site tokens.
  • Which Mermaid keyword should the repository use?: Use flowchart in all flowchart diagrams. Change the 24 graph blocks and src/devops_cli/ai/diagram.py to flowchart. (best practice) [sources: docs/DESIGN.md:255, ARCHITECTURE.md:12, src/devops_cli/ai/diagram.py]
    • Chosen: flowchart. The project design rule uses flowchart. It is the current Mermaid keyword. The hook can reject graph.
    • Rejected: graph. It is the old keyword. 24 blocks still use it. The hook rejects it.
  • How should the repository reject a Mermaid block that starts with graph?: Use the pre-commit pygrep hook that the repository already uses. Add a hook with id pygrep-mermaid-graph. Use a multiline pattern that matches a mermaid fence followed by graph. (best practice) [sources: docs/DESIGN.md:255]
    • Chosen: pre-commit pygrep hook. The repository already uses pre-commit pygrep. It needs no custom script.
    • Rejected: custom Python script. It adds code to build, keep, and fix.
    • Rejected: no hook. The migrated blocks can regress to graph.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4745

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/docs
    status/new
    value/medium
    effort/medium
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/docs. The (docs) scope of the title gives the scope.
    • Priority: P2-Medium. It improves the docs reading experience but does not block a release or fix a defect.
    • Value: Medium. Users see rendered diagrams instead of raw code, which makes the docs easier to follow.
    • Effort: Medium. It needs JavaScript init, CSS token wiring, 24 block edits, a Python file change, and a pre-commit hook.
    • Related: feat(docs): documentation syntax, code fence nesting, and mermaid link validator #227, which asks for a different change. Both items work on Mermaid blocks in the docs, but #227 adds a lint and validation CLI while the candidate renders the diagrams and migrates the keyword.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Owner direction of 2026-11-11:

    not sure about the "at least two weeks old" rule, sometimes security updates and bugfixes need to be used within minues of their release, as long as the tooling supports that version, it is fine to update

    New rule: no minimum release age for dependencies, images, charts or tools. Pin the newest release that fixes the known security and bug issues and that the surrounding tools support (the tests pass).

    Body changes: the docs site loads the newest mermaid release that it supports, 12.3.0 (2026-11-03) on 2026-11-11, not 12.2.0.

  6. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Scope change from tracker #5151 (2026-11-12).

    #5152 moves the docs site to Zensical 0.1.1 with the Mermaid custom fence of pymdownx.superfences. Zensical loads Mermaid itself, draws the diagrams again on a theme change, and takes the fonts and colors from the theme CSS variables. A trial build of 2026-11-12 drew the Mermaid blocks on 6 pages with no extra script. When #5152 merges first, this item changes as follows:

    • Drop the jsDelivr load of mermaid in docs/_layouts/default.html (the file goes away) and the custom init and redraw script.
    • Set the diagram colors through the theme CSS variables of feat(docs): build the docs site theme from the design tokens #4745, not through themeVariables in JavaScript.
    • Keep: the change from graph to flowchart in the 24 blocks and in src/devops_cli/ai/diagram.py, the label rules, and the pre-commit pygrep hook.
    • The acceptance check of the node fill reads the Zensical pages.
  7. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found Zensical (zensical/zensical, MIT, maintained), whose built-in Mermaid support through the pymdownx.superfences custom fence initializes Mermaid automatically, redraws diagrams on a theme change and takes the fonts and colors from the theme CSS variables — exactly the docs-site rendering that this issue plans to build with a jsDelivr load and ~20 lines of custom init/redraw JavaScript (the reply says that load and script are dropped). It does not do the rest of the issue: the graph→flowchart migration in the 24 blocks and ai/diagram.py, or the pre-commit pygrep hook, so it covers only a part.

    The repository already uses this tool.

    Tool: zensical/zensical (https://github.com/zensical/zensical)

    • License: MIT
    • Last activity: 2026-11-13
    • Maintained: yes

    Covers:

    • Renders Mermaid code blocks on the docs site natively, with no extra script
    • Works with instant navigation and draws the diagrams again on a light/dark theme change
    • Takes diagram fonts and colors from the theme CSS variables, and allows Mermaid frontmatter (base theme, themeVariables) for custom colors

    Lacks:

    • Does not change graph to flowchart in the 24 blocks or in src/devops_cli/ai/diagram.py
    • Does not add the pre-commit pygrep hook that rejects a Mermaid block starting with graph

    Tools considered:

    Searches run:

    • Zensical documentation generator Mermaid superfences, results: 5
    • Mermaid base theme themeVariables documentation, results: 5
    • Zensical Mermaid custom fence pymdownx, results: 5
    • Zensical static site generator, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  8. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at e5dfddb while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  9. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/docssource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions