Skip to content

Conversation

sidharthv96
Copy link
Member

@sidharthv96 sidharthv96 commented Apr 3, 2025

📑 Summary

Adds title and descriptions and examples to all diagrams, so that tools like mermaid.live, editor plugins, etc can use examples provided by diagram authors rather than maintaining a different copy, which will have to be updated manually whenever there is a new diagram in mermaid.

📏 Design Decisions

Examples is an array, to facilitate adding different ones if the author wishes to.

📋 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:.

Copy link

changeset-bot bot commented Apr 3, 2025

🦋 Changeset detected

Latest commit: 6deb476

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
mermaid Minor
@mermaid-js/examples Major

Not sure what this means? Click here to learn what changesets are.

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

Copy link

netlify bot commented Apr 3, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 3e6f680
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/67f5499f7dc740000859aef4
😎 Deploy Preview https://deploy-preview-6453--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 site configuration.

Copy link

pkg-pr-new bot commented Apr 3, 2025

Open in StackBlitz

@mermaid-js/examples

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

mermaid

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

@mermaid-js/layout-elk

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

@mermaid-js/mermaid-zenuml

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

@mermaid-js/parser

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

@mermaid-js/tiny

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

commit: 6deb476

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

Attention: Patch coverage is 8.21918% with 268 lines in your changes missing coverage. Please review.

Project coverage is 3.85%. Comparing base (1aa2870) to head (ed297ee).

Files with missing lines Patch % Lines
packages/examples/src/index.ts 2.17% 45 Missing ⚠️
packages/mermaid/src/diagram-api/loadDiagram.ts 0.00% 12 Missing ⚠️
packages/examples/src/examples/c4.ts 9.09% 10 Missing ⚠️
packages/examples/src/examples/architecture.ts 10.00% 9 Missing ⚠️
packages/examples/src/examples/block.ts 10.00% 9 Missing ⚠️
packages/examples/src/examples/class.ts 10.00% 9 Missing ⚠️
packages/examples/src/examples/er.ts 10.00% 9 Missing ⚠️
packages/examples/src/examples/flowchart.ts 10.00% 9 Missing ⚠️
packages/examples/src/examples/gantt.ts 10.00% 9 Missing ⚠️
packages/examples/src/examples/git.ts 10.00% 9 Missing ⚠️
... and 16 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #6453      +/-   ##
==========================================
+ Coverage     3.82%   3.85%   +0.02%     
==========================================
  Files          430     455      +25     
  Lines        44481   44772     +291     
  Branches       683     707      +24     
==========================================
+ Hits          1701    1725      +24     
- Misses       42780   43047     +267     
Flag Coverage Δ
unit 3.85% <8.21%> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
packages/examples/src/types.ts 100.00% <100.00%> (ø)
packages/mermaid/src/diagram-api/types.ts 100.00% <ø> (ø)
.build/common.ts 3.03% <0.00%> (-0.55%) ⬇️
packages/mermaid/src/mermaid.ts 0.42% <0.00%> (-0.02%) ⬇️
packages/examples/src/examples/architecture.ts 10.00% <10.00%> (ø)
packages/examples/src/examples/block.ts 10.00% <10.00%> (ø)
packages/examples/src/examples/class.ts 10.00% <10.00%> (ø)
packages/examples/src/examples/er.ts 10.00% <10.00%> (ø)
packages/examples/src/examples/flowchart.ts 10.00% <10.00%> (ø)
packages/examples/src/examples/gantt.ts 10.00% <10.00%> (ø)
... and 18 more

... 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.

Copy link

argos-ci bot commented Apr 3, 2025

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

Awaiting the start of a new Argos build…

@sidharthv96 sidharthv96 marked this pull request as ready for review April 8, 2025 06:17
…into sidv/examples

* 'sidv/examples' of https://github.com/mermaid-js/mermaid:
  chore: update E2E timings
  chore: Update permission for timings action
  chore: Fix PR action in e2e-timings
  chore: Fix branch in e2e-timings
@sidharthv96 sidharthv96 requested a review from Copilot April 8, 2025 11:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 38 out of 39 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • packages/examples/package.json: Language not supported

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@aloisklink aloisklink left a comment

Choose a reason for hiding this comment

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

There's a couple of things I think we could improve in this PR, but I don't think anything is blocking (maybe other than splitting the changeset into two files?).

Awesome work! I think this would be pretty helpful! The next cool thing would be if we could get these examples into the mermaid.js.org docs site as well!

Copy link
Member

Choose a reason for hiding this comment

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

suggestion(non-blocking): I think this is a good enough for a v1, but I would much rather store the examples as .mmd files instead (or even in .md files).

That way, us developers get to use syntax highlighting and Mermaid plugins in the IDE when using these examples.

Maybe a structure could work something like the following?

We have an index.ts file with the metadata, then a default.mmd file with the default diagram and all the other examples can have xxxx.mmd file names.

