diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6c01ba1b98..f09d047fc0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,11 +41,9 @@ jobs: run: | pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts - - name: Upload Coverage to Coveralls - # it feels a bit weird to use @master, but that's what the docs use - # (coveralls also doesn't publish a @v1 we can use) - # https://github.com/marketplace/actions/coveralls-github-action - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - flag-name: unit + # Coveralls is throwing 500. Disabled for now. + # - name: Upload Coverage to Coveralls + # uses: coverallsapp/github-action@v2 + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # flag-name: unit diff --git a/.gitignore b/.gitignore index efbfc8b366..8348f4ae4f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,10 @@ node_modules/ coverage/ .idea/ +.pnpm-store/ dist +v8-compile-cache-0 yarn-error.log .npmrc @@ -39,3 +41,4 @@ stats/ **/user-avatars/* **/contributor-names.json +.pnpm-store diff --git a/.lycheeignore b/.lycheeignore index 5f7b9679e7..d22d3cb153 100644 --- a/.lycheeignore +++ b/.lycheeignore @@ -9,3 +9,9 @@ https://twitter.com/mermaidjs_ # Don't check files that are generated during the build via `pnpm docs:code` packages/mermaid/src/docs/config/setup/* + +# Ignore localhost +http://localhost:3333/ + +# Ignore slack invite +https://join.slack.com/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 150a223416..e8ac09325e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,10 @@ # Contributing -So you want to help? That's great! +Please read in detail about how to contribute documentation and code on the [Mermaid documentation site.](https://mermaid-js.github.io/mermaid/#/development) -![Happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif) +--- -Here are a few things to know to get you started on the right path. - -Below link will help you making a copy of the repository in your local system. - -https://docs.github.com/en/get-started/quickstart/fork-a-repo +# Mermaid contribution cheat-sheet ## Requirements @@ -18,163 +14,58 @@ https://docs.github.com/en/get-started/quickstart/fork-a-repo ## Development Installation +If you don't have direct access to push to mermaid repositories, make a fork first. Then clone. Or clone directly from mermaid-js: + ```bash git clone git@github.com:mermaid-js/mermaid.git cd mermaid -# npx is required for first install as volta support for pnpm is not added yet. -npx pnpm install -pnpm test ``` -## Committing code - -We make all changes via pull requests. As we have many pull requests from developers new to mermaid, the current approach is to have _knsv, Knut Sveidqvist_ as a main reviewer of changes and merging pull requests. More precisely like this: - -- Large changes reviewed by knsv or other developer asked to review by knsv -- Smaller low-risk changes like dependencies, documentation, etc. can be merged by active collaborators -- Documentation (updates to the `package/mermaid/src/docs` folder is also allowed via direct commits) - -To commit code, create a branch, let it start with the type like feature or bug followed by the issue number for reference and some describing text. - -One example: - -`feature/945_state_diagrams` - -Another: - -`bug/123_nasty_bug_branch` - -## Committing documentation - -Less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. - -The documentation is written in **Markdown**. 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). +Install required packages: -### Documentation source files are in [`/packages/mermaid/src/docs`](packages/mermaid/src/docs) - -The source files for the project documentation are located in the [`/packages/mermaid/src/docs`](packages/mermaid/src/docs) directory. This is where you should make changes. -The files under `/packages/mermaid/src/docs` are processed to generate the published documentation, and the resulting files are put into the `/docs` directory. - -After editing files in the [`/packages/mermaid/src/docs`](packages/mermaid/src/docs) directory, be sure to run `pnpm install` and `pnpm run --filter mermaid docs:build` locally to build the `/docs` directory. - -```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 +```bash +# npx is required for first install as volta support for pnpm is not added yet. +npx pnpm install +pnpm test ``` -```` - -**_DO NOT CHANGE FILES IN `/docs`_** - -### The official documentation site +### Docker -**[The mermaid documentation site](https://mermaid-js.github.io/mermaid/) is powered by [Vitepress](https://vitepress.vuejs.org/), a simple documentation site generator.** +If you are using docker and docker-compose, you have self-documented `run` bash script, which is a convenient alias for docker-compose commands: -If you want to preview the whole documentation site on your machine: - -```sh -cd packages/mermaid -pnpm i -pnpm docs:dev +```bash +./run install # npx pnpm install +./run test # pnpm test ``` -You can now build and serve the documentation site: +## Testing -```sh -pnpm docs:serve +```bash +# Run unit test +pnpm test +# Run unit test in watch mode +pnpm test:watch +# Run E2E test +pnpm e2e +# Debug E2E tests +pnpm dev +pnpm cypress:open # in another terminal ``` -## Branching - -Going forward we will use a git flow inspired approach to branching. So development is done in develop, to do the development in the develop. - -Once development is done we branch a release branch from develop for testing. - -Once the release happens we merge the release branch to master and kill the release branch. - -This means... **branch off your pull request from develop** - -## Content of a pull request +## Branch name format: -A new feature has been born. Great! But without the steps below it might just ... fade away ... - -### **Add unit tests for the parsing part** - -This is important so that, if someone else does a change to the grammar that does not know about this great feature, gets notified early on when that change breaks the parser. Another important aspect is that without proper parsing tests refactoring is pretty much impossible. - -### **Add e2e tests** - -This tests the rendering and visual appearance of the diagram. 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, run `pnpm run dev` to start the dev server, after that start cypress by running `pnpm exec cypress open` in the mermaid folder. - -The rendering tests are very straightforward to create. There is a function imgSnapshotTest. This function takes a diagram in text form, the mermaid options and 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 for review it if it differs. - -This is what a rendering test looks like: - -```javascript -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'); -}); +```text + [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] ``` -### **Add documentation for it** - -Finally, if it is not in the documentation, no one will know about it and then **no one will use it**. Wouldn't that be sad? With all the effort that was put into the feature? - -The source files for documentation are in `/packages/mermaid/src/docs` and are written in markdown. Just pick the right section and start typing. See the [Committing Documentation](#committing-documentation) section for more about how the documentation is generated. +eg: `feature/2945_state-diagram-new-arrow-florbs`, `bug/1123_fix_random_ugly_red_text` -#### Adding to or changing the documentation organization +## Documentation -If you want to add a new section or change the organization (structure), then you need to make sure to **change the side navigation** in `mermaid/src/docs/.vitepress/config.js`. +Documentation is necessary for all non bugfix/refactoring changes. -When changes are committed and then released, they become part of the `master` branch and become part of the published documentation on https://mermaid-js.github.io/mermaid/ +Only make changes to files are in [`/packages/mermaid/src/docs`](packages/mermaid/src/docs) -## 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. +**_DO NOT CHANGE FILES IN `/docs`_** [Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) - -![A superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif) diff --git a/cSpell.json b/cSpell.json index 8be55333ba..ff9ef10743 100644 --- a/cSpell.json +++ b/cSpell.json @@ -129,6 +129,7 @@ "ugge", "unist", "unocss", + "upvoting", "valign", "verdana", "viewports", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..2762f3b99f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3.9' +services: + mermaid: + image: node:18.16.0-alpine3.18 + stdin_open: true + tty: true + working_dir: /mermaid + volumes: + - ./:/mermaid diff --git a/docs/community/development.md b/docs/community/development.md index 58ca4670bc..90f728e152 100644 --- a/docs/community/development.md +++ b/docs/community/development.md @@ -4,7 +4,17 @@ > > ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/development.md](../../packages/mermaid/src/docs/community/development.md). -# Development and Contribution 🙌 +# 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) + +--- So you want to help? That's great! @@ -12,72 +22,167 @@ So you want to help? That's great! Here are a few things to get you started on the right path. -**The Docs Structure is dictated by [.vitepress/config.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/.vitepress/config.ts)**. +## Technical Requirements and Setup + +### Technical Requirements + +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) + +Follow [the setup steps below](#setup) to install them and verify they are working + +### Setup + +Follow these steps to set up the environment you need to work on code and/or documentation. + +#### 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) -**Note: Commits and Pull Requests should be directed to the develop branch.** +#### 2. Install pnpm -## Branching +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. -Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. So development is done in the `develop` branch. +Ex: -Once development is done we branch a `release` branch from `develop` for testing. +```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 + +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: + +```bash +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.) -Once the release happens we merge the `release` branch with `master` and kill the `release` branch. +### Docker -This means that **you should branch off your pull request from develop** and direct all Pull Requests to it. +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 -We make all changes via Pull Requests. As we have many Pull Requests from developers new to mermaid, we have put in place a process, wherein _knsv, Knut Sveidqvist_ is the primary reviewer of changes and merging pull requests. The process is as follows: +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] +``` -- Large changes reviewed by knsv or other developer asked to review by knsv -- Smaller, low-risk changes like dependencies, documentation, etc. can be merged by active collaborators -- Documentation (we encourage updates to the `/packages/mermaid/src/docs` folder; you can submit them via direct commits) +```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] +``` -When you commit code, create a branch with the following naming convention: +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. -Start with the type, such as **feature** or **bug**, followed by the issue number for reference, and a text that describes the issue. +### 1. Checkout a git branch -**One example:** +Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. -`feature/945_state_diagrams` +Development is done in the `develop` branch. -**Another example:** +Once development is done we create a `release/vX.X.X` branch from `develop` for testing. -`bug/123_nasty_bug_branch` +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. -## Contributing to Documentation +**All new work should be based on the `develop` branch.** -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? +**When you are ready to do work, always, ALWAYS:** -The docs are located in the `src/docs` folder and are written in Markdown. Just pick the right section and start typing. If you want to propose changes to the structure of the documentation, such as adding a new section or a new file you do that via **[.vitepress/config.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/.vitepress/config.ts)**. +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. -> **All the documents displayed in the GitHub.io page are listed in [.vitepress/config.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/.vitepress/config.ts)**. +We use the follow naming convention for branches: -The contents of are based on the docs from the `master` branch. Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid-js.github.io/mermaid/) once released. +```text + [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] +``` -## How to Contribute to Documentation +- 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) -We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. +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.) -The documentation is located in the `src/docs` directory and organized according to relevant subfolder. +We use [Vitest](https://vitest.dev) to run unit tests. -The `docs` folder will be automatically generated when committing to `src/docs` and should not be edited manually. +You can use the following command to run the unit tests: -We encourage contributions to the documentation at [mermaid-js/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). We publish documentation using GitHub Pages with [Docsify](https://www.youtube.com/watch?v=TV88lp7egMw&t=3s) +```sh +pnpm test +``` -### Add Unit Tests for Parsing +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: -This is important so that, if someone that does not know about this great feature suggests a change to the grammar, they get notified early on when that change breaks the parser. Another important aspect is that, without proper parsing, tests refactoring is pretty much impossible. +```sh +pnpm test:watch +``` -### Add E2E Tests +#### Integration/End-to-End (e2e) tests -This tests 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! +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 run dev` to start the dev server -2. Start **Cypress** by running `pnpm exec cypress open` in the **mermaid** folder. +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. @@ -107,30 +212,162 @@ it('should render forks and joins', () => { }); ``` -### Any Questions or Suggestions? +**_\[TODO - running the tests against what is expected in development. ]_** -After logging in at [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). +**_\[TODO - how to generate new screenshots]_** +.... -### How to Contribute a Suggestion +### 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! + +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: -1. Find the Markdown file (.md) to edit in the [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) directory in the `develop` branch. -2. Create a fork of the develop branch. +_\[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 fork and push it to GitHub. +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). +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. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. +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 ## Last Words diff --git a/docs/community/n00b-overview.md b/docs/community/n00b-overview.md index e0056d9123..afb110e9ec 100644 --- a/docs/community/n00b-overview.md +++ b/docs/community/n00b-overview.md @@ -69,6 +69,6 @@ In fact one can pick up the syntax for it quite easily from the examples given a ## Mermaid is for everyone. -Video [Tutorials](https://mermaid-js.github.io/mermaid/#/../config/Tutorials) are also available for the mermaid [live editor](https://mermaid.live/). +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/config/directives.md b/docs/config/directives.md index e845596ad5..27fd767c75 100644 --- a/docs/config/directives.md +++ b/docs/config/directives.md @@ -8,11 +8,11 @@ ## Directives -Directives gives a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration. +Directives give a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration. -The significance of having directives is that you have them available while writing the diagram, and can modify the default global and diagram specific configurations. So, directives are applied on top of the default configurations. The beauty of directives is that you can use them to alter configuration settings for a specific diagram, i.e. at an individual level. +The significance of having directives is that you have them available while writing the diagram, and can modify the default global and diagram-specific configurations. So, directives are applied on top of the default configuration. The beauty of directives is that you can use them to alter configuration settings for a specific diagram, i.e. at an individual level. -While directives allow you to change most of the default configuration settings, there are some that are not available, that too for security reasons. Also, you do have the _option to define the set of configurations_ that you would allow to be available to the diagram author for overriding with help of directives. +While directives allow you to change most of the default configuration settings, there are some that are not available, for security reasons. Also, you have the _option to define the set of configurations_ that you wish to allow diagram authors to override with directives. ## Types of Directives options @@ -20,29 +20,29 @@ Mermaid basically supports two types of configuration options to be overridden b 1. _General/Top Level configurations_ : These are the configurations that are available and applied to all the diagram. **Some of the most important top-level** configurations are: -- theme -- fontFamily -- logLevel -- securityLevel -- startOnLoad -- secure + - theme + - fontFamily + - logLevel + - securityLevel + - startOnLoad + - secure -2. _Diagram specific configurations_ : These are the configurations that are available and applied to a specific diagram. For each diagram there are specific configuration that will alter how that particular diagram looks and behaves. - For example, `mirrorActors` is a configuration that is specific to the `SequenceDiagram` and alter whether the actors are mirrored or not. So this config is available only for the `SequenceDiagram` type. +2. _Diagram-specific configurations_ : These are the configurations that are available and applied to a specific diagram. For each diagram there are specific configuration that will alter how that particular diagram looks and behaves. + For example, `mirrorActors` is a configuration that is specific to the `SequenceDiagram` and alters whether the actors are mirrored or not. So this config is available only for the `SequenceDiagram` type. -**NOTE:** These options listed here are not all the configuration options. To get hold of all the configuration options, please refer to the [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. +**NOTE:** Not all configuration options are listed here. To get hold of all the configuration options, please refer to the [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. > **Note** -> We plan to publish a complete list of top-level configurations & all the diagram specific configurations, with their possible values in the docs soon. +> We plan to publish a complete list of top-level configurations & diagram-specific configurations with their possible values in the docs soon. ## Declaring directives Now that we have defined the types of configurations that are available, we can learn how to declare directives. -A directive always starts and end `%%` sign with directive text in between, like `%% {directive_text} %%`. +A directive always starts and ends with `%%` signs with directive text in between, like `%% {directive_text} %%`. Here the structure of a directive text is like a nested key-value pair map or a JSON object with root being _init_. Where all the general configurations are defined in the top level, and all the diagram specific configurations are defined one level deeper with diagram type as key/root for that section. -Following code snippet shows the structure of a directive: +The following code snippet shows the structure of a directive: %%{ init: { @@ -61,14 +61,14 @@ Following code snippet shows the structure of a directive: You can also define the directives in a single line, like this: - %%{init: { **insert argument here**}}%% + %%{init: { **insert configuration options here** } }%% For example, the following code snippet: %%{init: { "sequence": { "mirrorActors":false }}}%% **Notes:** -The json object that is passed as {**argument** } must be valid key value pairs and encased in quotation marks or it will be ignored. +The JSON object that is passed as {**argument**} must be valid key value pairs and encased in quotation marks or it will be ignored. Valid Key Value pairs can be found in config. Example with a simple graph: @@ -87,7 +87,7 @@ A-->B Here the directive declaration will set the `logLevel` to `debug` and the `theme` to `dark` for a rendered mermaid diagram, changing the appearance of the diagram itself. -Note: You can use 'init' or 'initialize' as both acceptable as init directives. Also note that `%%init%%` and `%%initialize%%` directives will be grouped together after they are parsed. This means: +Note: You can use 'init' or 'initialize' as both are acceptable as init directives. Also note that `%%init%%` and `%%initialize%%` directives will be grouped together after they are parsed. ```mermaid-example %%{init: { 'logLevel': 'debug', 'theme': 'forest' } }%% @@ -101,7 +101,7 @@ Note: You can use 'init' or 'initialize' as both acceptable as init directives. ... ``` -parsing the above generates a single `%%init%%` JSON object below, combining the two directives and carrying over the last value given for `loglevel`: +For example, parsing the above generates a single `%%init%%` JSON object below, combining the two directives and carrying over the last value given for `loglevel`: ```json { @@ -115,16 +115,15 @@ This will then be sent to `mermaid.initialize(...)` for rendering. ## Directive Examples -More directive examples for diagram specific configuration overrides -Now that the concept of directives has been explained, Let us see some more examples for directives usage: +Now that the concept of directives has been explained, let us see some more examples of directive usage: -### Changing Theme via directive +### Changing theme via directive -The following code snippet changes theme to forest: +The following code snippet changes `theme` to `forest`: `%%{init: { "theme": "forest" } }%%` -Possible themes value are: `default`,`base`, `dark`, `forest` and `neutral`. +Possible theme values are: `default`,`base`, `dark`, `forest` and `neutral`. Default Value is `default`. Example: @@ -155,7 +154,7 @@ A --> C[End] ### Changing fontFamily via directive -The following code snippet changes fontFamily to rebuchet MS, Verdana, Arial, Sans-Serif: +The following code snippet changes fontFamily to Trebuchet MS, Verdana, Arial, Sans-Serif: `%%{init: { "fontFamily": "Trebuchet MS, Verdana, Arial, Sans-Serif" } }%%` @@ -187,11 +186,11 @@ A --> C[End] ### Changing logLevel via directive -The following code snippet changes logLevel to 2: +The following code snippet changes `logLevel` to `2`: `%%{init: { "logLevel": 2 } }%%` -Possible logLevel values are: +Possible `logLevel` values are: - `1` for _debug_, - `2` for _info_ @@ -234,14 +233,14 @@ Some common flowchart configurations are: - _diagramPadding_: number - _useMaxWidth_: number -For complete list of flowchart configurations, see [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. -_Soon we plan to publish a complete list all diagram specific configurations updated in the docs_ +For a complete list of flowchart configurations, see [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. +_Soon we plan to publish a complete list of all diagram-specific configurations updated in the docs._ The following code snippet changes flowchart config: `%%{init: { "flowchart": { "htmlLabels": true, "curve": "linear" } } }%%` -Here were are overriding only the flowchart config, and not the general config, where HtmlLabels is set to true and curve is set to linear. +Here we are overriding only the flowchart config, and not the general config, setting `htmlLabels` to `true` and `curve` to `linear`. ```mermaid-example %%{init: { "flowchart": { "htmlLabels": true, "curve": "linear" } } }%% @@ -267,7 +266,7 @@ A --> C[End] ### Changing Sequence diagram config via directive -Some common sequence configurations are: +Some common sequence diagram configurations are: - _width_: number - _height_: number @@ -278,8 +277,8 @@ Some common sequence configurations are: - _showSequenceNumbers_: boolean - _wrap_: boolean -For complete list of sequence diagram configurations, see _defaultConfig.ts_ in the source code. -_Soon we plan to publish a complete list all diagram specific configurations updated in the docs_ +For a complete list of sequence diagram configurations, see [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. +_Soon we plan to publish a complete list of all diagram-specific configurations updated in the docs._ So, `wrap` by default has a value of `false` for sequence diagrams. @@ -289,7 +288,7 @@ Let us see an example: sequenceDiagram Alice->Bob: Hello Bob, how are you? -Bob->Alice: Fine, How did you mother like the book I suggested? And did you catch with the new book about alien invasion? +Bob->Alice: Fine, how did you mother like the book I suggested? And did you catch the new book about alien invasion? Alice->Bob: Good. Bob->Alice: Cool ``` @@ -298,7 +297,7 @@ Bob->Alice: Cool sequenceDiagram Alice->Bob: Hello Bob, how are you? -Bob->Alice: Fine, How did you mother like the book I suggested? And did you catch with the new book about alien invasion? +Bob->Alice: Fine, how did you mother like the book I suggested? And did you catch the new book about alien invasion? Alice->Bob: Good. Bob->Alice: Cool ``` @@ -309,13 +308,13 @@ The following code snippet changes sequence diagram config for `wrap` to `true`: `%%{init: { "sequence": { "wrap": true} } }%%` -Using in the diagram above, the wrap will be enabled. +By applying that snippet to the diagram above, `wrap` will be enabled: ```mermaid-example %%{init: { "sequence": { "wrap": true, "width":300 } } }%% sequenceDiagram Alice->Bob: Hello Bob, how are you? -Bob->Alice: Fine, How did you mother like the book I suggested? And did you catch with the new book about alien invasion? +Bob->Alice: Fine, how did you mother like the book I suggested? And did you catch the new book about alien invasion? Alice->Bob: Good. Bob->Alice: Cool ``` @@ -324,7 +323,7 @@ Bob->Alice: Cool %%{init: { "sequence": { "wrap": true, "width":300 } } }%% sequenceDiagram Alice->Bob: Hello Bob, how are you? -Bob->Alice: Fine, How did you mother like the book I suggested? And did you catch with the new book about alien invasion? +Bob->Alice: Fine, how did you mother like the book I suggested? And did you catch the new book about alien invasion? Alice->Bob: Good. Bob->Alice: Cool ``` diff --git a/docs/ecosystem/integrations.md b/docs/ecosystem/integrations.md index 24e3609d83..28db3afffb 100644 --- a/docs/ecosystem/integrations.md +++ b/docs/ecosystem/integrations.md @@ -6,6 +6,20 @@ # Integrations +## Recommendations + +### File Extension + +Applications that support mermaid files [SHOULD](https://datatracker.ietf.org/doc/html/rfc2119#section-3) use `.mermaid` or `.mmd` file extensions. + +### MIME Type + +The recommended [MIME type](https://www.iana.org/assignments/media-types/media-types.xhtml) for mermaid media is `text/vnd.mermaid`. + +[IANA](https://www.iana.org/) recognition pending. + +--- + The following list is a compilation of different integrations and plugins that allow the rendering of mermaid definitions within other applications. They also serve as proof of concept, for the variety of things that can be built with mermaid. diff --git a/docs/syntax/flowchart.md b/docs/syntax/flowchart.md index b4d527fbfb..0dbbc801b6 100644 --- a/docs/syntax/flowchart.md +++ b/docs/syntax/flowchart.md @@ -32,6 +32,9 @@ flowchart LR > **Note** > The id is what is displayed in the box. +> **💡 Tip** +> Instead of `flowchart` one can also use `graph`. + ### A node with text It is also possible to set text in the box that differs from the id. If this is done several times, it is the last text @@ -785,7 +788,10 @@ This feature is applicable to node labels, edge labels, and subgraph labels. ## Interaction -It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab. **Note**: This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`. +It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab. + +> **Note** +> This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`. click nodeId callback click nodeId call callback() @@ -1077,7 +1083,8 @@ You can change the renderer to elk by adding this directive: %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% -Note that the site needs to use mermaid version 9.4+ for this to work and have this featured enabled in the lazy-loading configuration. +> **Note** +> Note that the site needs to use mermaid version 9.4+ for this to work and have this featured enabled in the lazy-loading configuration. ### Width diff --git a/docs/syntax/timeline.md b/docs/syntax/timeline.md index f3db4bb590..d9915ff3ef 100644 --- a/docs/syntax/timeline.md +++ b/docs/syntax/timeline.md @@ -137,7 +137,7 @@ timeline section Stone Age 7600 BC : Britain's oldest known house was built in Orkney, Scotland 6000 BC : Sea levels rise and Britain becomes an island.
The people who live here are hunter-gatherers. - section Broze Age + section Bronze Age 2300 BC : People arrive from Europe and settle in Britain.
They bring farming and metalworking. : New styles of pottery and ways of burying the dead appear. 2200 BC : The last major building works are completed at Stonehenge.
People now bury their dead in stone circles. @@ -151,7 +151,7 @@ timeline section Stone Age 7600 BC : Britain's oldest known house was built in Orkney, Scotland 6000 BC : Sea levels rise and Britain becomes an island.
The people who live here are hunter-gatherers. - section Broze Age + section Bronze Age 2300 BC : People arrive from Europe and settle in Britain.
They bring farming and metalworking. : New styles of pottery and ways of burying the dead appear. 2200 BC : The last major building works are completed at Stonehenge.
People now bury their dead in stone circles. diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index 286c0c8717..8fceb810be 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -16,6 +16,10 @@ export default defineConfig({ description: 'Create diagrams and visualizations using text and code.', base: '/', markdown: allMarkdownTransformers, + ignoreDeadLinks: [ + // ignore all localhost links + /^https?:\/\/localhost/, + ], head: [ ['link', { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }], [ @@ -53,6 +57,7 @@ export default defineConfig({ }, }); +// Top (across the page) menu function nav() { return [ { text: 'Docs', link: '/intro/', activeMatch: '/intro/' }, @@ -76,7 +81,7 @@ function nav() { }, { text: 'Contributing', - link: 'https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md', + link: '/community/development', }, ], }, @@ -180,10 +185,7 @@ function sidebarCommunity() { collapsible: true, items: [ { text: 'Overview for Beginners', link: '/community/n00b-overview' }, - { - text: 'Development and Contribution', - link: '/community/development', - }, + ...sidebarCommunityDevelopContribute(), { text: 'Adding Diagrams', link: '/community/newDiagram' }, { text: 'Security', link: '/community/security' }, ], @@ -191,6 +193,40 @@ function sidebarCommunity() { ]; } +// Development and Contributing +function sidebarCommunityDevelopContribute() { + const page_path = '/community/development'; + return [ + { + text: 'Contributing to Mermaid', + link: page_path + '#contributing-to-mermaid', + collapsible: true, + 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 [ { @@ -203,3 +239,13 @@ function sidebarNews() { }, ]; } + +/** + * Return a string that puts together the pagePage, a '#', then the given id + * @param pagePath + * @param id + * @returns the fully formed path + */ +function pathToId(pagePath: string, id = ''): string { + return pagePath + '#' + id; +} diff --git a/packages/mermaid/src/docs/community/development.md b/packages/mermaid/src/docs/community/development.md index bfa5ddfcf7..a5aa39539d 100644 --- a/packages/mermaid/src/docs/community/development.md +++ b/packages/mermaid/src/docs/community/development.md @@ -1,4 +1,14 @@ -# Development and Contribution 🙌 +# 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) + +--- So you want to help? That's great! @@ -6,72 +16,162 @@ So you want to help? That's great! Here are a few things to get you started on the right path. -**The Docs Structure is dictated by [.vitepress/config.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/.vitepress/config.ts)**. +## Technical Requirements and Setup + +### Technical Requirements + +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) + +Follow [the setup steps below](#setup) to install them and verify they are working -**Note: Commits and Pull Requests should be directed to the develop branch.** +### Setup -## Branching +Follow these steps to set up the environment you need to work on code and/or documentation. -Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. So development is done in the `develop` branch. +#### 1. Fork and clone the repository -Once development is done we branch a `release` branch from `develop` for testing. +In GitHub, you first _fork_ a repository when you are going to make changes and submit pull requests. -Once the release happens we merge the `release` branch with `master` and kill the `release` branch. +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: + +```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 +``` -This means that **you should branch off your pull request from develop** and direct all Pull Requests to it. +#### 3. Verify Everything Is Working + +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: + +```bash +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.) + +### 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 -We make all changes via Pull Requests. As we have many Pull Requests from developers new to mermaid, we have put in place a process, wherein _knsv, Knut Sveidqvist_ is the primary reviewer of changes and merging pull requests. The process is as follows: +The basic steps for contributing code are: -- Large changes reviewed by knsv or other developer asked to review by knsv -- Smaller, low-risk changes like dependencies, documentation, etc. can be merged by active collaborators -- Documentation (we encourage updates to the `/packages/mermaid/src/docs` folder; you can submit them via direct commits) +```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] +``` -When you commit code, create a branch with the following naming convention: +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. -Start with the type, such as **feature** or **bug**, followed by the issue number for reference, and a text that describes the issue. +### 1. Checkout a git branch -**One example:** +Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. -`feature/945_state_diagrams` +Development is done in the `develop` branch. -**Another example:** +Once development is done we create a `release/vX.X.X` branch from `develop` for testing. -`bug/123_nasty_bug_branch` +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. -## Contributing to Documentation +**All new work should be based on the `develop` branch.** -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? +**When you are ready to do work, always, ALWAYS:** -The docs are located in the `src/docs` folder and are written in Markdown. Just pick the right section and start typing. If you want to propose changes to the structure of the documentation, such as adding a new section or a new file you do that via **[.vitepress/config.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/.vitepress/config.ts)**. +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. -> **All the documents displayed in the GitHub.io page are listed in [.vitepress/config.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/.vitepress/config.ts)**. +We use the follow naming convention for branches: -The contents of [https://mermaid-js.github.io/mermaid/](https://mermaid-js.github.io/mermaid/) are based on the docs from the `master` branch. Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid-js.github.io/mermaid/) once released. +```text + [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] +``` -## How to Contribute to Documentation +- 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) -We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. +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.) -The documentation is located in the `src/docs` directory and organized according to relevant subfolder. +We use [Vitest](https://vitest.dev) to run unit tests. -The `docs` folder will be automatically generated when committing to `src/docs` and should not be edited manually. +You can use the following command to run the unit tests: -We encourage contributions to the documentation at [mermaid-js/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). We publish documentation using GitHub Pages with [Docsify](https://www.youtube.com/watch?v=TV88lp7egMw&t=3s) +```sh +pnpm test +``` -### Add Unit Tests for Parsing +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: -This is important so that, if someone that does not know about this great feature suggests a change to the grammar, they get notified early on when that change breaks the parser. Another important aspect is that, without proper parsing, tests refactoring is pretty much impossible. +```sh +pnpm test:watch +``` -### Add E2E Tests +#### Integration/End-to-End (e2e) tests -This tests 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! +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 run dev` to start the dev server -2. Start **Cypress** by running `pnpm exec cypress open` in the **mermaid** folder. +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. @@ -101,30 +201,155 @@ it('should render forks and joins', () => { }); ``` -### Any Questions or Suggestions? +**_[TODO - running the tests against what is expected in development. ]_** -After logging in at [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). +**_[TODO - how to generate new screenshots]_** +.... -### How to Contribute a Suggestion +### 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! + +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: -1. Find the Markdown file (.md) to edit in the [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) directory in the `develop` branch. -2. Create a fork of the develop branch. -3. Make changes or add new documentation. -4. Commit changes to your fork and push it to GitHub. -5. Create a Pull Request of your fork. +_[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). -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. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. +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 ## Last Words diff --git a/packages/mermaid/src/docs/community/n00b-overview.md b/packages/mermaid/src/docs/community/n00b-overview.md index a72e500bdc..e8e84641a3 100644 --- a/packages/mermaid/src/docs/community/n00b-overview.md +++ b/packages/mermaid/src/docs/community/n00b-overview.md @@ -63,6 +63,6 @@ In fact one can pick up the syntax for it quite easily from the examples given a ## Mermaid is for everyone. -Video [Tutorials](https://mermaid-js.github.io/mermaid/#/../config/Tutorials) are also available for the mermaid [live editor](https://mermaid.live/). +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/config/directives.md b/packages/mermaid/src/docs/config/directives.md index b1e0e63030..c85d1d245e 100644 --- a/packages/mermaid/src/docs/config/directives.md +++ b/packages/mermaid/src/docs/config/directives.md @@ -2,11 +2,11 @@ ## Directives -Directives gives a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration. +Directives give a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration. -The significance of having directives is that you have them available while writing the diagram, and can modify the default global and diagram specific configurations. So, directives are applied on top of the default configurations. The beauty of directives is that you can use them to alter configuration settings for a specific diagram, i.e. at an individual level. +The significance of having directives is that you have them available while writing the diagram, and can modify the default global and diagram-specific configurations. So, directives are applied on top of the default configuration. The beauty of directives is that you can use them to alter configuration settings for a specific diagram, i.e. at an individual level. -While directives allow you to change most of the default configuration settings, there are some that are not available, that too for security reasons. Also, you do have the _option to define the set of configurations_ that you would allow to be available to the diagram author for overriding with help of directives. +While directives allow you to change most of the default configuration settings, there are some that are not available, for security reasons. Also, you have the _option to define the set of configurations_ that you wish to allow diagram authors to override with directives. ## Types of Directives options @@ -14,30 +14,30 @@ Mermaid basically supports two types of configuration options to be overridden b 1. _General/Top Level configurations_ : These are the configurations that are available and applied to all the diagram. **Some of the most important top-level** configurations are: -- theme -- fontFamily -- logLevel -- securityLevel -- startOnLoad -- secure + - theme + - fontFamily + - logLevel + - securityLevel + - startOnLoad + - secure -2. _Diagram specific configurations_ : These are the configurations that are available and applied to a specific diagram. For each diagram there are specific configuration that will alter how that particular diagram looks and behaves. - For example, `mirrorActors` is a configuration that is specific to the `SequenceDiagram` and alter whether the actors are mirrored or not. So this config is available only for the `SequenceDiagram` type. +2. _Diagram-specific configurations_ : These are the configurations that are available and applied to a specific diagram. For each diagram there are specific configuration that will alter how that particular diagram looks and behaves. + For example, `mirrorActors` is a configuration that is specific to the `SequenceDiagram` and alters whether the actors are mirrored or not. So this config is available only for the `SequenceDiagram` type. -**NOTE:** These options listed here are not all the configuration options. To get hold of all the configuration options, please refer to the [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. +**NOTE:** Not all configuration options are listed here. To get hold of all the configuration options, please refer to the [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. ```note -We plan to publish a complete list of top-level configurations & all the diagram specific configurations, with their possible values in the docs soon. +We plan to publish a complete list of top-level configurations & diagram-specific configurations with their possible values in the docs soon. ``` ## Declaring directives Now that we have defined the types of configurations that are available, we can learn how to declare directives. -A directive always starts and end `%%` sign with directive text in between, like `%% {directive_text} %%`. +A directive always starts and ends with `%%` signs with directive text in between, like `%% {directive_text} %%`. Here the structure of a directive text is like a nested key-value pair map or a JSON object with root being _init_. Where all the general configurations are defined in the top level, and all the diagram specific configurations are defined one level deeper with diagram type as key/root for that section. -Following code snippet shows the structure of a directive: +The following code snippet shows the structure of a directive: ``` %%{ @@ -59,7 +59,7 @@ Following code snippet shows the structure of a directive: You can also define the directives in a single line, like this: ``` -%%{init: { **insert argument here**}}%% +%%{init: { **insert configuration options here** } }%% ``` For example, the following code snippet: @@ -69,7 +69,7 @@ For example, the following code snippet: ``` **Notes:** -The json object that is passed as {**argument** } must be valid key value pairs and encased in quotation marks or it will be ignored. +The JSON object that is passed as {**argument**} must be valid key value pairs and encased in quotation marks or it will be ignored. Valid Key Value pairs can be found in config. Example with a simple graph: @@ -82,7 +82,7 @@ A-->B Here the directive declaration will set the `logLevel` to `debug` and the `theme` to `dark` for a rendered mermaid diagram, changing the appearance of the diagram itself. -Note: You can use 'init' or 'initialize' as both acceptable as init directives. Also note that `%%init%%` and `%%initialize%%` directives will be grouped together after they are parsed. This means: +Note: You can use 'init' or 'initialize' as both are acceptable as init directives. Also note that `%%init%%` and `%%initialize%%` directives will be grouped together after they are parsed. ```mermaid %%{init: { 'logLevel': 'debug', 'theme': 'forest' } }%% @@ -90,7 +90,7 @@ Note: You can use 'init' or 'initialize' as both acceptable as init directives. ... ``` -parsing the above generates a single `%%init%%` JSON object below, combining the two directives and carrying over the last value given for `loglevel`: +For example, parsing the above generates a single `%%init%%` JSON object below, combining the two directives and carrying over the last value given for `loglevel`: ```json { @@ -104,16 +104,15 @@ This will then be sent to `mermaid.initialize(...)` for rendering. ## Directive Examples -More directive examples for diagram specific configuration overrides -Now that the concept of directives has been explained, Let us see some more examples for directives usage: +Now that the concept of directives has been explained, let us see some more examples of directive usage: -### Changing Theme via directive +### Changing theme via directive -The following code snippet changes theme to forest: +The following code snippet changes `theme` to `forest`: `%%{init: { "theme": "forest" } }%%` -Possible themes value are: `default`,`base`, `dark`, `forest` and `neutral`. +Possible theme values are: `default`,`base`, `dark`, `forest` and `neutral`. Default Value is `default`. Example: @@ -132,7 +131,7 @@ A --> C[End] ### Changing fontFamily via directive -The following code snippet changes fontFamily to rebuchet MS, Verdana, Arial, Sans-Serif: +The following code snippet changes fontFamily to Trebuchet MS, Verdana, Arial, Sans-Serif: `%%{init: { "fontFamily": "Trebuchet MS, Verdana, Arial, Sans-Serif" } }%%` @@ -152,11 +151,11 @@ A --> C[End] ### Changing logLevel via directive -The following code snippet changes logLevel to 2: +The following code snippet changes `logLevel` to `2`: `%%{init: { "logLevel": 2 } }%%` -Possible logLevel values are: +Possible `logLevel` values are: - `1` for _debug_, - `2` for _info_ @@ -188,14 +187,14 @@ Some common flowchart configurations are: - _diagramPadding_: number - _useMaxWidth_: number -For complete list of flowchart configurations, see [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. -_Soon we plan to publish a complete list all diagram specific configurations updated in the docs_ +For a complete list of flowchart configurations, see [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. +_Soon we plan to publish a complete list of all diagram-specific configurations updated in the docs._ The following code snippet changes flowchart config: `%%{init: { "flowchart": { "htmlLabels": true, "curve": "linear" } } }%%` -Here were are overriding only the flowchart config, and not the general config, where HtmlLabels is set to true and curve is set to linear. +Here we are overriding only the flowchart config, and not the general config, setting `htmlLabels` to `true` and `curve` to `linear`. ```mermaid-example %%{init: { "flowchart": { "htmlLabels": true, "curve": "linear" } } }%% @@ -210,7 +209,7 @@ A --> C[End] ### Changing Sequence diagram config via directive -Some common sequence configurations are: +Some common sequence diagram configurations are: - _width_: number - _height_: number @@ -221,8 +220,8 @@ Some common sequence configurations are: - _showSequenceNumbers_: boolean - _wrap_: boolean -For complete list of sequence diagram configurations, see _defaultConfig.ts_ in the source code. -_Soon we plan to publish a complete list all diagram specific configurations updated in the docs_ +For a complete list of sequence diagram configurations, see [defaultConfig.ts](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/defaultConfig.ts) in the source code. +_Soon we plan to publish a complete list of all diagram-specific configurations updated in the docs._ So, `wrap` by default has a value of `false` for sequence diagrams. @@ -232,7 +231,7 @@ Let us see an example: sequenceDiagram Alice->Bob: Hello Bob, how are you? -Bob->Alice: Fine, How did you mother like the book I suggested? And did you catch with the new book about alien invasion? +Bob->Alice: Fine, how did you mother like the book I suggested? And did you catch the new book about alien invasion? Alice->Bob: Good. Bob->Alice: Cool ``` @@ -243,13 +242,13 @@ The following code snippet changes sequence diagram config for `wrap` to `true`: `%%{init: { "sequence": { "wrap": true} } }%%` -Using in the diagram above, the wrap will be enabled. +By applying that snippet to the diagram above, `wrap` will be enabled: ```mermaid-example %%{init: { "sequence": { "wrap": true, "width":300 } } }%% sequenceDiagram Alice->Bob: Hello Bob, how are you? -Bob->Alice: Fine, How did you mother like the book I suggested? And did you catch with the new book about alien invasion? +Bob->Alice: Fine, how did you mother like the book I suggested? And did you catch the new book about alien invasion? Alice->Bob: Good. Bob->Alice: Cool ``` diff --git a/packages/mermaid/src/docs/ecosystem/integrations.md b/packages/mermaid/src/docs/ecosystem/integrations.md index cd6f5058d9..be229a8aac 100644 --- a/packages/mermaid/src/docs/ecosystem/integrations.md +++ b/packages/mermaid/src/docs/ecosystem/integrations.md @@ -1,5 +1,19 @@ # Integrations +## Recommendations + +### File Extension + +Applications that support mermaid files [SHOULD](https://datatracker.ietf.org/doc/html/rfc2119#section-3) use `.mermaid` or `.mmd` file extensions. + +### MIME Type + +The recommended [MIME type](https://www.iana.org/assignments/media-types/media-types.xhtml) for mermaid media is `text/vnd.mermaid`. + +[IANA](https://www.iana.org/) recognition pending. + +--- + The following list is a compilation of different integrations and plugins that allow the rendering of mermaid definitions within other applications. They also serve as proof of concept, for the variety of things that can be built with mermaid. diff --git a/packages/mermaid/src/docs/syntax/flowchart.md b/packages/mermaid/src/docs/syntax/flowchart.md index a638e67d0c..82b1cb9452 100644 --- a/packages/mermaid/src/docs/syntax/flowchart.md +++ b/packages/mermaid/src/docs/syntax/flowchart.md @@ -25,6 +25,10 @@ flowchart LR The id is what is displayed in the box. ``` +```tip +Instead of `flowchart` one can also use `graph`. +``` + ### A node with text It is also possible to set text in the box that differs from the id. If this is done several times, it is the last text @@ -494,7 +498,11 @@ This feature is applicable to node labels, edge labels, and subgraph labels. ## Interaction -It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab. **Note**: This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`. +It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab. + +```note +This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`. +``` ``` click nodeId callback @@ -737,7 +745,9 @@ You can change the renderer to elk by adding this directive: %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% ``` +```note Note that the site needs to use mermaid version 9.4+ for this to work and have this featured enabled in the lazy-loading configuration. +``` ### Width diff --git a/packages/mermaid/src/docs/syntax/timeline.md b/packages/mermaid/src/docs/syntax/timeline.md index 4f2fc705b7..c9bc9161ee 100644 --- a/packages/mermaid/src/docs/syntax/timeline.md +++ b/packages/mermaid/src/docs/syntax/timeline.md @@ -100,7 +100,7 @@ timeline section Stone Age 7600 BC : Britain's oldest known house was built in Orkney, Scotland 6000 BC : Sea levels rise and Britain becomes an island.
The people who live here are hunter-gatherers. - section Broze Age + section Bronze Age 2300 BC : People arrive from Europe and settle in Britain.
They bring farming and metalworking. : New styles of pottery and ways of burying the dead appear. 2200 BC : The last major building works are completed at Stonehenge.
People now bury their dead in stone circles. diff --git a/run b/run new file mode 100755 index 0000000000..6afe76eeed --- /dev/null +++ b/run @@ -0,0 +1,40 @@ +#!/bin/bash +RUN="docker-compose run --rm" +command=$1 +args=${@:2} + +case $command in + +sh) +$RUN mermaid sh $args +;; + +install) +$RUN mermaid sh -c "npx pnpm install" +;; + +test) +$RUN mermaid sh -c "npx pnpm test" +;; + +lint) +$RUN mermaid sh -c "npx pnpm -w run lint:fix" +;; + +help) +cat <