Skip to content

Add Yearwheel grammar and tests for Langium#7459

Draft
Shahir-47 wants to merge 2 commits intomermaid-js:developfrom
Shahir-47:feature/7421_add-sunburst-diagram
Draft

Add Yearwheel grammar and tests for Langium#7459
Shahir-47 wants to merge 2 commits intomermaid-js:developfrom
Shahir-47:feature/7421_add-sunburst-diagram

Conversation

@Shahir-47
Copy link
Contributor

📑 Summary

Defines grammar and parser support for the new yearwheel diagram requested in #7421.

This PR adds:

  • a new yearwheel language in the parser (module, index, token builder)
  • parser registration so parse('yearwheel', ...) works
  • syntax support for:
    • diagram start: yearwheel
    • optional base date: baseDate now or baseDate YYYY-MM-DD
    • events: ID("label", "cron")
    • shared metadata: title, accTitle, accDescr
  • tests that confirm valid inputs parse and invalid inputs fail

This PR is only for grammar/parsing (no rendering changes yet).

Part of #7421

📏 Design Decisions

  • Used the same file structure and parser setup as other diagram types to keep maintenance simple.
  • Kept token handling minimal and consistent with existing diagram token builders.
  • Focused tests on real user syntax:
    • valid declaration, baseDate, events, and metadata
    • invalid declaration forms
    • invalid baseDate values and ordering
    • malformed event and accessibility lines
  • Limited scope to parser work so syntax can be reviewed and merged independently from rendering.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link

changeset-bot bot commented Mar 7, 2026

⚠️ No Changeset found

Latest commit: c977d30

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Mar 7, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit c977d30
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69abc6b9e505c00008a90ef5
😎 Deploy Preview https://deploy-preview-7459--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the Type: Enhancement New feature or request label Mar 7, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 7, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/@mermaid-js/examples@7459

mermaid

npm i https://pkg.pr.new/mermaid@7459

@mermaid-js/layout-elk

npm i https://pkg.pr.new/@mermaid-js/layout-elk@7459

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7459

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/@mermaid-js/mermaid-zenuml@7459

@mermaid-js/parser

npm i https://pkg.pr.new/@mermaid-js/parser@7459

@mermaid-js/tiny

npm i https://pkg.pr.new/@mermaid-js/tiny@7459

commit: 8e2ace4

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

❌ Patch coverage is 2.32558% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.53%. Comparing base (adcf722) to head (c977d30).

Files with missing lines Patch % Lines
packages/parser/src/language/yearwheel/module.ts 4.54% 21 Missing ⚠️
packages/parser/tests/test-util.ts 0.00% 9 Missing ⚠️
...ages/parser/src/language/yearwheel/tokenBuilder.ts 0.00% 5 Missing ⚠️
packages/parser/src/parse.ts 0.00% 5 Missing ⚠️
packages/parser/src/language/index.ts 0.00% 1 Missing ⚠️
packages/parser/src/language/yearwheel/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7459      +/-   ##
==========================================
- Coverage     3.53%   3.53%   -0.01%     
==========================================
  Files          490     494       +4     
  Lines        48968   49022      +54     
  Branches       766     769       +3     
==========================================
+ Hits          1733    1734       +1     
- Misses       47235   47288      +53     
Flag Coverage Δ
unit 3.53% <2.32%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/parser/src/language/index.ts 0.00% <0.00%> (ø)
packages/parser/src/language/yearwheel/index.ts 0.00% <0.00%> (ø)
...ages/parser/src/language/yearwheel/tokenBuilder.ts 0.00% <0.00%> (ø)
packages/parser/src/parse.ts 1.19% <0.00%> (-0.08%) ⬇️
packages/parser/tests/test-util.ts 1.35% <0.00%> (-0.19%) ⬇️
packages/parser/src/language/yearwheel/module.ts 4.54% <4.54%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link

argos-ci bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 1 removed, 1 failure Mar 7, 2026, 6:43 AM

@mrrudin
Copy link

mrrudin commented Mar 9, 2026

Happy to see that you picked this up!

Please tell me when there is something to test, and I will try to help out!

@Shahir-47
Copy link
Contributor Author

Shahir-47 commented Mar 9, 2026

Happy to see that you picked this up!

Please tell me when there is something to test, and I will try to help out!

Currently, I have just defined the grammar and parsing for this new diagram. I want the maintainers to confirm if the grammar and parsing is acceptable before I move on to the rendering step.

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

Labels

Type: Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants