Skip to content

ci: render every mermaid diagram type against labels that fight the syntax - #147

Merged
nao1215 merged 2 commits into
mainfrom
ci/render-every-mermaid-type
Aug 11, 2026
Merged

ci: render every mermaid diagram type against labels that fight the syntax#147
nao1215 merged 2 commits into
mainfrom
ci/render-every-mermaid-type

Conversation

@nao1215

@nao1215 nao1215 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Closes #125

Why

The render job already draws every committed diagram, but the diagrams it had to draw were the samples under doc/, which are documentation. That makes them weak tests: the labels a reader wants to see are exactly the ones that never break a renderer, so the job could only catch a defect that broke a plain label.

What

doc/edgecase/ adds one document per diagram type whose labels are the opposite, made of the punctuation that means something to mermaid: quotes, #, ;, brackets, braces, parentheses, <br/>, :, ,, *, -, |, %%, an emoji, and Japanese text.

One document per type rather than one holding all seventeen, so that a failure names the subpackage instead of a line number that moves whenever a label changes. The existing git ls-files '*.md' glob picks them up, and will pick up a new diagram type too, so nothing in the workflow needs editing when one is added.

What the measurements found

Each type carries the punctuation it can actually take today, measured rather than guessed: every character was put through every type on its own and rendered with mermaid-cli. That turned up defects in thirteen of the seventeen subpackages, from arch (which takes no punctuation at all, not even a space) to gantt (which loses the diagram on a colon).

Those are filed as #146 with the full matrix and reproduction steps. They are not fixed here on purpose: thirteen quoting fixes in one pull request would be unreviewable, and each changes generated output and needs its own regression test.

So the entries in supported are the honest current state, with the reason for each gap in a comment next to it. The rule that keeps the file from rotting is written there too: a fix that closes a gap widens the entry it is tested with, so the labels only ever get harder.

Verification

All seventeen documents render locally with the same checker CI uses. go generate ./... leaves a clean tree, go vet and golangci-lint are clean, and the magic numbers in the samples carry //nolint:mnd the way the other generators under doc/ do.

No library change

Generator and workflow comment only. No Go source file outside doc/ changed, and no existing generated document changed.

Summary by CodeRabbit

  • Documentation

    • Added comprehensive Mermaid diagram examples covering architecture, flowcharts, classes, sequences, charts, and other diagram types.
    • Added edge-case examples featuring punctuation, quotes, Unicode, emoji, HTML entities, and localized text.
    • Documented that generated diagrams are rendered and validated automatically.
  • Tests

    • Expanded continuous integration coverage to detect rendering and quoting issues across diverse diagram content.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a Go generator for Mermaid edge-case documents, commits fixtures for 17 diagram types, and documents their inclusion in the existing CI rendering workflow.

Changes

Mermaid edge-case rendering

