From 65c93807d8204f81c44f47a8bb736f734f0a53a6 Mon Sep 17 00:00:00 2001 From: "Nicko J. Ruddock" Date: Fri, 11 Aug 2023 15:23:16 +0100 Subject: [PATCH 01/31] Fix Twitter fontawesome class in flowchart.md --- packages/mermaid/src/docs/syntax/flowchart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/docs/syntax/flowchart.md b/packages/mermaid/src/docs/syntax/flowchart.md index 56cad19a0..7418b96e0 100644 --- a/packages/mermaid/src/docs/syntax/flowchart.md +++ b/packages/mermaid/src/docs/syntax/flowchart.md @@ -728,7 +728,7 @@ The icons are accessed via the syntax fa:#icon class name#. ```mermaid-example flowchart TD - B["fab:fa-twitter for peace"] + B["fa:fa-twitter for peace"] B-->C[fa:fa-ban forbidden] B-->D(fa:fa-spinner) B-->E(A fa:fa-camera-retro perhaps?) From 341130856f04be7266d9385c9546c3beeacb79f8 Mon Sep 17 00:00:00 2001 From: Nikolay Rozhkov Date: Thu, 17 Aug 2023 23:52:56 +0300 Subject: [PATCH 02/31] Split development documentation in several separate pages, fixes for the sidebar menu United similar sections at the intro page Fix spelling Update docs --- README.md | 2 +- README.zh-CN.md | 2 +- cSpell.json | 1 + docs/community/code.md | 176 ++++++++ docs/community/development.md | 399 +++--------------- docs/community/docker-development.md | 109 +++++ docs/community/documentation.md | 106 +++++ docs/community/n00b-overview.md | 74 ---- docs/community/questionsAndSuggestions.md | 28 ++ docs/intro/index.md | 35 +- docs/intro/n00b-syntaxReference.md | 4 +- .../mermaid/src/docs/.vitepress/config.ts | 52 +-- .../src/docs/.vitepress/theme/redirect.ts | 1 + packages/mermaid/src/docs/community/code.md | 165 ++++++++ .../mermaid/src/docs/community/development.md | 387 +++-------------- .../src/docs/community/docker-development.md | 104 +++++ .../src/docs/community/documentation.md | 93 ++++ .../src/docs/community/n00b-overview.md | 68 --- .../docs/community/questionsAndSuggestions.md | 22 + packages/mermaid/src/docs/intro/index.md | 35 +- .../src/docs/intro/n00b-syntaxReference.md | 4 +- run | 3 + 22 files changed, 953 insertions(+), 917 deletions(-) create mode 100644 docs/community/code.md create mode 100644 docs/community/docker-development.md create mode 100644 docs/community/documentation.md delete mode 100644 docs/community/n00b-overview.md create mode 100644 docs/community/questionsAndSuggestions.md create mode 100644 packages/mermaid/src/docs/community/code.md create mode 100644 packages/mermaid/src/docs/community/docker-development.md create mode 100644 packages/mermaid/src/docs/community/documentation.md delete mode 100644 packages/mermaid/src/docs/community/n00b-overview.md create mode 100644 packages/mermaid/src/docs/community/questionsAndSuggestions.md diff --git a/README.md b/README.md index bdffbe175..0f47ceca2 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Use Mermaid with your favorite applications, check out the list of [Integrations You can also use Mermaid within [GitHub](https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/) as well many of your other favorite applications—check out the list of [Integrations and Usages of Mermaid](./docs/ecosystem/integrations.md). -For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](./docs/community/n00b-overview.md), [Usage](./docs/config/usage.md) and [Tutorials](./docs/config/Tutorials.md). +For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](./docs/intro/n00b-gettingStarted.md), [Usage](./docs/config/usage.md) and [Tutorials](./docs/config/Tutorials.md). In our release process we rely heavily on visual regression tests using [applitools](https://applitools.com/). Applitools is a great service which has been easy to use and integrate with our tests. diff --git a/README.zh-CN.md b/README.zh-CN.md index 9a2e797be..0cc05906e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -55,7 +55,7 @@ Mermaid 通过允许用户创建便于修改的图表来解决这一难题,它 Mermaid 甚至能让非程序员也能通过 [Mermaid Live Editor](https://mermaid.live/) 轻松创建详细的图表。
你可以访问 [教程](./docs/config/Tutorials.md) 来查看 Live Editor 的视频教程,也可以查看 [Mermaid 的集成和使用](./docs/ecosystem/integrations.md) 这个清单来检查你的文档工具是否已经集成了 Mermaid 支持。 -如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 [入门指引](./docs/community/n00b-overview.md), [用法](./docs/config/usage.md) 和 [教程](./docs/config/Tutorials.md). +如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 [入门指引](./docs/intro/n00b-gettingStarted.md), [用法](./docs/config/usage.md) 和 [教程](./docs/config/Tutorials.md). diff --git a/cSpell.json b/cSpell.json index af7a9ca46..055c4b20b 100644 --- a/cSpell.json +++ b/cSpell.json @@ -91,6 +91,7 @@ "nextra", "nikolay", "nirname", + "npmjs", "orlandoni", "pathe", "pbrolin", diff --git a/docs/community/code.md b/docs/community/code.md new file mode 100644 index 000000000..7f4b1e105 --- /dev/null +++ b/docs/community/code.md @@ -0,0 +1,176 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/code.md](../../packages/mermaid/src/docs/community/code.md). + +# Contributing Code + +The basic steps for contributing code are: + +```mermaid-example +graph LR + git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] +``` + +```mermaid +graph LR + git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] +``` + +1. **Create** and checkout a git branch and work on your code in the branch +2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.) +3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_ +4. **Submit** your code as a _pull request_. +5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat. + +## 1. Checkout a git branch + +Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. + +Development is done in the `develop` branch. + +Once development is done we create a `release/vX.X.X` branch from `develop` for testing. + +Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch. + +**All new work should be based on the `develop` branch.** + +**When you are ready to do work, always, ALWAYS:** + +1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it) +2. Check out the `develop` branch +3. Create a new branch for your work. Please name the branch following our naming convention below. + +We use the follow naming convention for branches: + +```txt + [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] +``` + +You can always check current [configuration of labelling and branch prefixes](https://github.com/mermaid-js/mermaid/blob/develop/.github/pr-labeler.yml) + +- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs') +- followed by a _slash_ (which helps to group like types together in many git tools) +- followed by the **issue number** +- followed by an _underscore_ ('\_') +- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces) + +If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together. + +**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams** + +`feature/2945_state-diagram-new-arrow-florbs` + +**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types** +`bug/1123_fix_random_ugly_red_text` + +## 2. Write Tests + +Tests ensure that each function, module, or part of code does what it says it will do. This is critically +important when other changes are made to ensure that existing code is not broken (no regression). + +Just as important, the tests act as _specifications:_ they specify what the code does (or should do). +Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why. + +If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again. +(If there had been a test for the situation, the bug never would have happened in the first place.) +You may need to change existing tests if they were inaccurate. + +If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests. + +### Unit Tests + +Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run. + +Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.) + +We use [Vitest](https://vitest.dev) to run unit tests. + +You can use the following command to run the unit tests: + +```sh +pnpm test +``` + +When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command: + +```sh +pnpm test:watch +``` + +### Integration/End-to-End (e2e) tests + +These test the rendering and visual appearance of the diagrams. +This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks! + +To start working with the e2e tests: + +1. Run `pnpm dev` to start the dev server +2. Start **Cypress** by running `pnpm cypress:open`. + +The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress. + +When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs. + +This is what a rendering test looks like: + +```js +it('should render forks and joins', () => { + imgSnapshotTest( + ` + stateDiagram + state fork_state <<fork>> + [*] --> fork_state + fork_state --> State2 + fork_state --> State3 + + state join_state <<join>> + State2 --> join_state + State3 --> join_state + join_state --> State4 + State4 --> [*] + `, + { logLevel: 0 } + ); + cy.get('svg'); +}); +``` + +**_\[TODO - running the tests against what is expected in development. ]_** + +**_\[TODO - how to generate new screenshots]_** +.... + +## 3. Update Documentation + +If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken. +Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. + +The documentation has to be updated to users know that things have changed and added! +If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. + +eg: `# Feature Name (v+)` + +We know it can sometimes be hard to code _and_ write user documentation. + +Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section. + +Create another issue specifically for the documentation.\ +You will need to help with the PR, but definitely ask for help if you feel stuck. +When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work! + +When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!) + +## 4. Submit your pull request + +**\[TODO - PR titles should start with (fix | feat | ....)]** + +We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs. + +- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed. +- The maintainers will request a review from knsv, if necessary. +- Once the PR is approved, the maintainers will merge the PR into the `develop` branch. +- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process. + +**Reminder: Pull Requests should be submitted to the develop branch.** diff --git a/docs/community/development.md b/docs/community/development.md index f8c8b0638..65ee18660 100644 --- a/docs/community/development.md +++ b/docs/community/development.md @@ -6,15 +6,9 @@ # Contributing to Mermaid -## Contents - -- [Technical Requirements and Setup](#technical-requirements-and-setup) -- [Contributing Code](#contributing-code) -- [Contributing Documentation](#contributing-documentation) -- [Questions or Suggestions?](#questions-or-suggestions) -- [Last Words](#last-words) - ---- +> The following documentation describes how to work with Mermaid in your host environment. +> There's also a [Docker installation guide](../community/docker-development.md) +> if you prefer to work in a Docker environment. So you want to help? That's great! @@ -22,47 +16,68 @@ So you want to help? That's great! Here are a few things to get you started on the right path. -## Technical Requirements and Setup +## Get the Source Code -### Technical Requirements +In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests. -These are the tools we use for working with the code and documentation. +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. + +[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentaion, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories). + +[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) + +## Technical Requirements + +> The following documentation describes how to work with Mermaid in your host environment. +> There's also a [Docker installation guide](../community/docker-development.md) +> if you prefer to work in a Docker environment. + +These are the tools we use for working with the code and documentation: - [volta](https://volta.sh/) to manage node versions. - [Node.js](https://nodejs.org/en/). `volta install node` - [pnpm](https://pnpm.io/) package manager. `volta install pnpm` -- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#2-install-pnpm) +- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#install-packages) -Follow [the setup steps below](#setup) to install them and verify they are working +Follow the setup steps below to install them and start the development. -### Setup +## Setup and Launch -Follow these steps to set up the environment you need to work on code and/or documentation. +### Switch to project -#### 1. Fork and clone the repository - -In GitHub, you first _fork_ a repository when you are going to make changes and submit pull requests. - -Then you _clone_ a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. - -[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) - -#### 2. Install pnpm - -Once you have cloned the repository onto your development machine, change into the `mermaid` project folder so that you can install `pnpm`. You will need `npx` to install pnpm because volta doesn't support it yet. - -Ex: +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository) ```bash -# Change into the mermaid directory (the top level director of the mermaid project repository) cd mermaid -# npx is required for first install because volta does not support pnpm yet -npx pnpm install ``` -#### 3. Verify Everything Is Working +### Install packages -Once you have installed pnpm, you can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly: +Run `npx pnpm install`. You will need `npx` for this because volta doesn't support it yet. + +```bash +npx pnpm install # npx is required for first install +``` + +### Launch + +```bash +npx pnpm run dev +``` + +Now you are ready to make your changes! Edit whichever files in `src` as required. + +Open in your browser, after starting the dev server. +There is a list of demos that can be used to see and test your changes. + +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. + +That will be served at . +After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) + +## Verify Everything is Working + +You can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly: ```bash pnpm test @@ -70,321 +85,7 @@ pnpm test The `test` script and others are in the top-level `package.json` file. -All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ "warnings"; those are ok during this step.) - -#### 4. Make your changes - -Now you are ready to make your changes! -Edit whichever files in `src` as required. - -#### 5. See your changes - -Open in your browser, after starting the dev server. -There is a list of demos that can be used to see and test your changes. - -If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. -That will be served at . -After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) - -### Docker - -If you are using docker and docker-compose, you have self-documented `run` bash script, which is a convenient alias for docker-compose commands: - -```bash -./run install # npx pnpm install -./run test # pnpm test -``` - -## Contributing Code - -The basic steps for contributing code are: - -```mermaid-example -graph LR - git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] -``` - -```mermaid -graph LR - git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] -``` - -1. **Create** and checkout a git branch and work on your code in the branch -2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.) -3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_ -4. **Submit** your code as a _pull request_. -5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat. - -### 1. Checkout a git branch - -Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. - -Development is done in the `develop` branch. - -Once development is done we create a `release/vX.X.X` branch from `develop` for testing. - -Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch. - -**All new work should be based on the `develop` branch.** - -**When you are ready to do work, always, ALWAYS:** - -1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it) -2. Check out the `develop` branch -3. Create a new branch for your work. Please name the branch following our naming convention below. - -We use the follow naming convention for branches: - -```text - [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] -``` - -- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs') -- followed by a _slash_ (which helps to group like types together in many git tools) -- followed by the **issue number** -- followed by an _underscore_ ('\_') -- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces) - -If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together. - -**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams** - -`feature/2945_state-diagram-new-arrow-florbs` - -**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types** -`bug/1123_fix_random_ugly_red_text` - -### 2. Write Tests - -Tests ensure that each function, module, or part of code does what it says it will do. This is critically -important when other changes are made to ensure that existing code is not broken (no regression). - -Just as important, the tests act as _specifications:_ they specify what the code does (or should do). -Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why. - -If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again. -(If there had been a test for the situation, the bug never would have happened in the first place.) -You may need to change existing tests if they were inaccurate. - -If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests. - -#### Unit Tests - -Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run. - -Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.) - -We use [Vitest](https://vitest.dev) to run unit tests. - -You can use the following command to run the unit tests: - -```sh -pnpm test -``` - -When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command: - -```sh -pnpm test:watch -``` - -#### Integration/End-to-End (e2e) tests - -These test the rendering and visual appearance of the diagrams. -This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks! - -To start working with the e2e tests: - -1. Run `pnpm dev` to start the dev server -2. Start **Cypress** by running `pnpm cypress:open`. - -The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress. - -When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs. - -This is what a rendering test looks like: - -```js -it('should render forks and joins', () => { - imgSnapshotTest( - ` - stateDiagram - state fork_state <<fork>> - [*] --> fork_state - fork_state --> State2 - fork_state --> State3 - - state join_state <<join>> - State2 --> join_state - State3 --> join_state - join_state --> State4 - State4 --> [*] - `, - { logLevel: 0 } - ); - cy.get('svg'); -}); -``` - -**_\[TODO - running the tests against what is expected in development. ]_** - -**_\[TODO - how to generate new screenshots]_** -.... - -### 3. Update Documentation - -If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken. -Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. - -The documentation has to be updated to users know that things have changed and added! -If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. - -eg: `# Feature Name (v+)` - -We know it can sometimes be hard to code _and_ write user documentation. - -Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section. - -Create another issue specifically for the documentation.\ -You will need to help with the PR, but definitely ask for help if you feel stuck. -When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work! - -When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!) - -### 4. Submit your pull request - -**\[TODO - PR titles should start with (fix | feat | ....)]** - -We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs. - -- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed. -- The maintainers will request a review from knsv, if necessary. -- Once the PR is approved, the maintainers will merge the PR into the `develop` branch. -- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process. - -**Reminder: Pull Requests should be submitted to the develop branch.** - -## Contributing Documentation - -**_\[TODO: This section is still a WIP. It still needs MAJOR revision.]_** - -If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature? - -The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing. - -The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. -Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published. - -### How to Contribute to Documentation - -We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. - -The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder. - -The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually. - -```mermaid-example -flowchart LR - classDef default fill:#fff,color:black,stroke:black - - source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] - -``` - -```mermaid -flowchart LR - classDef default fill:#fff,color:black,stroke:black - - source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] - -``` - -You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. -Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. - -```` -```note -Note content -``` - -```tip -Tip content -``` - -```warning -Warning content -``` - -```danger -Danger content -``` - -```` - -> **Note** -> If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. - -We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). - -**_DO NOT CHANGE FILES IN `/docs`_** - -### The official documentation site - -**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).** - -To run the documentation site locally: - -1. Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.) -2. Open in your browser. - -Markdown is used to format the text, for more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). - -To edit Docs on your computer: - -_\[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_ - -1. Create a fork of the develop branch to work on. -2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. -3. Make changes or add new documentation. -4. Commit changes to your branch and push it to GitHub (which should create a new branch). -5. Create a Pull Request of your fork. - -To edit Docs on GitHub: - -1. Login to [GitHub.com](https://www.github.com). -2. Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository. -3. To edit a file, click the pencil icon at the top-right of the file contents panel. -4. Describe what you changed in the **Propose file change** section, located at the bottom of the page. -5. Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch). -6. Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork. -7. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. - -### Documentation organization: Sidebar navigation - -If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.** - -The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts). - -## Questions or Suggestions? - -#### First search to see if someone has already asked (and hopefully been answered) or suggested the same thing. - -- Search in Discussions -- Search in open Issues -- Search in closed Issues - -If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it. -Use the GitHub reactions to add a thumbs-up to the issue or discussion thread. - -This helps the team know the relative interest in something and helps them set priorities and assignments. - -Feel free to add to the discussion on the issue or topic. - -If you can't find anything that already addresses your question or suggestion, _open a new issue:_ - -Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). - -### How to Contribute a Suggestion +All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.) ## Last Words diff --git a/docs/community/docker-development.md b/docs/community/docker-development.md new file mode 100644 index 000000000..4b206408c --- /dev/null +++ b/docs/community/docker-development.md @@ -0,0 +1,109 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/docker-development.md](../../packages/mermaid/src/docs/community/docker-development.md). + +# Contributing to Mermaid via Docker + +> The following documentation describes how to work with Mermaid in a Docker environment. +> There's also a [host installation guide](../community/development.md) +> if you prefer to work without a Docker environment. + +So you want to help? That's great! + +![Image of happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif) + +Here are a few things to get you started on the right path. + +## Get the Source Code + +In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests. + +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. + +[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentaion, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories). + +[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) + +## Technical Requirements + +> The following documentation describes how to work with Mermaid in a Docker environment. +> There's also a [host installation guide](../community/development.md) +> if you prefer to work without a Docker environment. + +[Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need. + +Optionally, to run GUI (Cypress) within Docker you will also need X11 server installed. +Maybe you already have it installed, so check it first: + +```bash +echo $DISPLAY +``` + +If variable `$DISPLAY` is not empty, then it must be working. Otherwise install it. + +## Setup and Launch + +### Switch to project + +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository) + +```bash +cd mermaid +``` + +### Make `./run` executable + +For development using Docker there is a self-documented `run` bash script, which provides convenient aliases for `docker compose` commands. + +Ensure `./run` script is executable: + +```bash +chmod +x run +``` + +> **💡 Tip** +> To get detailed help simply type `./run` or `./run help`. +> +> It also has short _Development quick start guide_ embedded. + +### Install packages + +```bash +./run pnpm install # Install packages +``` + +### Launch + +```bash +./run dev +``` + +Now you are ready to make your changes! Edit whichever files in `src` as required. + +Open in your browser, after starting the dev server. +There is a list of demos that can be used to see and test your changes. + +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. + +That will be served at . +After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) + +## Verify Everything is Working + +```bash +./run pnpm test +``` + +The `test` script and others are in the top-level `package.json` file. + +All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.) + +## Last Words + +Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there. + +[Join our Slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) + +![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif) diff --git a/docs/community/documentation.md b/docs/community/documentation.md new file mode 100644 index 000000000..b4f19597a --- /dev/null +++ b/docs/community/documentation.md @@ -0,0 +1,106 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/documentation.md](../../packages/mermaid/src/docs/community/documentation.md). + +# Contributing Documentation + +**_\[TODO: This section is still a WIP. It still needs MAJOR revision.]_** + +If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature? + +The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing. + +The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. +Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published. + +## How to Contribute to Documentation + +We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. + +The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder. + +The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually. + +```mermaid-example +flowchart LR + classDef default fill:#fff,color:black,stroke:black + + source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] + +``` + +```mermaid +flowchart LR + classDef default fill:#fff,color:black,stroke:black + + source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] + +``` + +You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. +Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. + +```` +```note +Note content +``` + +```tip +Tip content +``` + +```warning +Warning content +``` + +```danger +Danger content +``` + +```` + +> **Note** +> If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. + +We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). + +**_DO NOT CHANGE FILES IN `/docs`_** + +## The official documentation site + +**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).** + +To run the documentation site locally: + +1. Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.) +2. Open in your browser. + +Markdown is used to format the text, for more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). + +To edit Docs on your computer: + +_\[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_ + +1. Create a fork of the develop branch to work on. +2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. +3. Make changes or add new documentation. +4. Commit changes to your branch and push it to GitHub (which should create a new branch). +5. Create a Pull Request of your fork. + +To edit Docs on GitHub: + +1. Login to [GitHub.com](https://www.github.com). +2. Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository. +3. To edit a file, click the pencil icon at the top-right of the file contents panel. +4. Describe what you changed in the **Propose file change** section, located at the bottom of the page. +5. Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch). +6. Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork. +7. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. + +## Documentation organization: Sidebar navigation + +If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.** + +The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts). diff --git a/docs/community/n00b-overview.md b/docs/community/n00b-overview.md deleted file mode 100644 index afb110e9e..000000000 --- a/docs/community/n00b-overview.md +++ /dev/null @@ -1,74 +0,0 @@ -> **Warning** -> -> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. -> -> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/n00b-overview.md](../../packages/mermaid/src/docs/community/n00b-overview.md). - -# Overview for Beginners - -**Explaining with a Diagram** - -A picture is worth a thousand words, a good diagram is undoubtedly worth more. They make understanding easier. - -## Creating and Maintaining Diagrams - -Anyone who has used Visio, or (God Forbid) Excel to make a Gantt Chart, knows how hard it is to create, edit and maintain good visualizations. - -Diagrams/Charts are significant but also become obsolete/inaccurate very fast. This catch-22 hobbles the productivity of teams. - -# Doc Rot in Diagrams - -Doc-Rot kills diagrams as quickly as it does text, but it takes hours in a desktop application to produce a diagram. - -Mermaid seeks to change using markdown-inspired syntax. The process is a quicker, less complicated, and more convenient way of going from concept to visualization. - -It is a relatively straightforward solution to a significant hurdle with the software teams. - -# Definition of Terms/ Dictionary - -**Mermaid text definitions can be saved for later reuse and editing.** - -> These are the Mermaid diagram definitions inside `
` tags, with the `class=mermaid`. - -```html -
-    graph TD
-    A[Client] --> B[Load Balancer]
-    B --> C[Server01]
-    B --> D[Server02]
-
-``` - -**render** - -> This is the core function of the Mermaid API. It reads all the `Mermaid Definitions` inside `div` tags and returns an SVG file, based on the definition. - -**Nodes** - -> These are the boxes that contain text or otherwise discrete pieces of each diagram, separated generally by arrows, except for Gantt Charts and User Journey Diagrams. They will be referred often in the instructions. Read for Diagram Specific [Syntax](../intro/n00b-syntaxReference.md) - -## Advantages of using Mermaid - -- Ease to generate, modify and render diagrams when you make them. -- The number of integrations and plugins it has. -- You can add it to your or companies website. -- Diagrams can be created through comments like this in a script: - -## The catch-22 of Diagrams and Charts: - -**Diagramming and charting is a large waste of developer's time, but not having diagrams ruins productivity.** - -Mermaid solves this by reducing the time and effort required to create diagrams and charts. - -Because, the text base for the diagrams allows it to be updated easily. Also, it can be made part of production scripts (and other pieces of code). So less time is spent on documenting, as a separate task. - -## Catching up with Development - -Being based on markdown, Mermaid can be used, not only by accomplished front-end developers, but by most computer savvy people to render diagrams, at much faster speeds. -In fact one can pick up the syntax for it quite easily from the examples given and there are many tutorials available in the internet. - -## Mermaid is for everyone. - -Video [Tutorials](https://mermaid.js.org/config/Tutorials.html) are also available for the mermaid [live editor](https://mermaid.live/). - -Alternatively you can use Mermaid [Plug-Ins](https://mermaid-js.github.io/mermaid/#/./integrations), with tools you already use, like Google Docs. diff --git a/docs/community/questionsAndSuggestions.md b/docs/community/questionsAndSuggestions.md new file mode 100644 index 000000000..28b107d1f --- /dev/null +++ b/docs/community/questionsAndSuggestions.md @@ -0,0 +1,28 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/questionsAndSuggestions.md](../../packages/mermaid/src/docs/community/questionsAndSuggestions.md). + +# Questions or Suggestions? + +**_\[TODO: This section is still a WIP. It still needs MAJOR revision.]_** + +## First search to see if someone has already asked (and hopefully been answered) or suggested the same thing. + +- Search in Discussions +- Search in open Issues +- Search in closed Issues + +If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it. +Use the GitHub reactions to add a thumbs-up to the issue or discussion thread. + +This helps the team know the relative interest in something and helps them set priorities and assignments. + +Feel free to add to the discussion on the issue or topic. + +If you can't find anything that already addresses your question or suggestion, _open a new issue:_ + +Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). + +## How to Contribute a Suggestion diff --git a/docs/intro/index.md b/docs/intro/index.md index 6b811d86e..89af6ecd1 100644 --- a/docs/intro/index.md +++ b/docs/intro/index.md @@ -322,6 +322,7 @@ To Deploy Mermaid: - [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) - [Mermaid Webpack Demo](https://github.com/mermaidjs/mermaid-webpack-demo) - [Mermaid Parcel Demo](https://github.com/mermaidjs/mermaid-parcel-demo) +- [HTTP Server](https://github.com/TomWright/mermaid-server) ## Request for Assistance @@ -338,7 +339,17 @@ Together we could continue the work with things like: Don't hesitate to contact me if you want to get involved! -## For contributors +## Contributors + +
+ +[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) + +
+ +Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. + +Detailed information about how to contribute can be found in the [contribution guideline](/community/development). ### Requirements @@ -346,7 +357,7 @@ Don't hesitate to contact me if you want to get involved! - [Node.js](https://nodejs.org/en/). `volta install node` - [pnpm](https://pnpm.io/) package manager. `volta install pnpm` -## Development Installation +### Development Installation ```bash git clone git@github.com:mermaid-js/mermaid.git @@ -383,25 +394,7 @@ Update version number in `package.json`. npm publish ``` -The above command generates files into the `dist` folder and publishes them to \. - -## Related projects - -- [Command Line Interface](https://github.com/mermaid-js/mermaid-cli) -- [Live Editor](https://github.com/mermaid-js/mermaid-live-editor) -- [HTTP Server](https://github.com/TomWright/mermaid-server) - -## Contributors - -
- -[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) - -
- -Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. - -Detailed information about how to contribute can be found in the [contribution guide](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md) +The above command generates files into the `dist` folder and publishes them to [npmjs.org](npmjs.org). ## Security and safe diagrams diff --git a/docs/intro/n00b-syntaxReference.md b/docs/intro/n00b-syntaxReference.md index c51b1680e..e8c5dab68 100644 --- a/docs/intro/n00b-syntaxReference.md +++ b/docs/intro/n00b-syntaxReference.md @@ -56,11 +56,11 @@ One should **beware the use of some words or symbols** that can break diagrams. | 'end' | The word "End" can cause Flowcharts and Sequence diagrams to break | Wrap them in quotation marks to prevent breakage. | | [Nodes inside Nodes](../syntax/flowchart.md?id=special-characters-that-break-syntax) | Mermaid gets confused with nested shapes | wrap them in quotation marks to prevent breaking | -### Mermaid Live Editor +## Mermaid Live Editor Now, that you've seen what you should not add to your diagrams, you can play around with them in the [Mermaid Live Editor](https://mermaid.live). -# Configuration +## Configuration Configuration is the third part of Mermaid, after deployment and syntax. It deals with the different ways that Mermaid can be customized across different deployments. diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index 06485ab7d..f86da0490 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -72,6 +72,11 @@ function nav() { activeMatch: '/config/', }, { text: 'Integrations', link: '/ecosystem/integrations', activeMatch: '/ecosystem/' }, + { + text: 'Contributing', + link: '/community/development.html', + activeMatch: '/community/', + }, { text: 'Latest News', link: '/news/announcements', @@ -104,11 +109,8 @@ function sidebarAll() { collapsed: false, items: [ { text: 'About Mermaid', link: '/intro/' }, - { text: 'Deployment', link: '/intro/n00b-gettingStarted' }, - { - text: 'Syntax and Configuration', - link: '/intro/n00b-syntaxReference', - }, + { text: 'Getting Started', link: '/intro/n00b-gettingStarted' }, + { text: 'Syntax and Configuration', link: '/intro/n00b-syntaxReference' }, ], }, ...sidebarSyntax(), @@ -191,8 +193,10 @@ function sidebarCommunity() { text: '🙌 Contributions and Community', collapsed: false, items: [ - { text: 'Overview for Beginners', link: '/community/n00b-overview' }, - ...sidebarCommunityDevelopContribute(), + { text: 'Contributing to Mermaid', link: '/community/development' }, + { text: 'Contributing Code', link: '/community/code' }, + { text: 'Contributing Documentation', link: '/community/documentation' }, + { text: 'Questions and Suggestions', link: '/community/questionsAndSuggestions' }, { text: 'Adding Diagrams', link: '/community/newDiagram' }, { text: 'Security', link: '/community/security' }, ], @@ -200,40 +204,6 @@ function sidebarCommunity() { ]; } -// Development and Contributing -function sidebarCommunityDevelopContribute() { - const page_path = '/community/development'; - return [ - { - text: 'Contributing to Mermaid', - link: page_path + '#contributing-to-mermaid', - collapsed: false, - items: [ - { - text: 'Technical Requirements and Setup', - link: pathToId(page_path, 'technical-requirements-and-setup'), - }, - { - text: 'Contributing Code', - link: pathToId(page_path, 'contributing-code'), - }, - { - text: 'Contributing Documentation', - link: pathToId(page_path, 'contributing-documentation'), - }, - { - text: 'Questions or Suggestions?', - link: pathToId(page_path, 'questions-or-suggestions'), - }, - { - text: 'Last Words', - link: pathToId(page_path, 'last-words'), - }, - ], - }, - ]; -} - function sidebarNews() { return [ { diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts index da32e5f8f..da4326be7 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts @@ -50,6 +50,7 @@ const idRedirectMap: Record = { 'n00b-advanced': 'config/n00b-advanced', 'n00b-gettingstarted': 'intro/n00b-gettingStarted', 'n00b-overview': 'community/n00b-overview', + 'community/n00b-overview': 'intro/n00b-gettingStarted', 'n00b-syntaxreference': 'intro/n00b-syntaxReference', newdiagram: 'community/newDiagram', pie: 'syntax/pie', diff --git a/packages/mermaid/src/docs/community/code.md b/packages/mermaid/src/docs/community/code.md new file mode 100644 index 000000000..cfbba8b7e --- /dev/null +++ b/packages/mermaid/src/docs/community/code.md @@ -0,0 +1,165 @@ +# Contributing Code + +The basic steps for contributing code are: + +```mermaid +graph LR + git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] +``` + +1. **Create** and checkout a git branch and work on your code in the branch +2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.) +3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_ +4. **Submit** your code as a _pull request_. +5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat. + +## 1. Checkout a git branch + +Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. + +Development is done in the `develop` branch. + +Once development is done we create a `release/vX.X.X` branch from `develop` for testing. + +Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch. + +**All new work should be based on the `develop` branch.** + +**When you are ready to do work, always, ALWAYS:** + +1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it) +2. Check out the `develop` branch +3. Create a new branch for your work. Please name the branch following our naming convention below. + +We use the follow naming convention for branches: + +```txt + [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] +``` + +You can always check current [configuration of labelling and branch prefixes](https://github.com/mermaid-js/mermaid/blob/develop/.github/pr-labeler.yml) + +- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs') +- followed by a _slash_ (which helps to group like types together in many git tools) +- followed by the **issue number** +- followed by an _underscore_ ('\_') +- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces) + +If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together. + +**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams** + +`feature/2945_state-diagram-new-arrow-florbs` + +**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types** +`bug/1123_fix_random_ugly_red_text` + +## 2. Write Tests + +Tests ensure that each function, module, or part of code does what it says it will do. This is critically +important when other changes are made to ensure that existing code is not broken (no regression). + +Just as important, the tests act as _specifications:_ they specify what the code does (or should do). +Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why. + +If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again. +(If there had been a test for the situation, the bug never would have happened in the first place.) +You may need to change existing tests if they were inaccurate. + +If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests. + +### Unit Tests + +Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run. + +Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.) + +We use [Vitest](https://vitest.dev) to run unit tests. + +You can use the following command to run the unit tests: + +```sh +pnpm test +``` + +When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command: + +```sh +pnpm test:watch +``` + +### Integration/End-to-End (e2e) tests + +These test the rendering and visual appearance of the diagrams. +This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks! + +To start working with the e2e tests: + +1. Run `pnpm dev` to start the dev server +2. Start **Cypress** by running `pnpm cypress:open`. + +The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress. + +When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs. + +This is what a rendering test looks like: + +```js +it('should render forks and joins', () => { + imgSnapshotTest( + ` + stateDiagram + state fork_state <<fork>> + [*] --> fork_state + fork_state --> State2 + fork_state --> State3 + + state join_state <<join>> + State2 --> join_state + State3 --> join_state + join_state --> State4 + State4 --> [*] + `, + { logLevel: 0 } + ); + cy.get('svg'); +}); +``` + +**_[TODO - running the tests against what is expected in development. ]_** + +**_[TODO - how to generate new screenshots]_** +.... + +## 3. Update Documentation + +If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken. +Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. + +The documentation has to be updated to users know that things have changed and added! +If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. + +eg: `# Feature Name (v+)` + +We know it can sometimes be hard to code _and_ write user documentation. + +Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section. + +Create another issue specifically for the documentation. +You will need to help with the PR, but definitely ask for help if you feel stuck. +When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work! + +When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!) + +## 4. Submit your pull request + +**[TODO - PR titles should start with (fix | feat | ....)]** + +We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs. + +- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed. +- The maintainers will request a review from knsv, if necessary. +- Once the PR is approved, the maintainers will merge the PR into the `develop` branch. +- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process. + +**Reminder: Pull Requests should be submitted to the develop branch.** diff --git a/packages/mermaid/src/docs/community/development.md b/packages/mermaid/src/docs/community/development.md index 35a01e589..e3c0826fd 100644 --- a/packages/mermaid/src/docs/community/development.md +++ b/packages/mermaid/src/docs/community/development.md @@ -1,14 +1,8 @@ # Contributing to Mermaid -## Contents - -- [Technical Requirements and Setup](#technical-requirements-and-setup) -- [Contributing Code](#contributing-code) -- [Contributing Documentation](#contributing-documentation) -- [Questions or Suggestions?](#questions-or-suggestions) -- [Last Words](#last-words) - ---- +> The following documentation describes how to work with Mermaid in your host environment. +> There's also a [Docker installation guide](../community/docker-development.md) +> if you prefer to work in a Docker environment. So you want to help? That's great! @@ -16,47 +10,68 @@ So you want to help? That's great! Here are a few things to get you started on the right path. -## Technical Requirements and Setup +## Get the Source Code -### Technical Requirements +In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests. -These are the tools we use for working with the code and documentation. +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. + +[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentaion, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories). + +[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) + +## Technical Requirements + +> The following documentation describes how to work with Mermaid in your host environment. +> There's also a [Docker installation guide](../community/docker-development.md) +> if you prefer to work in a Docker environment. + +These are the tools we use for working with the code and documentation: - [volta](https://volta.sh/) to manage node versions. - [Node.js](https://nodejs.org/en/). `volta install node` - [pnpm](https://pnpm.io/) package manager. `volta install pnpm` -- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#2-install-pnpm) +- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#install-packages) -Follow [the setup steps below](#setup) to install them and verify they are working +Follow the setup steps below to install them and start the development. -### Setup +## Setup and Launch -Follow these steps to set up the environment you need to work on code and/or documentation. +### Switch to project -#### 1. Fork and clone the repository - -In GitHub, you first _fork_ a repository when you are going to make changes and submit pull requests. - -Then you _clone_ a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. - -[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) - -#### 2. Install pnpm - -Once you have cloned the repository onto your development machine, change into the `mermaid` project folder so that you can install `pnpm`. You will need `npx` to install pnpm because volta doesn't support it yet. - -Ex: +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository) ```bash -# Change into the mermaid directory (the top level director of the mermaid project repository) cd mermaid -# npx is required for first install because volta does not support pnpm yet -npx pnpm install ``` -#### 3. Verify Everything Is Working +### Install packages -Once you have installed pnpm, you can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly: +Run `npx pnpm install`. You will need `npx` for this because volta doesn't support it yet. + +```bash +npx pnpm install # npx is required for first install +``` + +### Launch + +```bash +npx pnpm run dev +``` + +Now you are ready to make your changes! Edit whichever files in `src` as required. + +Open in your browser, after starting the dev server. +There is a list of demos that can be used to see and test your changes. + +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. + +That will be served at . +After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) + +## Verify Everything is Working + +You can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly: ```bash pnpm test @@ -64,309 +79,7 @@ pnpm test The `test` script and others are in the top-level `package.json` file. -All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ "warnings"; those are ok during this step.) - -#### 4. Make your changes - -Now you are ready to make your changes! -Edit whichever files in `src` as required. - -#### 5. See your changes - -Open in your browser, after starting the dev server. -There is a list of demos that can be used to see and test your changes. - -If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. -That will be served at . -After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) - -### Docker - -If you are using docker and docker-compose, you have self-documented `run` bash script, which is a convenient alias for docker-compose commands: - -```bash -./run install # npx pnpm install -./run test # pnpm test -``` - -## Contributing Code - -The basic steps for contributing code are: - -```mermaid -graph LR - git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] -``` - -1. **Create** and checkout a git branch and work on your code in the branch -2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.) -3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_ -4. **Submit** your code as a _pull request_. -5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat. - -### 1. Checkout a git branch - -Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. - -Development is done in the `develop` branch. - -Once development is done we create a `release/vX.X.X` branch from `develop` for testing. - -Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch. - -**All new work should be based on the `develop` branch.** - -**When you are ready to do work, always, ALWAYS:** - -1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it) -2. Check out the `develop` branch -3. Create a new branch for your work. Please name the branch following our naming convention below. - -We use the follow naming convention for branches: - -```text - [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] -``` - -- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs') -- followed by a _slash_ (which helps to group like types together in many git tools) -- followed by the **issue number** -- followed by an _underscore_ ('\_') -- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces) - -If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together. - -**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams** - -`feature/2945_state-diagram-new-arrow-florbs` - -**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types** -`bug/1123_fix_random_ugly_red_text` - -### 2. Write Tests - -Tests ensure that each function, module, or part of code does what it says it will do. This is critically -important when other changes are made to ensure that existing code is not broken (no regression). - -Just as important, the tests act as _specifications:_ they specify what the code does (or should do). -Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why. - -If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again. -(If there had been a test for the situation, the bug never would have happened in the first place.) -You may need to change existing tests if they were inaccurate. - -If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests. - -#### Unit Tests - -Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run. - -Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.) - -We use [Vitest](https://vitest.dev) to run unit tests. - -You can use the following command to run the unit tests: - -```sh -pnpm test -``` - -When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command: - -```sh -pnpm test:watch -``` - -#### Integration/End-to-End (e2e) tests - -These test the rendering and visual appearance of the diagrams. -This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks! - -To start working with the e2e tests: - -1. Run `pnpm dev` to start the dev server -2. Start **Cypress** by running `pnpm cypress:open`. - -The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress. - -When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs. - -This is what a rendering test looks like: - -```js -it('should render forks and joins', () => { - imgSnapshotTest( - ` - stateDiagram - state fork_state <<fork>> - [*] --> fork_state - fork_state --> State2 - fork_state --> State3 - - state join_state <<join>> - State2 --> join_state - State3 --> join_state - join_state --> State4 - State4 --> [*] - `, - { logLevel: 0 } - ); - cy.get('svg'); -}); -``` - -**_[TODO - running the tests against what is expected in development. ]_** - -**_[TODO - how to generate new screenshots]_** -.... - -### 3. Update Documentation - -If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken. -Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. - -The documentation has to be updated to users know that things have changed and added! -If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. - -eg: `# Feature Name (v+)` - -We know it can sometimes be hard to code _and_ write user documentation. - -Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section. - -Create another issue specifically for the documentation. -You will need to help with the PR, but definitely ask for help if you feel stuck. -When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work! - -When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!) - -### 4. Submit your pull request - -**[TODO - PR titles should start with (fix | feat | ....)]** - -We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs. - -- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed. -- The maintainers will request a review from knsv, if necessary. -- Once the PR is approved, the maintainers will merge the PR into the `develop` branch. -- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process. - -**Reminder: Pull Requests should be submitted to the develop branch.** - -## Contributing Documentation - -**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_** - -If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature? - -The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing. - -The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. -Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published. - -### How to Contribute to Documentation - -We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. - -The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder. - -The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually. - -```mermaid -flowchart LR - classDef default fill:#fff,color:black,stroke:black - - source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] - -``` - -You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. -Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. - -```` -```note -Note content -``` - -```tip -Tip content -``` - -```warning -Warning content -``` - -```danger -Danger content -``` - -```` - -```note -If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. -``` - -We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). - -**_DO NOT CHANGE FILES IN `/docs`_** - -### The official documentation site - -**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).** - -To run the documentation site locally: - -1. Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.) -2. Open [http://localhost:3333/](http://localhost:3333/) in your browser. - -Markdown is used to format the text, for more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). - -To edit Docs on your computer: - -_[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_ - -1. Create a fork of the develop branch to work on. -2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. -3. Make changes or add new documentation. -4. Commit changes to your branch and push it to GitHub (which should create a new branch). -5. Create a Pull Request of your fork. - -To edit Docs on GitHub: - -1. Login to [GitHub.com](https://www.github.com). -2. Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository. -3. To edit a file, click the pencil icon at the top-right of the file contents panel. -4. Describe what you changed in the **Propose file change** section, located at the bottom of the page. -5. Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch). -6. Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork. -7. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. - -### Documentation organization: Sidebar navigation - -If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.** - -The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts). - -## Questions or Suggestions? - -#### First search to see if someone has already asked (and hopefully been answered) or suggested the same thing. - -- Search in Discussions -- Search in open Issues -- Search in closed Issues - -If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it. -Use the GitHub reactions to add a thumbs-up to the issue or discussion thread. - -This helps the team know the relative interest in something and helps them set priorities and assignments. - -Feel free to add to the discussion on the issue or topic. - -If you can't find anything that already addresses your question or suggestion, _open a new issue:_ - -Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). - -### How to Contribute a Suggestion +All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.) ## Last Words diff --git a/packages/mermaid/src/docs/community/docker-development.md b/packages/mermaid/src/docs/community/docker-development.md new file mode 100644 index 000000000..f3fb41391 --- /dev/null +++ b/packages/mermaid/src/docs/community/docker-development.md @@ -0,0 +1,104 @@ +# Contributing to Mermaid via Docker + +> The following documentation describes how to work with Mermaid in a Docker environment. +> There's also a [host installation guide](../community/development.md) +> if you prefer to work without a Docker environment. + +So you want to help? That's great! + +![Image of happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif) + +Here are a few things to get you started on the right path. + +## Get the Source Code + +In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests. + +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. + +[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentaion, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories). + +[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) + +## Technical Requirements + +> The following documentation describes how to work with Mermaid in a Docker environment. +> There's also a [host installation guide](../community/development.md) +> if you prefer to work without a Docker environment. + +[Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need. + +Optionally, to run GUI (Cypress) within Docker you will also need X11 server installed. +Maybe you already have it installed, so check it first: + +```bash +echo $DISPLAY +``` + +If variable `$DISPLAY` is not empty, then it must be working. Otherwise install it. + +## Setup and Launch + +### Switch to project + +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository) + +```bash +cd mermaid +``` + +### Make `./run` executable + +For development using Docker there is a self-documented `run` bash script, which provides convenient aliases for `docker compose` commands. + +Ensure `./run` script is executable: + +```bash +chmod +x run +``` + +```tip +To get detailed help simply type `./run` or `./run help`. + +It also has short _Development quick start guide_ embedded. +``` + +### Install packages + +```bash +./run pnpm install # Install packages +``` + +### Launch + +```bash +./run dev +``` + +Now you are ready to make your changes! Edit whichever files in `src` as required. + +Open in your browser, after starting the dev server. +There is a list of demos that can be used to see and test your changes. + +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. + +That will be served at . +After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) + +## Verify Everything is Working + +```bash +./run pnpm test +``` + +The `test` script and others are in the top-level `package.json` file. + +All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.) + +## Last Words + +Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there. + +[Join our Slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) + +![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif) diff --git a/packages/mermaid/src/docs/community/documentation.md b/packages/mermaid/src/docs/community/documentation.md new file mode 100644 index 000000000..79a984376 --- /dev/null +++ b/packages/mermaid/src/docs/community/documentation.md @@ -0,0 +1,93 @@ +# Contributing Documentation + +**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_** + +If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature? + +The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing. + +The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. +Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published. + +## How to Contribute to Documentation + +We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. + +The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder. + +The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually. + +```mermaid +flowchart LR + classDef default fill:#fff,color:black,stroke:black + + source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] + +``` + +You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. +Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. + +```` +```note +Note content +``` + +```tip +Tip content +``` + +```warning +Warning content +``` + +```danger +Danger content +``` + +```` + +```note +If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. +``` + +We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). + +**_DO NOT CHANGE FILES IN `/docs`_** + +## The official documentation site + +**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).** + +To run the documentation site locally: + +1. Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.) +2. Open [http://localhost:3333/](http://localhost:3333/) in your browser. + +Markdown is used to format the text, for more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). + +To edit Docs on your computer: + +_[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_ + +1. Create a fork of the develop branch to work on. +2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. +3. Make changes or add new documentation. +4. Commit changes to your branch and push it to GitHub (which should create a new branch). +5. Create a Pull Request of your fork. + +To edit Docs on GitHub: + +1. Login to [GitHub.com](https://www.github.com). +2. Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository. +3. To edit a file, click the pencil icon at the top-right of the file contents panel. +4. Describe what you changed in the **Propose file change** section, located at the bottom of the page. +5. Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch). +6. Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork. +7. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. + +## Documentation organization: Sidebar navigation + +If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.** + +The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts). diff --git a/packages/mermaid/src/docs/community/n00b-overview.md b/packages/mermaid/src/docs/community/n00b-overview.md deleted file mode 100644 index e8e84641a..000000000 --- a/packages/mermaid/src/docs/community/n00b-overview.md +++ /dev/null @@ -1,68 +0,0 @@ -# Overview for Beginners - -**Explaining with a Diagram** - -A picture is worth a thousand words, a good diagram is undoubtedly worth more. They make understanding easier. - -## Creating and Maintaining Diagrams - -Anyone who has used Visio, or (God Forbid) Excel to make a Gantt Chart, knows how hard it is to create, edit and maintain good visualizations. - -Diagrams/Charts are significant but also become obsolete/inaccurate very fast. This catch-22 hobbles the productivity of teams. - -# Doc Rot in Diagrams - -Doc-Rot kills diagrams as quickly as it does text, but it takes hours in a desktop application to produce a diagram. - -Mermaid seeks to change using markdown-inspired syntax. The process is a quicker, less complicated, and more convenient way of going from concept to visualization. - -It is a relatively straightforward solution to a significant hurdle with the software teams. - -# Definition of Terms/ Dictionary - -**Mermaid text definitions can be saved for later reuse and editing.** - -> These are the Mermaid diagram definitions inside `
` tags, with the `class=mermaid`. - -```html -
-    graph TD
-    A[Client] --> B[Load Balancer]
-    B --> C[Server01]
-    B --> D[Server02]
-
-``` - -**render** - -> This is the core function of the Mermaid API. It reads all the `Mermaid Definitions` inside `div` tags and returns an SVG file, based on the definition. - -**Nodes** - -> These are the boxes that contain text or otherwise discrete pieces of each diagram, separated generally by arrows, except for Gantt Charts and User Journey Diagrams. They will be referred often in the instructions. Read for Diagram Specific [Syntax](../intro/n00b-syntaxReference.md) - -## Advantages of using Mermaid - -- Ease to generate, modify and render diagrams when you make them. -- The number of integrations and plugins it has. -- You can add it to your or companies website. -- Diagrams can be created through comments like this in a script: - -## The catch-22 of Diagrams and Charts: - -**Diagramming and charting is a large waste of developer's time, but not having diagrams ruins productivity.** - -Mermaid solves this by reducing the time and effort required to create diagrams and charts. - -Because, the text base for the diagrams allows it to be updated easily. Also, it can be made part of production scripts (and other pieces of code). So less time is spent on documenting, as a separate task. - -## Catching up with Development - -Being based on markdown, Mermaid can be used, not only by accomplished front-end developers, but by most computer savvy people to render diagrams, at much faster speeds. -In fact one can pick up the syntax for it quite easily from the examples given and there are many tutorials available in the internet. - -## Mermaid is for everyone. - -Video [Tutorials](https://mermaid.js.org/config/Tutorials.html) are also available for the mermaid [live editor](https://mermaid.live/). - -Alternatively you can use Mermaid [Plug-Ins](https://mermaid-js.github.io/mermaid/#/./integrations), with tools you already use, like Google Docs. diff --git a/packages/mermaid/src/docs/community/questionsAndSuggestions.md b/packages/mermaid/src/docs/community/questionsAndSuggestions.md new file mode 100644 index 000000000..f72d0a47d --- /dev/null +++ b/packages/mermaid/src/docs/community/questionsAndSuggestions.md @@ -0,0 +1,22 @@ +# Questions or Suggestions? + +**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_** + +## First search to see if someone has already asked (and hopefully been answered) or suggested the same thing. + +- Search in Discussions +- Search in open Issues +- Search in closed Issues + +If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it. +Use the GitHub reactions to add a thumbs-up to the issue or discussion thread. + +This helps the team know the relative interest in something and helps them set priorities and assignments. + +Feel free to add to the discussion on the issue or topic. + +If you can't find anything that already addresses your question or suggestion, _open a new issue:_ + +Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). + +## How to Contribute a Suggestion diff --git a/packages/mermaid/src/docs/intro/index.md b/packages/mermaid/src/docs/intro/index.md index c81cd0efc..61fd064ec 100644 --- a/packages/mermaid/src/docs/intro/index.md +++ b/packages/mermaid/src/docs/intro/index.md @@ -99,6 +99,7 @@ To Deploy Mermaid: - [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) - [Mermaid Webpack Demo](https://github.com/mermaidjs/mermaid-webpack-demo) - [Mermaid Parcel Demo](https://github.com/mermaidjs/mermaid-parcel-demo) +- [HTTP Server](https://github.com/TomWright/mermaid-server) ## Request for Assistance @@ -115,7 +116,17 @@ Together we could continue the work with things like: Don't hesitate to contact me if you want to get involved! -## For contributors +## Contributors + +
+ +[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) + +
+ +Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. + +Detailed information about how to contribute can be found in the [contribution guideline](/community/development). ### Requirements @@ -123,7 +134,7 @@ Don't hesitate to contact me if you want to get involved! - [Node.js](https://nodejs.org/en/). `volta install node` - [pnpm](https://pnpm.io/) package manager. `volta install pnpm` -## Development Installation +### Development Installation ```bash git clone git@github.com:mermaid-js/mermaid.git @@ -160,25 +171,7 @@ Update version number in `package.json`. npm publish ``` -The above command generates files into the `dist` folder and publishes them to . - -## Related projects - -- [Command Line Interface](https://github.com/mermaid-js/mermaid-cli) -- [Live Editor](https://github.com/mermaid-js/mermaid-live-editor) -- [HTTP Server](https://github.com/TomWright/mermaid-server) - -## Contributors - -
- -[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) - -
- -Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. - -Detailed information about how to contribute can be found in the [contribution guide](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md) +The above command generates files into the `dist` folder and publishes them to [npmjs.org](npmjs.org). ## Security and safe diagrams diff --git a/packages/mermaid/src/docs/intro/n00b-syntaxReference.md b/packages/mermaid/src/docs/intro/n00b-syntaxReference.md index 8e8c18a4d..398f83257 100644 --- a/packages/mermaid/src/docs/intro/n00b-syntaxReference.md +++ b/packages/mermaid/src/docs/intro/n00b-syntaxReference.md @@ -38,11 +38,11 @@ One should **beware the use of some words or symbols** that can break diagrams. | 'end' | The word "End" can cause Flowcharts and Sequence diagrams to break | Wrap them in quotation marks to prevent breakage. | | [Nodes inside Nodes](../syntax/flowchart.md?id=special-characters-that-break-syntax) | Mermaid gets confused with nested shapes | wrap them in quotation marks to prevent breaking | -### Mermaid Live Editor +## Mermaid Live Editor Now, that you've seen what you should not add to your diagrams, you can play around with them in the [Mermaid Live Editor](https://mermaid.live). -# Configuration +## Configuration Configuration is the third part of Mermaid, after deployment and syntax. It deals with the different ways that Mermaid can be customized across different deployments. diff --git a/run b/run index cc169e209..fbf437263 100755 --- a/run +++ b/run @@ -80,6 +80,9 @@ $(bold ./$name cypress open --project .) $(bold ./$name cypress run --spec cypress/integration/rendering/)$(underline test.spec.ts) Run specific test in cypress\n +$(bold xhost +local:) + Allow local connections for x11 server + EOF ) From 7b45dbea1a74f46b136d3b7bcd4c001f685312cf Mon Sep 17 00:00:00 2001 From: Nikolay Rozhkov Date: Fri, 18 Aug 2023 03:14:12 +0300 Subject: [PATCH 03/31] Fixed links --- docs/intro/index.md | 2 +- packages/mermaid/src/docs/intro/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/intro/index.md b/docs/intro/index.md index 89af6ecd1..b77dd454f 100644 --- a/docs/intro/index.md +++ b/docs/intro/index.md @@ -37,7 +37,7 @@ Mermaid allows even non-programmers to easily create detailed and diagrams throu [Tutorials](../config/Tutorials.md) has video tutorials. Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](../ecosystem/integrations.md). -For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../community/n00b-overview.md) and [Usage](../config/usage.md). +For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../intro/n00b-gettingStarted.md) and [Usage](../config/usage.md). 🌐 [CDN](https://www.jsdelivr.com/package/npm/mermaid) | 📖 [Documentation](https://mermaidjs.github.io) | 🙌 [Contribution](../community/development.md) | 🔌 [Plug-Ins](../ecosystem/integrations.md) diff --git a/packages/mermaid/src/docs/intro/index.md b/packages/mermaid/src/docs/intro/index.md index 61fd064ec..c76f09a08 100644 --- a/packages/mermaid/src/docs/intro/index.md +++ b/packages/mermaid/src/docs/intro/index.md @@ -32,7 +32,7 @@ Mermaid allows even non-programmers to easily create detailed and diagrams throu [Tutorials](../config/Tutorials.md) has video tutorials. Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](../ecosystem/integrations.md). -For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../community/n00b-overview.md) and [Usage](../config/usage.md). +For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../intro/n00b-gettingStarted.md) and [Usage](../config/usage.md). 🌐 [CDN](https://www.jsdelivr.com/package/npm/mermaid) | 📖 [Documentation](https://mermaidjs.github.io) | 🙌 [Contribution](../community/development.md) | 🔌 [Plug-Ins](../ecosystem/integrations.md) From 4d84f1cd71eba0b1aa0e544e05c47e45c9355939 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 19 Aug 2023 11:19:18 +0530 Subject: [PATCH 04/31] feat(sankey): Show values (#4674) --- demos/sankey.html | 32 +++++++++++++++---- packages/mermaid/src/config.type.ts | 15 +++++++++ .../mermaid/src/diagrams/sankey/sankeyDB.ts | 2 +- .../src/diagrams/sankey/sankeyRenderer.ts | 26 ++++++++++----- .../mermaid/src/schemas/config.schema.yaml | 14 ++++++++ 5 files changed, 74 insertions(+), 15 deletions(-) diff --git a/demos/sankey.html b/demos/sankey.html index 0c9679c65..4c3eeac5e 100644 --- a/demos/sankey.html +++ b/demos/sankey.html @@ -5,16 +5,13 @@ States Mermaid Quick Test Page -

Sankey diagram demos

+

FY20-21 Performance

+
+

Energy flow

       sankey-beta
@@ -101,8 +98,31 @@
           height: 600,
           linkColor: 'gradient',
           nodeAlignment: 'justify',
+          showValues: false,
+        },
+        startOnLoad: false,
+      });
+      // Render the Energy flow diagram
+      await mermaid.run();
+
+      mermaid.initialize({
+        sankey: {
+          prefix: '$',
+          suffix: 'B',
         },
       });
+
+      const { svg } = await mermaid.render(
+        'ff',
+        `
+sankey-beta
+Revenue,Expenses,10
+Revenue,Profit,10
+Expenses,Manufacturing,5
+Expenses,Tax,3
+Expenses,Research,2`
+      );
+      document.getElementById('financials').innerHTML = svg;
     
   
 
diff --git a/packages/mermaid/src/config.type.ts b/packages/mermaid/src/config.type.ts
index c378660ca..a4bf6cca8 100644
--- a/packages/mermaid/src/config.type.ts
+++ b/packages/mermaid/src/config.type.ts
@@ -1298,6 +1298,21 @@ export interface SankeyDiagramConfig extends BaseDiagramConfig {
    */
   nodeAlignment?: 'left' | 'right' | 'center' | 'justify';
   useMaxWidth?: boolean;
+  /**
+   * Toggle to display or hide values along with title.
+   *
+   */
+  showValues?: boolean;
+  /**
+   * The prefix to use for values
+   *
+   */
+  prefix?: string;
+  /**
+   * The suffix to use for values
+   *
+   */
+  suffix?: string;
 }
 /**
  * This interface was referenced by `MermaidConfig`'s JSON-Schema
diff --git a/packages/mermaid/src/diagrams/sankey/sankeyDB.ts b/packages/mermaid/src/diagrams/sankey/sankeyDB.ts
index 1921e1b85..f6db1886d 100644
--- a/packages/mermaid/src/diagrams/sankey/sankeyDB.ts
+++ b/packages/mermaid/src/diagrams/sankey/sankeyDB.ts
@@ -31,7 +31,7 @@ class SankeyLink {
 /**
  * @param source - Node where the link starts
  * @param target - Node where the link ends
- * @param value - number, float or integer, describes the amount to be passed
+ * @param value - Describes the amount to be passed
  */
 const addLink = (source: SankeyNode, target: SankeyNode, value: number): void => {
   links.push(new SankeyLink(source, target, value));
diff --git a/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts b/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
index a9ee698e9..c40226b4c 100644
--- a/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
+++ b/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
@@ -18,7 +18,7 @@ import {
 } from 'd3-sankey';
 import { configureSvgSize } from '../../setupGraphViewbox.js';
 import { Uid } from '../../rendering-util/uid.js';
-import type { SankeyLinkColor, SankeyNodeAlignment } from '../../config.type.js';
+import type { SankeyNodeAlignment } from '../../config.type.js';
 
 // Map config options to alignment functions
 const alignmentsMap: Record<
@@ -62,10 +62,13 @@ export const draw = function (text: string, id: string, _version: string, diagOb
 
   // Establish svg dimensions and get width and height
   //
-  const width = conf?.width || defaultSankeyConfig.width!;
-  const height = conf?.height || defaultSankeyConfig.width!;
-  const useMaxWidth = conf?.useMaxWidth || defaultSankeyConfig.useMaxWidth!;
-  const nodeAlignment = conf?.nodeAlignment || defaultSankeyConfig.nodeAlignment!;
+  const width = conf?.width ?? defaultSankeyConfig.width!;
+  const height = conf?.height ?? defaultSankeyConfig.width!;
+  const useMaxWidth = conf?.useMaxWidth ?? defaultSankeyConfig.useMaxWidth!;
+  const nodeAlignment = conf?.nodeAlignment ?? defaultSankeyConfig.nodeAlignment!;
+  const prefix = conf?.prefix ?? defaultSankeyConfig.prefix!;
+  const suffix = conf?.suffix ?? defaultSankeyConfig.suffix!;
+  const showValues = conf?.showValues ?? defaultSankeyConfig.showValues!;
 
   // FIX: using max width prevents height from being set, is it intended?
   // to add height directly one can use `svg.attr('height', height)`
@@ -94,7 +97,7 @@ export const draw = function (text: string, id: string, _version: string, diagOb
   const sankey = d3Sankey()
     .nodeId((d: any) => d.id) // we use 'id' property to identify node
     .nodeWidth(nodeWidth)
-    .nodePadding(10)
+    .nodePadding(10 + (showValues ? 15 : 0))
     .nodeAlign(nodeAlign)
     .extent([
       [0, 0],
@@ -130,6 +133,13 @@ export const draw = function (text: string, id: string, _version: string, diagOb
     .attr('width', (d: any) => d.x1 - d.x0)
     .attr('fill', (d: any) => colorScheme(d.id));
 
+  const getText = ({ id, value }: { id: string; value: number }) => {
+    if (!showValues) {
+      return id;
+    }
+    return `${id}\n${prefix}${Math.round(value * 100) / 100}${suffix}`;
+  };
+
   // Create labels for nodes
   svg
     .append('g')
@@ -141,9 +151,9 @@ export const draw = function (text: string, id: string, _version: string, diagOb
     .join('text')
     .attr('x', (d: any) => (d.x0 < width / 2 ? d.x1 + 6 : d.x0 - 6))
     .attr('y', (d: any) => (d.y1 + d.y0) / 2)
-    .attr('dy', '0.35em')
+    .attr('dy', `${showValues ? '0' : '0.35'}em`)
     .attr('text-anchor', (d: any) => (d.x0 < width / 2 ? 'start' : 'end'))
-    .text((d: any) => d.id);
+    .text(getText);
 
   // Creates the paths that represent the links.
   const link = svg
diff --git a/packages/mermaid/src/schemas/config.schema.yaml b/packages/mermaid/src/schemas/config.schema.yaml
index 6e5f48d95..9e7b3e6f3 100644
--- a/packages/mermaid/src/schemas/config.schema.yaml
+++ b/packages/mermaid/src/schemas/config.schema.yaml
@@ -1859,6 +1859,20 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
         default: justify
       useMaxWidth:
         default: false
+      showValues:
+        description: |
+          Toggle to display or hide values along with title.
+        default: true
+      prefix:
+        description: |
+          The prefix to use for values
+        type: string
+        default: ''
+      suffix:
+        description: |
+          The suffix to use for values
+        type: string
+        default: ''
 
   FontCalculator:
     title: Font Calculator

From 11b599d77cd9cbaff6f6520d66b5041a88069fe8 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Tue, 22 Aug 2023 13:44:11 +0530
Subject: [PATCH 05/31] chore: Fix type imports

---
 .eslintrc.cjs                                            | 1 +
 packages/mermaid/src/diagram-api/detectType.ts           | 2 +-
 packages/mermaid/src/diagram-api/diagramAPI.spec.ts      | 2 +-
 packages/mermaid/src/diagram-api/types.ts                | 2 +-
 packages/mermaid/src/diagrams/c4/c4Diagram.ts            | 4 ++--
 packages/mermaid/src/diagrams/class/classDb.ts           | 5 +++--
 packages/mermaid/src/diagrams/class/classDiagram-v2.ts   | 2 +-
 packages/mermaid/src/diagrams/class/classDiagram.ts      | 2 +-
 packages/mermaid/src/diagrams/class/classRenderer-v2.ts  | 2 +-
 packages/mermaid/src/diagrams/common/common.ts           | 2 +-
 .../src/diagrams/flowchart/elk/render-utils.spec.ts      | 3 ++-
 .../mermaid/src/diagrams/flowchart/flowDiagram-v2.ts     | 2 +-
 packages/mermaid/src/diagrams/flowchart/flowDiagram.ts   | 2 +-
 packages/mermaid/src/diagrams/gantt/ganttDiagram.ts      | 2 +-
 packages/mermaid/src/diagrams/git/gitGraphDiagram.ts     | 2 +-
 packages/mermaid/src/diagrams/pie/pieRenderer.ts         | 3 ++-
 .../quadrant-chart/parser/quadrant.jison.spec.ts         | 3 ++-
 .../src/diagrams/quadrant-chart/quadrantDiagram.ts       | 2 +-
 .../src/diagrams/quadrant-chart/quadrantRenderer.ts      | 4 ++--
 .../src/diagrams/requirement/requirementDiagram.ts       | 2 +-
 packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts    | 2 +-
 packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts   | 4 ++--
 .../mermaid/src/diagrams/sequence/sequenceDiagram.ts     | 2 +-
 .../mermaid/src/diagrams/sequence/sequenceRenderer.ts    | 2 +-
 packages/mermaid/src/diagrams/state/stateDiagram-v2.ts   | 2 +-
 packages/mermaid/src/diagrams/state/stateDiagram.ts      | 2 +-
 .../mermaid/src/diagrams/timeline/timelineRenderer.ts    | 7 ++++---
 .../mermaid/src/diagrams/user-journey/journeyDiagram.ts  | 2 +-
 packages/mermaid/src/mermaid.ts                          | 9 +++++----
 packages/mermaid/src/mermaidAPI.spec.ts                  | 2 +-
 packages/mermaid/src/mermaidAPI.ts                       | 2 +-
 packages/mermaid/src/rendering-util/createText.ts        | 2 +-
 .../mermaid/src/rendering-util/handle-markdown-text.ts   | 2 +-
 packages/mermaid/src/utils.ts                            | 4 ++--
 34 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index cae97e586..273aa47b9 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -48,6 +48,7 @@ module.exports = {
     'no-prototype-builtins': 'off',
     'no-unused-vars': 'off',
     'cypress/no-async-tests': 'off',
+    '@typescript-eslint/consistent-type-imports': 'error',
     '@typescript-eslint/no-floating-promises': 'error',
     '@typescript-eslint/no-misused-promises': 'error',
     '@typescript-eslint/ban-ts-comment': [
diff --git a/packages/mermaid/src/diagram-api/detectType.ts b/packages/mermaid/src/diagram-api/detectType.ts
index aae913155..ba78dbe55 100644
--- a/packages/mermaid/src/diagram-api/detectType.ts
+++ b/packages/mermaid/src/diagram-api/detectType.ts
@@ -1,4 +1,4 @@
-import { MermaidConfig } from '../config.type.js';
+import type { MermaidConfig } from '../config.type.js';
 import { log } from '../logger.js';
 import type {
   DetectorRecord,
diff --git a/packages/mermaid/src/diagram-api/diagramAPI.spec.ts b/packages/mermaid/src/diagram-api/diagramAPI.spec.ts
index b437745cf..b82011f8d 100644
--- a/packages/mermaid/src/diagram-api/diagramAPI.spec.ts
+++ b/packages/mermaid/src/diagram-api/diagramAPI.spec.ts
@@ -1,7 +1,7 @@
 import { detectType } from './detectType.js';
 import { getDiagram, registerDiagram } from './diagramAPI.js';
 import { addDiagrams } from './diagram-orchestration.js';
-import { DiagramDetector } from './types.js';
+import type { DiagramDetector } from './types.js';
 import { getDiagramFromText } from '../Diagram.js';
 import { it, describe, expect, beforeAll } from 'vitest';
 
diff --git a/packages/mermaid/src/diagram-api/types.ts b/packages/mermaid/src/diagram-api/types.ts
index 4d30fe97d..2ac7fba12 100644
--- a/packages/mermaid/src/diagram-api/types.ts
+++ b/packages/mermaid/src/diagram-api/types.ts
@@ -1,4 +1,4 @@
-import { Diagram } from '../Diagram.js';
+import type { Diagram } from '../Diagram.js';
 import type { BaseDiagramConfig, MermaidConfig } from '../config.type.js';
 import type * as d3 from 'd3';
 
diff --git a/packages/mermaid/src/diagrams/c4/c4Diagram.ts b/packages/mermaid/src/diagrams/c4/c4Diagram.ts
index b3c7ae8eb..4c578b624 100644
--- a/packages/mermaid/src/diagrams/c4/c4Diagram.ts
+++ b/packages/mermaid/src/diagrams/c4/c4Diagram.ts
@@ -3,8 +3,8 @@ import c4Parser from './parser/c4Diagram.jison';
 import c4Db from './c4Db.js';
 import c4Renderer from './c4Renderer.js';
 import c4Styles from './styles.js';
-import { MermaidConfig } from '../../config.type.js';
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { MermaidConfig } from '../../config.type.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 
 export const diagram: DiagramDefinition = {
   parser: c4Parser,
diff --git a/packages/mermaid/src/diagrams/class/classDb.ts b/packages/mermaid/src/diagrams/class/classDb.ts
index 7b74aa819..b14b1d07a 100644
--- a/packages/mermaid/src/diagrams/class/classDb.ts
+++ b/packages/mermaid/src/diagrams/class/classDb.ts
@@ -1,5 +1,6 @@
 // @ts-nocheck - don't check until handle it
-import { select, Selection } from 'd3';
+import type { Selection } from 'd3';
+import { select } from 'd3';
 import { log } from '../../logger.js';
 import * as configApi from '../../config.js';
 import common from '../common/common.js';
@@ -14,7 +15,7 @@ import {
   setDiagramTitle,
   getDiagramTitle,
 } from '../../commonDb.js';
-import {
+import type {
   ClassRelation,
   ClassNode,
   ClassNote,
diff --git a/packages/mermaid/src/diagrams/class/classDiagram-v2.ts b/packages/mermaid/src/diagrams/class/classDiagram-v2.ts
index 91e8597a4..ec5398d29 100644
--- a/packages/mermaid/src/diagrams/class/classDiagram-v2.ts
+++ b/packages/mermaid/src/diagrams/class/classDiagram-v2.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: JISON doesn't support types
 import parser from './parser/classDiagram.jison';
 import db from './classDb.js';
diff --git a/packages/mermaid/src/diagrams/class/classDiagram.ts b/packages/mermaid/src/diagrams/class/classDiagram.ts
index 532d52189..7f027c186 100644
--- a/packages/mermaid/src/diagrams/class/classDiagram.ts
+++ b/packages/mermaid/src/diagrams/class/classDiagram.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: JISON doesn't support types
 import parser from './parser/classDiagram.jison';
 import db from './classDb.js';
diff --git a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts
index 6197fe8ac..d9e39912c 100644
--- a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts
+++ b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts
@@ -8,7 +8,7 @@ import utils from '../../utils.js';
 import { interpolateToCurve, getStylesFromArray } from '../../utils.js';
 import { setupGraphViewbox } from '../../setupGraphViewbox.js';
 import common from '../common/common.js';
-import { ClassRelation, ClassNote, ClassMap, EdgeData, NamespaceMap } from './classTypes.js';
+import type { ClassRelation, ClassNote, ClassMap, EdgeData, NamespaceMap } from './classTypes.js';
 
 const sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig());
 
diff --git a/packages/mermaid/src/diagrams/common/common.ts b/packages/mermaid/src/diagrams/common/common.ts
index 24591642b..ef9ace6b3 100644
--- a/packages/mermaid/src/diagrams/common/common.ts
+++ b/packages/mermaid/src/diagrams/common/common.ts
@@ -1,5 +1,5 @@
 import DOMPurify from 'dompurify';
-import { MermaidConfig } from '../../config.type.js';
+import type { MermaidConfig } from '../../config.type.js';
 
 // Remove and ignore br:s
 export const lineBreakRegex = //gi;
diff --git a/packages/mermaid/src/diagrams/flowchart/elk/render-utils.spec.ts b/packages/mermaid/src/diagrams/flowchart/elk/render-utils.spec.ts
index d048b07a3..046ed43c1 100644
--- a/packages/mermaid/src/diagrams/flowchart/elk/render-utils.spec.ts
+++ b/packages/mermaid/src/diagrams/flowchart/elk/render-utils.spec.ts
@@ -1,4 +1,5 @@
-import { findCommonAncestor, TreeData } from './render-utils.js';
+import type { TreeData } from './render-utils.js';
+import { findCommonAncestor } from './render-utils.js';
 describe('when rendering a flowchart using elk ', () => {
   let lookupDb: TreeData;
   beforeEach(() => {
diff --git a/packages/mermaid/src/diagrams/flowchart/flowDiagram-v2.ts b/packages/mermaid/src/diagrams/flowchart/flowDiagram-v2.ts
index 754057211..c3de4b685 100644
--- a/packages/mermaid/src/diagrams/flowchart/flowDiagram-v2.ts
+++ b/packages/mermaid/src/diagrams/flowchart/flowDiagram-v2.ts
@@ -3,7 +3,7 @@ import flowParser from './parser/flow.jison';
 import flowDb from './flowDb.js';
 import flowRendererV2 from './flowRenderer-v2.js';
 import flowStyles from './styles.js';
-import { MermaidConfig } from '../../config.type.js';
+import type { MermaidConfig } from '../../config.type.js';
 import { setConfig } from '../../config.js';
 
 export const diagram = {
diff --git a/packages/mermaid/src/diagrams/flowchart/flowDiagram.ts b/packages/mermaid/src/diagrams/flowchart/flowDiagram.ts
index 2c331f4eb..ca4f8fba8 100644
--- a/packages/mermaid/src/diagrams/flowchart/flowDiagram.ts
+++ b/packages/mermaid/src/diagrams/flowchart/flowDiagram.ts
@@ -4,7 +4,7 @@ import flowDb from './flowDb.js';
 import flowRenderer from './flowRenderer.js';
 import flowRendererV2 from './flowRenderer-v2.js';
 import flowStyles from './styles.js';
-import { MermaidConfig } from '../../config.type.js';
+import type { MermaidConfig } from '../../config.type.js';
 
 export const diagram = {
   parser: flowParser,
diff --git a/packages/mermaid/src/diagrams/gantt/ganttDiagram.ts b/packages/mermaid/src/diagrams/gantt/ganttDiagram.ts
index cf2974d44..a9ebfdb93 100644
--- a/packages/mermaid/src/diagrams/gantt/ganttDiagram.ts
+++ b/packages/mermaid/src/diagrams/gantt/ganttDiagram.ts
@@ -3,7 +3,7 @@ import ganttParser from './parser/gantt.jison';
 import ganttDb from './ganttDb.js';
 import ganttRenderer from './ganttRenderer.js';
 import ganttStyles from './styles.js';
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 
 export const diagram: DiagramDefinition = {
   parser: ganttParser,
diff --git a/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts b/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts
index c9a21cc2d..2a9efdb59 100644
--- a/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts
+++ b/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts
@@ -3,7 +3,7 @@ import gitGraphParser from './parser/gitGraph.jison';
 import gitGraphDb from './gitGraphAst.js';
 import gitGraphRenderer from './gitGraphRenderer.js';
 import gitGraphStyles from './styles.js';
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 
 export const diagram: DiagramDefinition = {
   parser: gitGraphParser,
diff --git a/packages/mermaid/src/diagrams/pie/pieRenderer.ts b/packages/mermaid/src/diagrams/pie/pieRenderer.ts
index 57dd4002b..5ef081842 100644
--- a/packages/mermaid/src/diagrams/pie/pieRenderer.ts
+++ b/packages/mermaid/src/diagrams/pie/pieRenderer.ts
@@ -1,4 +1,5 @@
-import d3, { scaleOrdinal, pie as d3pie, arc } from 'd3';
+import type d3 from 'd3';
+import { scaleOrdinal, pie as d3pie, arc } from 'd3';
 
 import { log } from '../../logger.js';
 import { configureSvgSize } from '../../setupGraphViewbox.js';
diff --git a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts
index f4a9835e1..faa9281f0 100644
--- a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts
+++ b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts
@@ -1,6 +1,7 @@
 // @ts-ignore: JISON doesn't support types
 import { parser } from './quadrant.jison';
-import { Mock, vi } from 'vitest';
+import type { Mock } from 'vitest';
+import { vi } from 'vitest';
 
 const parserFnConstructor = (str: string) => {
   return () => {
diff --git a/packages/mermaid/src/diagrams/quadrant-chart/quadrantDiagram.ts b/packages/mermaid/src/diagrams/quadrant-chart/quadrantDiagram.ts
index c2fc970b1..a9e822d0e 100644
--- a/packages/mermaid/src/diagrams/quadrant-chart/quadrantDiagram.ts
+++ b/packages/mermaid/src/diagrams/quadrant-chart/quadrantDiagram.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: JISON doesn't support types
 import parser from './parser/quadrant.jison';
 import db from './quadrantDb.js';
diff --git a/packages/mermaid/src/diagrams/quadrant-chart/quadrantRenderer.ts b/packages/mermaid/src/diagrams/quadrant-chart/quadrantRenderer.ts
index 92943337a..9dd309b53 100644
--- a/packages/mermaid/src/diagrams/quadrant-chart/quadrantRenderer.ts
+++ b/packages/mermaid/src/diagrams/quadrant-chart/quadrantRenderer.ts
@@ -3,8 +3,8 @@ import { select } from 'd3';
 import * as configApi from '../../config.js';
 import { log } from '../../logger.js';
 import { configureSvgSize } from '../../setupGraphViewbox.js';
-import { Diagram } from '../../Diagram.js';
-import {
+import type { Diagram } from '../../Diagram.js';
+import type {
   QuadrantBuildType,
   QuadrantLineType,
   QuadrantPointType,
diff --git a/packages/mermaid/src/diagrams/requirement/requirementDiagram.ts b/packages/mermaid/src/diagrams/requirement/requirementDiagram.ts
index c2e997628..619f5b052 100644
--- a/packages/mermaid/src/diagrams/requirement/requirementDiagram.ts
+++ b/packages/mermaid/src/diagrams/requirement/requirementDiagram.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: JISON doesn't support types
 import parser from './parser/requirementDiagram.jison';
 import db from './requirementDb.js';
diff --git a/packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts b/packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts
index d5b62122e..6fed435ac 100644
--- a/packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts
+++ b/packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: jison doesn't export types
 import parser from './parser/sankey.jison';
 import db from './sankeyDB.js';
diff --git a/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts b/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
index a9ee698e9..c624de4cf 100644
--- a/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
+++ b/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
@@ -1,4 +1,4 @@
-import { Diagram } from '../../Diagram.js';
+import type { Diagram } from '../../Diagram.js';
 import * as configApi from '../../config.js';
 
 import {
@@ -7,6 +7,7 @@ import {
   schemeTableau10 as d3schemeTableau10,
 } from 'd3';
 
+import type { SankeyNode as d3SankeyNode } from 'd3-sankey';
 import {
   sankey as d3Sankey,
   sankeyLinkHorizontal as d3SankeyLinkHorizontal,
@@ -14,7 +15,6 @@ import {
   sankeyRight as d3SankeyRight,
   sankeyCenter as d3SankeyCenter,
   sankeyJustify as d3SankeyJustify,
-  SankeyNode as d3SankeyNode,
 } from 'd3-sankey';
 import { configureSvgSize } from '../../setupGraphViewbox.js';
 import { Uid } from '../../rendering-util/uid.js';
diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.ts b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.ts
index b4342a694..8779b9cc4 100644
--- a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.ts
+++ b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: JISON doesn't support types
 import parser from './parser/sequenceDiagram.jison';
 import db from './sequenceDb.js';
diff --git a/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts b/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts
index feee7157f..e84d2254c 100644
--- a/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts
+++ b/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts
@@ -8,7 +8,7 @@ import * as configApi from '../../config.js';
 import assignWithDepth from '../../assignWithDepth.js';
 import utils from '../../utils.js';
 import { configureSvgSize } from '../../setupGraphViewbox.js';
-import { Diagram } from '../../Diagram.js';
+import type { Diagram } from '../../Diagram.js';
 
 let conf = {};
 
diff --git a/packages/mermaid/src/diagrams/state/stateDiagram-v2.ts b/packages/mermaid/src/diagrams/state/stateDiagram-v2.ts
index 8f62a64db..36fc95edd 100644
--- a/packages/mermaid/src/diagrams/state/stateDiagram-v2.ts
+++ b/packages/mermaid/src/diagrams/state/stateDiagram-v2.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: JISON doesn't support types
 import parser from './parser/stateDiagram.jison';
 import db from './stateDb.js';
diff --git a/packages/mermaid/src/diagrams/state/stateDiagram.ts b/packages/mermaid/src/diagrams/state/stateDiagram.ts
index fd3467607..643e847ce 100644
--- a/packages/mermaid/src/diagrams/state/stateDiagram.ts
+++ b/packages/mermaid/src/diagrams/state/stateDiagram.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: JISON doesn't support types
 import parser from './parser/stateDiagram.jison';
 import db from './stateDb.js';
diff --git a/packages/mermaid/src/diagrams/timeline/timelineRenderer.ts b/packages/mermaid/src/diagrams/timeline/timelineRenderer.ts
index d44174fe4..ee351d905 100644
--- a/packages/mermaid/src/diagrams/timeline/timelineRenderer.ts
+++ b/packages/mermaid/src/diagrams/timeline/timelineRenderer.ts
@@ -1,11 +1,12 @@
 // @ts-nocheck - don't check until handle it
-import { select, Selection } from 'd3';
+import type { Selection } from 'd3';
+import { select } from 'd3';
 import svgDraw from './svgDraw.js';
 import { log } from '../../logger.js';
 import { getConfig } from '../../config.js';
 import { setupGraphViewbox } from '../../setupGraphViewbox.js';
-import { Diagram } from '../../Diagram.js';
-import { MermaidConfig } from '../../config.type.js';
+import type { Diagram } from '../../Diagram.js';
+import type { MermaidConfig } from '../../config.type.js';
 
 interface Block {
   number: number;
diff --git a/packages/mermaid/src/diagrams/user-journey/journeyDiagram.ts b/packages/mermaid/src/diagrams/user-journey/journeyDiagram.ts
index 1c009d9ea..c2b6cd717 100644
--- a/packages/mermaid/src/diagrams/user-journey/journeyDiagram.ts
+++ b/packages/mermaid/src/diagrams/user-journey/journeyDiagram.ts
@@ -1,4 +1,4 @@
-import { DiagramDefinition } from '../../diagram-api/types.js';
+import type { DiagramDefinition } from '../../diagram-api/types.js';
 // @ts-ignore: JISON doesn't support types
 import parser from './parser/journey.jison';
 import db from './journeyDb.js';
diff --git a/packages/mermaid/src/mermaid.ts b/packages/mermaid/src/mermaid.ts
index d140ded4f..caf4a2b9b 100644
--- a/packages/mermaid/src/mermaid.ts
+++ b/packages/mermaid/src/mermaid.ts
@@ -3,17 +3,18 @@
  * functionality and to render the diagrams to svg code!
  */
 import { dedent } from 'ts-dedent';
-import { MermaidConfig } from './config.type.js';
+import type { MermaidConfig } from './config.type.js';
 import { log } from './logger.js';
 import utils from './utils.js';
-import { mermaidAPI, ParseOptions, RenderResult } from './mermaidAPI.js';
+import type { ParseOptions, RenderResult } from './mermaidAPI.js';
+import { mermaidAPI } from './mermaidAPI.js';
 import { registerLazyLoadedDiagrams, detectType } from './diagram-api/detectType.js';
 import { loadRegisteredDiagrams } from './diagram-api/loadDiagram.js';
 import type { ParseErrorFunction } from './Diagram.js';
 import { isDetailedError } from './utils.js';
 import type { DetailedError } from './utils.js';
-import { ExternalDiagramDefinition } from './diagram-api/types.js';
-import { UnknownDiagramError } from './errors.js';
+import type { ExternalDiagramDefinition } from './diagram-api/types.js';
+import type { UnknownDiagramError } from './errors.js';
 
 export type {
   MermaidConfig,
diff --git a/packages/mermaid/src/mermaidAPI.spec.ts b/packages/mermaid/src/mermaidAPI.spec.ts
index 0f4e61499..d7c16a1cf 100644
--- a/packages/mermaid/src/mermaidAPI.spec.ts
+++ b/packages/mermaid/src/mermaidAPI.spec.ts
@@ -34,7 +34,7 @@ vi.mock('./diagrams/state/stateRenderer-v2.js');
 // -------------------------------------
 
 import mermaid from './mermaid.js';
-import { MermaidConfig } from './config.type.js';
+import type { MermaidConfig } from './config.type.js';
 
 import mermaidAPI, { removeExistingElements } from './mermaidAPI.js';
 import {
diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts
index f8a36f88e..1654a2f6e 100644
--- a/packages/mermaid/src/mermaidAPI.ts
+++ b/packages/mermaid/src/mermaidAPI.ts
@@ -25,7 +25,7 @@ import getStyles from './styles.js';
 import theme from './themes/index.js';
 import utils, { directiveSanitizer } from './utils.js';
 import DOMPurify from 'dompurify';
-import { MermaidConfig } from './config.type.js';
+import type { MermaidConfig } from './config.type.js';
 import { evaluate } from './diagrams/common/common.js';
 import isEmpty from 'lodash-es/isEmpty.js';
 import { setA11yDiagramInfo, addSVGa11yTitleDescription } from './accessibility.js';
diff --git a/packages/mermaid/src/rendering-util/createText.ts b/packages/mermaid/src/rendering-util/createText.ts
index 703e121e2..a0aaa66ba 100644
--- a/packages/mermaid/src/rendering-util/createText.ts
+++ b/packages/mermaid/src/rendering-util/createText.ts
@@ -4,7 +4,7 @@ import { log } from '../logger.js';
 import { decodeEntities } from '../mermaidAPI.js';
 import { markdownToHTML, markdownToLines } from '../rendering-util/handle-markdown-text.js';
 import { splitLineToFitWidth } from './splitText.js';
-import { MarkdownLine, MarkdownWord } from './types.js';
+import type { MarkdownLine, MarkdownWord } from './types.js';
 
 function applyStyle(dom, styleFn) {
   if (styleFn) {
diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.ts b/packages/mermaid/src/rendering-util/handle-markdown-text.ts
index ae76faf8a..ce694edcd 100644
--- a/packages/mermaid/src/rendering-util/handle-markdown-text.ts
+++ b/packages/mermaid/src/rendering-util/handle-markdown-text.ts
@@ -1,7 +1,7 @@
 import type { Content } from 'mdast';
 import { fromMarkdown } from 'mdast-util-from-markdown';
 import { dedent } from 'ts-dedent';
-import { MarkdownLine, MarkdownWordType } from './types.js';
+import type { MarkdownLine, MarkdownWordType } from './types.js';
 
 /**
  * @param markdown - markdown to process
diff --git a/packages/mermaid/src/utils.ts b/packages/mermaid/src/utils.ts
index 0c5eca2ae..0558cfd0d 100644
--- a/packages/mermaid/src/utils.ts
+++ b/packages/mermaid/src/utils.ts
@@ -1,5 +1,6 @@
 // @ts-nocheck : TODO Fix ts errors
 import { sanitizeUrl } from '@braintree/sanitize-url';
+import type { CurveFactory } from 'd3';
 import {
   curveBasis,
   curveBasisClosed,
@@ -13,7 +14,6 @@ import {
   curveCatmullRomClosed,
   curveCatmullRomOpen,
   curveCatmullRom,
-  CurveFactory,
   curveLinear,
   curveLinearClosed,
   curveMonotoneX,
@@ -29,7 +29,7 @@ import { configKeys } from './defaultConfig.js';
 import { log } from './logger.js';
 import { detectType } from './diagram-api/detectType.js';
 import assignWithDepth from './assignWithDepth.js';
-import { MermaidConfig } from './config.type.js';
+import type { MermaidConfig } from './config.type.js';
 import memoize from 'lodash-es/memoize.js';
 import merge from 'lodash-es/merge.js';
 import { directiveRegex } from './diagram-api/regexes.js';

From ce6992ea9b70b43e511e0be0ff246e82a532500a Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Tue, 22 Aug 2023 14:06:46 +0530
Subject: [PATCH 06/31] docs: Fix sankey demo

---
 demos/sankey.html | 60 ++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 32 deletions(-)

diff --git a/demos/sankey.html b/demos/sankey.html
index 4c3eeac5e..5a76f476a 100644
--- a/demos/sankey.html
+++ b/demos/sankey.html
@@ -3,17 +3,42 @@
   
     
     
-    States Mermaid Quick Test Page
+    Sankey Mermaid Quick Test Page
     
   
 
   
     

Sankey diagram demos

FY20-21 Performance

-
+
+      ---
+      config:
+        sankey:
+          showValues: true
+          prefix: $
+          suffix: B
+          width: 800
+          nodeAlignment: left
+      ---
+      sankey-beta
+        Revenue,Expenses,10
+        Revenue,Profit,10
+        Expenses,Manufacturing,5
+        Expenses,Tax,3
+        Expenses,Research,2
+    

Energy flow

+      ---
+      config:
+        sankey:
+          showValues: false
+          width: 1200
+          height: 600
+          linkColor: gradient
+          nodeAlignment: justify
+      ---
       sankey-beta
 
       Agricultural 'waste',Bio-conversion,124.729
@@ -92,37 +117,8 @@
         theme: 'default',
         logLevel: 3,
         securityLevel: 'loose',
-        sankey: {
-          title: 'Hey, this is Sankey-Beta',
-          width: 1200,
-          height: 600,
-          linkColor: 'gradient',
-          nodeAlignment: 'justify',
-          showValues: false,
-        },
-        startOnLoad: false,
+        startOnLoad: true,
       });
-      // Render the Energy flow diagram
-      await mermaid.run();
-
-      mermaid.initialize({
-        sankey: {
-          prefix: '$',
-          suffix: 'B',
-        },
-      });
-
-      const { svg } = await mermaid.render(
-        'ff',
-        `
-sankey-beta
-Revenue,Expenses,10
-Revenue,Profit,10
-Expenses,Manufacturing,5
-Expenses,Tax,3
-Expenses,Research,2`
-      );
-      document.getElementById('financials').innerHTML = svg;
     
   
 

From cee2a458f172bd28b73cb4969d1097cb1f0a308b Mon Sep 17 00:00:00 2001
From: Nikolay Rozhkov 
Date: Wed, 23 Aug 2023 00:23:14 +0300
Subject: [PATCH 07/31] Fixed docs according review

Update docs
---
 docs/community/docker-development.md              |  6 +++---
 docs/community/documentation.md                   |  7 +++----
 ...uggestions.md => questions-and-suggestions.md} |  4 +---
 docs/intro/index.md                               | 15 ++++++++++++---
 packages/mermaid/src/docs/.vitepress/config.ts    |  2 +-
 .../mermaid/src/docs/.vitepress/theme/redirect.ts |  2 +-
 .../src/docs/community/docker-development.md      |  6 +++---
 .../mermaid/src/docs/community/documentation.md   |  7 +++----
 ...uggestions.md => questions-and-suggestions.md} |  2 --
 packages/mermaid/src/docs/intro/index.md          | 15 ++++++++++++---
 10 files changed, 39 insertions(+), 27 deletions(-)
 rename docs/community/{questionsAndSuggestions.md => questions-and-suggestions.md} (88%)
 rename packages/mermaid/src/docs/community/{questionsAndSuggestions.md => questions-and-suggestions.md} (96%)

diff --git a/docs/community/docker-development.md b/docs/community/docker-development.md
index 4b206408c..42189a88e 100644
--- a/docs/community/docker-development.md
+++ b/docs/community/docker-development.md
@@ -34,14 +34,14 @@ Then you **clone** a copy to your local development machine (e.g. where you code
 
 [Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need.
 
-Optionally, to run GUI (Cypress) within Docker you will also need X11 server installed.
-Maybe you already have it installed, so check it first:
+Optionally, to run GUI (Cypress) within Docker you will also need an X11 server installed.
+You might already have it installed, so check this by running:
 
 ```bash
 echo $DISPLAY
 ```
 
-If variable `$DISPLAY` is not empty, then it must be working. Otherwise install it.
+If the `$DISPLAY` variable is not empty, then an X11 server is running. Otherwise you may need to install one.
 
 ## Setup and Launch
 
diff --git a/docs/community/documentation.md b/docs/community/documentation.md
index b4f19597a..67d35d395 100644
--- a/docs/community/documentation.md
+++ b/docs/community/documentation.md
@@ -42,7 +42,7 @@ flowchart LR
 You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box.
 Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly.
 
-````
+````markdown
 ```note
 Note content
 ```
@@ -58,11 +58,10 @@ Warning content
 ```danger
 Danger content
 ```
-
 ````
 
 > **Note**
-> If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch.
+> If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. In that case, your branch should be based on master, not develop.
 
 We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs).
 
@@ -87,7 +86,7 @@ _\[TODO: need to keep this in sync with [check out a git branch in Contributing
 2.  Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory.
 3.  Make changes or add new documentation.
 4.  Commit changes to your branch and push it to GitHub (which should create a new branch).
-5.  Create a Pull Request of your fork.
+5.  Create a Pull Request from the branch of your fork.
 
 To edit Docs on GitHub:
 
diff --git a/docs/community/questionsAndSuggestions.md b/docs/community/questions-and-suggestions.md
similarity index 88%
rename from docs/community/questionsAndSuggestions.md
rename to docs/community/questions-and-suggestions.md
index 28b107d1f..23d6de50f 100644
--- a/docs/community/questionsAndSuggestions.md
+++ b/docs/community/questions-and-suggestions.md
@@ -2,7 +2,7 @@
 >
 > ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
 >
-> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/questionsAndSuggestions.md](../../packages/mermaid/src/docs/community/questionsAndSuggestions.md).
+> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/questions-and-suggestions.md](../../packages/mermaid/src/docs/community/questions-and-suggestions.md).
 
 # Questions or Suggestions?
 
@@ -24,5 +24,3 @@ Feel free to add to the discussion on the issue or topic.
 If you can't find anything that already addresses your question or suggestion, _open a new issue:_
 
 Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22).
-
-## How to Contribute a Suggestion
diff --git a/docs/intro/index.md b/docs/intro/index.md
index b77dd454f..0197d7950 100644
--- a/docs/intro/index.md
+++ b/docs/intro/index.md
@@ -16,7 +16,14 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-ins
 
 
-[![Build CI Status](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml/badge.svg)](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) [![npm minified gzipped bundle size](https://img.shields.io/bundlephobia/minzip/mermaid)](https://bundlephobia.com/package/mermaid) [![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) [![NPM](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) [![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [![Twitter Follow](https://img.shields.io/twitter/follow/mermaidjs_?style=social)](https://twitter.com/mermaidjs_) +[![Build CI Status](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml/badge.svg)](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) +[![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) +[![npm minified gzipped bundle size](https://img.shields.io/bundlephobia/minzip/mermaid)](https://bundlephobia.com/package/mermaid) +[![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) +[![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) +[![NPM](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) +[![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[![Twitter Follow](https://img.shields.io/twitter/follow/mermaidjs_?style=social)](https://twitter.com/mermaidjs_)
@@ -322,7 +329,6 @@ To Deploy Mermaid: - [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) - [Mermaid Webpack Demo](https://github.com/mermaidjs/mermaid-webpack-demo) - [Mermaid Parcel Demo](https://github.com/mermaidjs/mermaid-parcel-demo) -- [HTTP Server](https://github.com/TomWright/mermaid-server) ## Request for Assistance @@ -343,7 +349,9 @@ Don't hesitate to contact me if you want to get involved!
-[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) +[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) +[![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) +[![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors)
@@ -428,6 +436,7 @@ _Mermaid was created by Knut Sveidqvist for easier documentation._ .badges > p { display: flex; } + .badges > p > a { margin: 0 0.5rem; } diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index f86da0490..d787fe6ea 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -196,7 +196,7 @@ function sidebarCommunity() { { text: 'Contributing to Mermaid', link: '/community/development' }, { text: 'Contributing Code', link: '/community/code' }, { text: 'Contributing Documentation', link: '/community/documentation' }, - { text: 'Questions and Suggestions', link: '/community/questionsAndSuggestions' }, + { text: 'Questions and Suggestions', link: '/community/questions-and-suggestions' }, { text: 'Adding Diagrams', link: '/community/newDiagram' }, { text: 'Security', link: '/community/security' }, ], diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts index da4326be7..951ee5371 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts @@ -49,7 +49,7 @@ const idRedirectMap: Record = { 'more-pages': '', 'n00b-advanced': 'config/n00b-advanced', 'n00b-gettingstarted': 'intro/n00b-gettingStarted', - 'n00b-overview': 'community/n00b-overview', + 'n00b-overview': 'intro/n00b-gettingStarted', 'community/n00b-overview': 'intro/n00b-gettingStarted', 'n00b-syntaxreference': 'intro/n00b-syntaxReference', newdiagram: 'community/newDiagram', diff --git a/packages/mermaid/src/docs/community/docker-development.md b/packages/mermaid/src/docs/community/docker-development.md index f3fb41391..33cd6a201 100644 --- a/packages/mermaid/src/docs/community/docker-development.md +++ b/packages/mermaid/src/docs/community/docker-development.md @@ -28,14 +28,14 @@ Then you **clone** a copy to your local development machine (e.g. where you code [Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need. -Optionally, to run GUI (Cypress) within Docker you will also need X11 server installed. -Maybe you already have it installed, so check it first: +Optionally, to run GUI (Cypress) within Docker you will also need an X11 server installed. +You might already have it installed, so check this by running: ```bash echo $DISPLAY ``` -If variable `$DISPLAY` is not empty, then it must be working. Otherwise install it. +If the `$DISPLAY` variable is not empty, then an X11 server is running. Otherwise you may need to install one. ## Setup and Launch diff --git a/packages/mermaid/src/docs/community/documentation.md b/packages/mermaid/src/docs/community/documentation.md index 79a984376..6a0df983d 100644 --- a/packages/mermaid/src/docs/community/documentation.md +++ b/packages/mermaid/src/docs/community/documentation.md @@ -28,7 +28,7 @@ flowchart LR You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. -```` +````markdown ```note Note content ``` @@ -44,11 +44,10 @@ Warning content ```danger Danger content ``` - ```` ```note -If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. +If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. In that case, your branch should be based on master, not develop. ``` We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). @@ -74,7 +73,7 @@ _[TODO: need to keep this in sync with [check out a git branch in Contributing C 2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. 3. Make changes or add new documentation. 4. Commit changes to your branch and push it to GitHub (which should create a new branch). -5. Create a Pull Request of your fork. +5. Create a Pull Request from the branch of your fork. To edit Docs on GitHub: diff --git a/packages/mermaid/src/docs/community/questionsAndSuggestions.md b/packages/mermaid/src/docs/community/questions-and-suggestions.md similarity index 96% rename from packages/mermaid/src/docs/community/questionsAndSuggestions.md rename to packages/mermaid/src/docs/community/questions-and-suggestions.md index f72d0a47d..6d6f80fb6 100644 --- a/packages/mermaid/src/docs/community/questionsAndSuggestions.md +++ b/packages/mermaid/src/docs/community/questions-and-suggestions.md @@ -18,5 +18,3 @@ Feel free to add to the discussion on the issue or topic. If you can't find anything that already addresses your question or suggestion, _open a new issue:_ Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). - -## How to Contribute a Suggestion diff --git a/packages/mermaid/src/docs/intro/index.md b/packages/mermaid/src/docs/intro/index.md index c76f09a08..8410ef1cb 100644 --- a/packages/mermaid/src/docs/intro/index.md +++ b/packages/mermaid/src/docs/intro/index.md @@ -10,7 +10,14 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-ins
-[![Build CI Status](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml/badge.svg)](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) [![npm minified gzipped bundle size](https://img.shields.io/bundlephobia/minzip/mermaid)](https://bundlephobia.com/package/mermaid) [![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) [![NPM](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) [![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [![Twitter Follow](https://img.shields.io/twitter/follow/mermaidjs_?style=social)](https://twitter.com/mermaidjs_) +[![Build CI Status](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml/badge.svg)](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) +[![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) +[![npm minified gzipped bundle size](https://img.shields.io/bundlephobia/minzip/mermaid)](https://bundlephobia.com/package/mermaid) +[![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) +[![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) +[![NPM](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) +[![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[![Twitter Follow](https://img.shields.io/twitter/follow/mermaidjs_?style=social)](https://twitter.com/mermaidjs_)
@@ -99,7 +106,6 @@ To Deploy Mermaid: - [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) - [Mermaid Webpack Demo](https://github.com/mermaidjs/mermaid-webpack-demo) - [Mermaid Parcel Demo](https://github.com/mermaidjs/mermaid-parcel-demo) -- [HTTP Server](https://github.com/TomWright/mermaid-server) ## Request for Assistance @@ -120,7 +126,9 @@ Don't hesitate to contact me if you want to get involved!
-[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) +[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) +[![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) +[![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors)
@@ -205,6 +213,7 @@ _Mermaid was created by Knut Sveidqvist for easier documentation._ .badges > p { display: flex; } + .badges > p > a { margin: 0 0.5rem; } From 108c25f19f72fad9f3e20551435439b18aac9267 Mon Sep 17 00:00:00 2001 From: Nikolay Rozhkov Date: Wed, 23 Aug 2023 23:32:33 +0300 Subject: [PATCH 08/31] Removed all n00b file names and added redirects --- docker-compose.yml | 2 +- packages/mermaid/src/docs/.vitepress/config.ts | 6 +++--- .../src/docs/.vitepress/theme/redirect.spec.ts | 4 ++-- .../mermaid/src/docs/.vitepress/theme/redirect.ts | 15 +++++++++------ packages/mermaid/src/docs/config/Tutorials.md | 2 +- .../docs/config/{n00b-advanced.md => advanced.md} | 2 +- packages/mermaid/src/docs/config/usage.md | 2 +- ...{n00b-gettingStarted.md => getting-started.md} | 4 ++-- packages/mermaid/src/docs/intro/index.md | 8 ++++---- ...00b-syntaxReference.md => syntax-reference.md} | 6 +++--- pnpm-lock.yaml | 2 +- 11 files changed, 28 insertions(+), 25 deletions(-) rename packages/mermaid/src/docs/config/{n00b-advanced.md => advanced.md} (90%) rename packages/mermaid/src/docs/intro/{n00b-gettingStarted.md => getting-started.md} (96%) rename packages/mermaid/src/docs/intro/{n00b-syntaxReference.md => syntax-reference.md} (95%) diff --git a/docker-compose.yml b/docker-compose.yml index 2480311a2..5ee31964d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: working_dir: /mermaid mem_limit: '2G' environment: - - NODE_OPTIONS=--max_old_space_size=2048 + - NODE_OPTIONS=--max_old_space_size=4096 volumes: - ./:/mermaid - root_cache:/root/.cache diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index d787fe6ea..ede064fa4 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -109,8 +109,8 @@ function sidebarAll() { collapsed: false, items: [ { text: 'About Mermaid', link: '/intro/' }, - { text: 'Getting Started', link: '/intro/n00b-gettingStarted' }, - { text: 'Syntax and Configuration', link: '/intro/n00b-syntaxReference' }, + { text: 'Getting Started', link: '/intro/getting-started' }, + { text: 'Syntax and Configuration', link: '/intro/syntax-reference' }, ], }, ...sidebarSyntax(), @@ -167,7 +167,7 @@ function sidebarConfig() { { text: 'Theming', link: '/config/theming' }, { text: 'Accessibility', link: '/config/accessibility' }, { text: 'Mermaid CLI', link: '/config/mermaidCLI' }, - { text: 'Advanced usage', link: '/config/n00b-advanced' }, + { text: 'Advanced usage', link: '/config/advanced' }, { text: 'FAQ', link: '/config/faq' }, ], }, diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts index 3d88913d1..b78f63990 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts @@ -19,8 +19,8 @@ test.each([ 'https://mermaid-js.github.io/mermaid/#/flowchart?another=test&id=my-id&one=more', // with multiple params 'syntax/flowchart.html#my-id', ], - ['https://mermaid-js.github.io/mermaid/#/n00b-advanced', 'config/n00b-advanced.html'], // without .md - ['https://mermaid-js.github.io/mermaid/#/n00b-advanced.md', 'config/n00b-advanced.html'], // with .md + ['https://mermaid-js.github.io/mermaid/#/n00b-advanced', 'config/advanced.html'], // without .md + ['https://mermaid-js.github.io/mermaid/#/n00b-advanced.md', 'config/advanced.html'], // with .md [ 'https://mermaid-js.github.io/mermaid/#/flowchart?id=a-node-in-the-form-of-a-circle', // with id, without .md 'syntax/flowchart.html#a-node-in-the-form-of-a-circle', diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts index 8d576fece..98009ca6d 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts @@ -50,15 +50,18 @@ const idRedirectMap: Record = { mermaidcli: 'config/mermaidCLI', mindmap: 'syntax/mindmap', 'more-pages': '', - 'n00b-advanced': 'config/n00b-advanced', - 'n00b-gettingstarted': 'intro/n00b-gettingStarted', - 'n00b-overview': 'intro/n00b-gettingStarted', - 'community/n00b-overview': 'intro/n00b-gettingStarted', - 'n00b-syntaxreference': 'intro/n00b-syntaxReference', + 'n00b-advanced': 'config/advanced', + 'config/n00b-advanced': 'config/advanced', + 'n00b-gettingstarted': 'intro/getting-started', + 'intro/n00b-gettingStarted': 'intro/getting-started', + 'n00b-overview': 'intro/getting-started', + 'n00b-syntaxreference': 'intro/syntax-reference', + 'intro/n00b-syntaxReference': 'intro/syntax-reference', + 'community/n00b-overview': 'intro/getting-started', newdiagram: 'community/newDiagram', pie: 'syntax/pie', plugins: '', - quickstart: 'intro/n00b-gettingStarted', + quickstart: 'intro/getting-started', requirementdiagram: 'syntax/requirementDiagram', security: 'community/security', sequencediagram: 'syntax/sequenceDiagram', diff --git a/packages/mermaid/src/docs/config/Tutorials.md b/packages/mermaid/src/docs/config/Tutorials.md index c6db9dacf..af7dbe672 100644 --- a/packages/mermaid/src/docs/config/Tutorials.md +++ b/packages/mermaid/src/docs/config/Tutorials.md @@ -26,7 +26,7 @@ The definitions that can be generated the Live-Editor are also backwards-compati ## Mermaid with HTML -Examples are provided in [Getting Started](../intro/n00b-gettingStarted.md) +Examples are provided in [Getting Started](../intro/getting-started.md) **CodePen Examples:** diff --git a/packages/mermaid/src/docs/config/n00b-advanced.md b/packages/mermaid/src/docs/config/advanced.md similarity index 90% rename from packages/mermaid/src/docs/config/n00b-advanced.md rename to packages/mermaid/src/docs/config/advanced.md index 2932faa48..4ab477428 100644 --- a/packages/mermaid/src/docs/config/n00b-advanced.md +++ b/packages/mermaid/src/docs/config/advanced.md @@ -1,4 +1,4 @@ -# Advanced n00b mermaid (Coming soon..) +# Advanced mermaid (Coming soon..) ## splitting mermaid code from html diff --git a/packages/mermaid/src/docs/config/usage.md b/packages/mermaid/src/docs/config/usage.md index 740b3509b..7f3a04caa 100644 --- a/packages/mermaid/src/docs/config/usage.md +++ b/packages/mermaid/src/docs/config/usage.md @@ -35,7 +35,7 @@ pnpm add mermaid **Hosting mermaid on a web page:** -> Note:This topic explored in greater depth in the [User Guide for Beginners](../intro/n00b-gettingStarted.md) +> Note:This topic explored in greater depth in the [User Guide for Beginners](../intro/getting-started.md) The easiest way to integrate mermaid on a web page requires two elements: diff --git a/packages/mermaid/src/docs/intro/n00b-gettingStarted.md b/packages/mermaid/src/docs/intro/getting-started.md similarity index 96% rename from packages/mermaid/src/docs/intro/n00b-gettingStarted.md rename to packages/mermaid/src/docs/intro/getting-started.md index fcb3f31ee..47ffa7291 100644 --- a/packages/mermaid/src/docs/intro/n00b-gettingStarted.md +++ b/packages/mermaid/src/docs/intro/getting-started.md @@ -2,7 +2,7 @@ Mermaid is composed of three parts: Deployment, Syntax and Configuration. -This section talks about the different ways to deploy Mermaid. Learning the [Syntax](n00b-syntaxReference.md) would be of great help to the beginner. +This section talks about the different ways to deploy Mermaid. Learning the [Syntax](syntax-reference.md) would be of great help to the beginner. > Generally the live editor is enough for most general uses of mermaid, and is a good place to start learning. @@ -36,7 +36,7 @@ graph TD In the `Code` section one can write or edit raw mermaid code, and instantly `Preview` the rendered result on the panel beside it. -The `Configuration` Section is for changing the appearance and behavior of mermaid diagrams. An easy introduction to mermaid configuration is found in the [Advanced usage](../config/n00b-advanced.md) section. A complete configuration reference cataloging the default values can be found on the [mermaidAPI](../config/setup/README.md) page. +The `Configuration` Section is for changing the appearance and behavior of mermaid diagrams. An easy introduction to mermaid configuration is found in the [Advanced usage](../config/advanced.md) section. A complete configuration reference cataloging the default values can be found on the [mermaidAPI](../config/setup/README.md) page. ![Code,Config and Preview](./img/Code-Preview-Config.png) diff --git a/packages/mermaid/src/docs/intro/index.md b/packages/mermaid/src/docs/intro/index.md index 8410ef1cb..554db5a12 100644 --- a/packages/mermaid/src/docs/intro/index.md +++ b/packages/mermaid/src/docs/intro/index.md @@ -4,7 +4,7 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically. -> If you are familiar with Markdown you should have no problem learning [Mermaid's Syntax](n00b-syntaxReference.md). +> If you are familiar with Markdown you should have no problem learning [Mermaid's Syntax](syntax-reference.md). @@ -39,7 +39,7 @@ Mermaid allows even non-programmers to easily create detailed and diagrams throu [Tutorials](../config/Tutorials.md) has video tutorials. Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](../ecosystem/integrations.md). -For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../intro/n00b-gettingStarted.md) and [Usage](../config/usage.md). +For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../intro/getting-started.md) and [Usage](../config/usage.md). 🌐 [CDN](https://www.jsdelivr.com/package/npm/mermaid) | 📖 [Documentation](https://mermaidjs.github.io) | 🙌 [Contribution](../community/development.md) | 🔌 [Plug-Ins](../ecosystem/integrations.md) @@ -59,9 +59,9 @@ In our release process we rely heavily on visual regression tests using [applito ## Installation -**In depth guides and examples can be found at [Getting Started](./n00b-gettingStarted.md) and [Usage](../config/usage.md).** +**In depth guides and examples can be found at [Getting Started](./getting-started.md) and [Usage](../config/usage.md).** -**It would also be helpful to learn more about mermaid's [Syntax](./n00b-syntaxReference.md).** +**It would also be helpful to learn more about mermaid's [Syntax](./syntax-reference.md).** ### CDN diff --git a/packages/mermaid/src/docs/intro/n00b-syntaxReference.md b/packages/mermaid/src/docs/intro/syntax-reference.md similarity index 95% rename from packages/mermaid/src/docs/intro/n00b-syntaxReference.md rename to packages/mermaid/src/docs/intro/syntax-reference.md index 398f83257..51f25be35 100644 --- a/packages/mermaid/src/docs/intro/n00b-syntaxReference.md +++ b/packages/mermaid/src/docs/intro/syntax-reference.md @@ -24,7 +24,7 @@ erDiagram PRODUCT ||--o{ ORDER-ITEM : "ordered in" ``` -The [Getting Started](./n00b-gettingStarted.md) section can also provide some practical examples of mermaid syntax. +The [Getting Started](./getting-started.md) section can also provide some practical examples of mermaid syntax. ## Diagram Breaking @@ -48,13 +48,13 @@ Configuration is the third part of Mermaid, after deployment and syntax. It deal If you are interested in altering and customizing your Mermaid Diagrams, you will find the methods and values available for [Configuration](../config/setup/README.md) here. It includes themes. This section will introduce the different methods of configuring the behaviors and appearances of Mermaid Diagrams. -The following are the most commonly used methods, and they are all tied to Mermaid [Deployment](./n00b-gettingStarted.md) methods. +The following are the most commonly used methods, and they are all tied to Mermaid [Deployment](./getting-started.md) methods. ### Configuration Section in the [Live Editor](https://mermaid.live). Here you can edit certain values to change the behavior and appearance of the diagram. -### [The initialize() call](https://mermaid-js.github.io/mermaid/#/n00b-gettingStarted?id=_3-calling-the-javascript-api), +### [The initialize() call](https://mermaid-js.github.io/mermaid/#/getting-started?id=_3-calling-the-javascript-api), Used when Mermaid is called via an API, or through a `