diff --git a/architecture/default.mmd b/architecture/default.mmd
new file mode 100644
index 000000000..8ea7afd46
--- /dev/null
+++ b/architecture/default.mmd
@@ -0,0 +1,14 @@
+---
+title: Basic System Architecture
+---
+architecture-beta
+    group api(cloud)[API]
+
+    service db(database)[Database] in api
+    service disk1(disk)[Storage] in api
+    service disk2(disk)[Storage] in api
+    service server(server)[Server] in api
+
+    db:L -- R:server
+    disk1:T -- B:server
+    disk2:T -- B:db
diff --git a/architecture/index.ts b/architecture/index.ts
new file mode 100644
index 000000000..5ab821ea9
--- /dev/null
+++ b/architecture/index.ts
@@ -0,0 +1,7 @@
+export default {
+  name: 'Architecture Diagram',
+  description: 'Visualize system architecture and components',
+  examples: [
+    // add some cool Vite script here to automatically load them from the `.mmd` file
+  ]
+};

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this!

Copy link
Member Author

Choose a reason for hiding this comment

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

Will check esbuild and vite loaders for markdown.

Copy link
Member

Choose a reason for hiding this comment

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

esbuild and vite loaders

You can just do a ?raw import in Vite to import the .mmd as a string. And it should bundlify into the exact same bundle.

Having it in a markdown file would be even cooler, but then you'd have to parse it to ensure it's exactly in the correct format, e.g.

# Diagram Name

Diagram Description goes Here

## Examples

### Example Name Here (maybe the default one is the first one?)

Optional Example Description Here

```mermaid
info
    %% My example here
```
### Second Example Name Here

Optional example description here

```mermaid
info
    %% My second example here
```

sidharthv96 and others added 4 commits April 17, 2025 21:26
Co-authored-by: Alois Klink <alois@aloisklink.com>
Co-authored-by: Alois Klink <alois@aloisklink.com>
Co-authored-by: Alois Klink <alois@aloisklink.com>
…into sidv/examples

* 'sidv/examples' of https://github.com/mermaid-js/mermaid:
  Update packages/examples/tsconfig.json
Copy link

netlify bot commented Apr 17, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit f43398d
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/680125046cb33700086589f2
😎 Deploy Preview https://deploy-preview-6453--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 site configuration.

Co-authored-by: Alois Klink <alois@aloisklink.com>
Copy link

netlify bot commented Apr 17, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 6deb476
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/686c22df89104a000854924d
😎 Deploy Preview https://deploy-preview-6453--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.

sidharthv96 and others added 15 commits April 17, 2025 21:32
Co-authored-by: Alois Klink <alois@aloisklink.com>
…into sidv/examples

* 'sidv/examples' of https://github.com/mermaid-js/mermaid: (110 commits)
  [autofix.ci] apply automated fixes
  chore: Change `mermaid` blocks to `mermaid-example` in docs
  chore: Remove duplicate `mermaid` blocks
  chore: update E2E timings
  [autofix.ci] apply automated fixes
  chore: Switch from `%%{init` to `config:`
  chore: Add details to e2e-timings
  chore: Ignore timeout domains
  [autofix.ci] apply automated fixes
  [autofix.ci] apply automated fixes
  Create neat-moose-compare.md
  chore: Add changeset
  updated tests
  modified description of showDataLabel in config schema and added it to docs
  fix(deps): update all major dependencies
  chore(deps): update peter-evans/create-pull-request digest to a7b20e1
  fix(deps): update dependency dompurify to ^3.2.5
  [autofix.ci] apply automated fixes
  Update integrations-community.md
  [autofix.ci] apply automated fixes
  ...
* develop: (189 commits)
  chore(deps): update dependency vite to v6.1.6 [security]
  corrected font size text
  docs(theme): fix table formatting by removing extra line between fontFamily and fontSize
  chore(deps): update dependency eslint-plugin-unicorn to v59
  chore(deps): update dependency vite to v6.1.5 [security]
  docs(theme): document fontFamily customization in themeVariables
  chore(deps): update eslint
  chore(deps): update peter-evans/create-pull-request digest to 3b1f4bf
  chore(deps): update dependency vite to v6.1.5 [security]
  Added the changeset
  Deleted unused code
  Deleted unused method
  chore: update E2E timings
  added changeset and unit test
  fix(sequenceDiagram): allow empty message after colon (Fixes #6518)
  chore(deps): update wei/curl digest to 012398a
  `layout-elk` package documentation misleading version
  [autofix.ci] apply automated fixes
  code review - wording and removals
  [autofix.ci] apply automated fixes
  ...
* develop: (198 commits)
  Version Packages
  docs: Update changeset
  update in changeset
  updated validaor and tests to use treemap
  Updated parser to use treemap
  chore: Fail build in CI on type errors
  Version Packages
  Updated phpbb url  to support 403 in lychee
  Updated lychee for working url phpbb.com
  resolve PR comment
  resolve PR comments
  chore: update E2E timings
  add changeset
  log warning when duplicate commit IDs are encountered
  Added updated chatgpt  plugin url and removed failing url
  Added classes and outernodes in imperativestate
  Updated code as per suggestions
  fixed unwanted vitepress from lockfile
  Updated as per suggestions
  Added step to install pnpm and echo statements for debugging.
  ...
Co-authored-by: Alois Klink <alois@aloisklink.com>
@sidharthv96 sidharthv96 merged commit d8bd4de into develop Jul 7, 2025
17 of 18 checks passed
@sidharthv96 sidharthv96 deleted the sidv/examples branch July 7, 2025 19:41
@github-actions github-actions bot mentioned this pull request Jul 7, 2025
@github-actions github-actions bot mentioned this pull request Jul 16, 2025
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.

2 participants