Layer / File(s) Summary
Generator foundation
doc/edgecase/main.go
Defines supported punctuation, Unicode labels, title helpers, environment filters, document metadata, and Markdown file generation.
Diagram builders
doc/edgecase/main.go
Adds builders for architecture, block, class, ER, flowchart, Gantt, git graph, Kanban, mindmap, packet, pie, quadrant, requirement, sequence, state, user journey, and XY chart diagrams.
Committed fixtures and CI coverage
.github/workflows/doc_render.yml, doc/edgecase/*.md
Adds generated Mermaid fixtures containing punctuation, quoting, markup, emoji, and Japanese text. Comments document that the existing Markdown glob includes these fixtures and future diagrams.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Generator as doc/edgecase/main.go
  participant Fixtures as doc/edgecase/*.md
  participant Workflow as doc_render.yml
  participant Renderer as Mermaid rendering check
  Generator->>Fixtures: generate committed diagrams
  Workflow->>Fixtures: select Markdown files with existing glob
  Workflow->>Renderer: render diagram fixtures
Loading

Possibly related issues

  • nao1215/markdown issue 146: Adds the edge-case generator and fixtures that reproduce the Mermaid rendering failures described by the issue.

Possibly related PRs

  • nao1215/markdown#86: Introduces mindmap functionality exercised by the new mindmap fixture.
  • nao1215/markdown#87: Introduces the requirement diagram builder exercised by the new requirement fixture.
  • nao1215/markdown#88: Introduces the XY chart API exercised by the new XY chart fixture.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The pull request adds rendering coverage but leaves label-related rendering failures unresolved, contrary to the required fixes in [#125]. Add minimal quoting fixes, unit regression tests, and CHANGELOG entries for rendering failures exposed by the new edge-case fixtures.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the CI rendering coverage and syntax-sensitive Mermaid labels added by the pull request.
Out of Scope Changes check ✅ Passed The changes remain focused on adding Mermaid edge-case fixtures and generator coverage for the CI rendering objective in [#125].
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/render-every-mermaid-type

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
doc/edgecase/main.go (1)

62-107: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Fail when a diagram has no punctuation profile.

supported returns "" for an unknown key. This is also the intentional value for architecture. If a future diagrams entry has no profile, the generator writes plain labels and CI can pass without edge-case coverage.

Return an existence flag, or panic for a missing key. Keep the explicit empty architecture value valid.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@doc/edgecase/main.go` around lines 62 - 107, Update supported so it
distinguishes a missing diagram key from the intentional empty profile for
architecture; return an existence indicator alongside the profile or otherwise
panic when the key is absent, and make the caller validate that indicator before
generating labels. Preserve the explicit empty architecture value as valid.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/doc_render.yml:
- Around line 8-12: Update the render-input glob used by the workflow command to
include both .md and .mmd files, preserving the existing recursive discovery so
documentation, edgecase fixtures, and future diagrams are all rendered.

---

Nitpick comments:
In `@doc/edgecase/main.go`:
- Around line 62-107: Update supported so it distinguishes a missing diagram key
from the intentional empty profile for architecture; return an existence
indicator alongside the profile or otherwise panic when the key is absent, and
make the caller validate that indicator before generating labels. Preserve the
explicit empty architecture value as valid.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5456d89d-2ca0-483e-919d-e600bcb88638

📥 Commits

Reviewing files that changed from the base of the PR and between ce45d85 and 6e59252.

📒 Files selected for processing (19)
  • .github/workflows/doc_render.yml
  • doc/edgecase/architecture.md
  • doc/edgecase/block.md
  • doc/edgecase/class.md
  • doc/edgecase/er.md
  • doc/edgecase/flowchart.md
  • doc/edgecase/gantt.md
  • doc/edgecase/gitgraph.md
  • doc/edgecase/kanban.md
  • doc/edgecase/main.go
  • doc/edgecase/mindmap.md
  • doc/edgecase/packet.md
  • doc/edgecase/piechart.md
  • doc/edgecase/quadrant.md
  • doc/edgecase/requirement.md
  • doc/edgecase/sequence.md
  • doc/edgecase/state.md
  • doc/edgecase/userjourney.md
  • doc/edgecase/xychart.md

Comment thread .github/workflows/doc_render.yml Outdated
Comment on lines +8 to +12
# That covers two sets of diagrams. The samples under doc/ are documentation and
# read as such, which makes them weak tests: the labels a reader wants to see are
# the ones that never break a renderer. doc/edgecase/ holds one document per
# diagram type whose labels are the opposite, so a quoting defect fails here.
# Both are picked up by the glob below, and so is any diagram added later.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Include .mmd fixtures in the render input.

The command on Line 58 uses only *.md. It ignores .mmd files. The claim that future diagrams are automatically included is false for .mmd fixtures, and Issue #125 requires both extensions.

Proposed fix
- run: git ls-files -z '*.md' | node scripts/mermaid-check/check.mjs --stdin0
+ run: git ls-files -z -- '*.md' '*.mmd' | node scripts/mermaid-check/check.mjs --stdin0
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/doc_render.yml around lines 8 - 12, Update the
render-input glob used by the workflow command to include both .md and .mmd
files, preserving the existing recursive discovery so documentation, edgecase
fixtures, and future diagrams are all rendered.

…yntax

The render job already draws every committed diagram, but the diagrams it had
to draw were the samples under doc/, which are documentation. That makes them
weak tests: the labels a reader wants to see are exactly the ones that never
break a renderer, so the job could only catch a defect that broke a plain
label.

doc/edgecase/ adds one document per diagram type whose labels are the
opposite, made of the punctuation that means something to mermaid. One
document per type rather than one holding all of them, so a failure names the
subpackage instead of a line number that moves whenever a label changes. The
existing glob picks them up, and will pick up a new diagram type too.

Each type carries the punctuation it can actually take today, measured rather
than guessed: every character was put through every type on its own and
rendered. What is missing from an entry is a quoting gap, and each one is
recorded with its evidence in the generator and in the tracking issue. The
entries only ever get harder, so a fix that closes a gap widens the label it
is tested with.
The comment explaining the edge case documents was the only change to it, and
the glob already picks the documents up, so the workflow needs no edit at all.
Removing it also keeps this pull request mergeable without the workflow scope.
@nao1215
nao1215 force-pushed the ci/render-every-mermaid-type branch from 6e59252 to 39da422 Compare August 11, 2026 16:27
@github-actions

Copy link
Copy Markdown

Code Metrics Report

main (d75b165) #147 (7cbbb08) +/-
Coverage 95.9% 95.9% 0.0%
Test Execution Time 5s 10s +5s
Details
  |                     | main (d75b165) | #147 (7cbbb08) | +/-  |
  |---------------------|----------------|----------------|------|
  | Coverage            |          95.9% |          95.9% | 0.0% |
  |   Files             |             57 |             57 |    0 |
  |   Lines             |           2663 |           2663 |    0 |
  |   Covered           |           2555 |           2555 |    0 |
- | Test Execution Time |             5s |            10s |  +5s |

Reported by octocov

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: render every mermaid diagram type in CI, including edge-case labels

1 participant