Batch of small improvements for the documentation
This commit is contained in:
parent
d54d13ef28
commit
807a5bfab4
|
@ -5,9 +5,9 @@ services:
|
|||
stdin_open: true
|
||||
tty: true
|
||||
working_dir: /mermaid
|
||||
mem_limit: '6G'
|
||||
mem_limit: '8G'
|
||||
environment:
|
||||
- NODE_OPTIONS=--max_old_space_size=6096
|
||||
- NODE_OPTIONS=--max_old_space_size=8192
|
||||
volumes:
|
||||
- ./:/mermaid
|
||||
- root_cache:/root/.cache
|
||||
|
|
|
@ -200,14 +200,10 @@ function sidebarCommunity() {
|
|||
text: '🙌 Contributing',
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: 'Contributing to Mermaid', link: '/contributing/intro' },
|
||||
{ text: 'Contributing Guide', link: '/contributing/contributing' },
|
||||
{ text: 'Initial Setup', link: '/contributing/setup' },
|
||||
{ text: 'Workflow', link: '/contributing/workflow' },
|
||||
{ text: 'Code', link: '/contributing/code' },
|
||||
{ text: 'Documentation', link: '/contributing/documentation' },
|
||||
{ text: 'Questions and Suggestions', link: '/contributing/questions-and-suggestions' },
|
||||
{ text: 'Getting Started', link: '/contributing/intro' },
|
||||
{ text: 'Contributing to Mermaid', link: '/contributing/contributing' },
|
||||
{ text: 'Adding Diagrams', link: '/contributing/new-diagram' },
|
||||
{ text: 'Questions and Suggestions', link: '/contributing/questions-and-suggestions' },
|
||||
{ text: 'Security', link: '/contributing/security' },
|
||||
],
|
||||
},
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
# Contributing Code
|
||||
|
||||
Code it the heart of every software project. We strive to make it better. Who if not us?
|
||||
|
||||
## Where is the Code Located?
|
||||
|
||||
The core of Mermaid is located under `packages/mermaid/src`.
|
||||
|
||||
## Running Mermaid Locally
|
||||
|
||||
**Host**
|
||||
|
||||
```bash
|
||||
npx pnpm run dev
|
||||
```
|
||||
|
||||
**Docker**
|
||||
|
||||
```bash
|
||||
./run dev
|
||||
```
|
||||
|
||||
After starting the dev server open <http://localhost:9000> in your browser.
|
||||
|
||||
Now you are ready to make your changes!
|
||||
|
||||
## Make Changes
|
||||
|
||||
Have a look at <http://localhost:9000>. 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 <http://localhost:9000/dev/your-file-name.html>.
|
||||
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!)
|
||||
|
||||
Edit files in `packages/mermaid/src` as required.
|
||||
|
||||
## 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]_** -->
|
||||
|
||||
## Update Documentation
|
||||
|
||||
```tip
|
||||
Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [documentation section](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<MERMAID_RELEASE_VERSION>+)` in the title or description. It will be replaced automatically with the current version number when the release happens.
|
||||
|
||||
eg: `# Feature Name (v<MERMAID_RELEASE_VERSION>+)`
|
||||
|
||||
We know it can sometimes be hard to code _and_ write user documentation.
|
||||
|
||||
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!)
|
|
@ -19,13 +19,13 @@ flowchart LR
|
|||
|
||||
### Get the Source Code
|
||||
|
||||
In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests.
|
||||
In GitHub, you first [**fork a mermaid repository**](https://github.com/mermaid-js/mermaid/fork) 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 documentation, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories).
|
||||
|
||||
```tip
|
||||
[Here is a GitHub document that gives an overview of the process](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
|
||||
```
|
||||
|
||||
```bash
|
||||
git clone git@github.com/your-fork/mermaid
|
||||
|
@ -227,7 +227,7 @@ A bug described in issue 1123 that causes random ugly red text in multiple diagr
|
|||
|
||||
Code it the heart of every software project. We strive to make it better. Who if not us?
|
||||
|
||||
### Where is the code located?
|
||||
### Where is the Code Located?
|
||||
|
||||
The core of Mermaid is located under `packages/mermaid/src`.
|
||||
|
||||
|
@ -262,8 +262,7 @@ Edit files in `packages/mermaid/src` as required.
|
|||
|
||||
### 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).
|
||||
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.
|
||||
|
@ -282,6 +281,8 @@ Unit tests are mandatory all code except the renderers. (The renderers are teste
|
|||
|
||||
We use [Vitest](https://vitest.dev) to run unit tests.
|
||||
|
||||
**Host**
|
||||
|
||||
You can use the following command to run the unit tests:
|
||||
|
||||
```sh
|
||||
|
@ -294,6 +295,14 @@ When writing new tests, it's easier to have the tests automatically run as you m
|
|||
pnpm test:watch
|
||||
```
|
||||
|
||||
**Docker**
|
||||
|
||||
When using Docker prepend your command with `./run`:
|
||||
|
||||
```sh
|
||||
./run pnpm test
|
||||
```
|
||||
|
||||
#### Integration/End-to-End (e2e) tests
|
||||
|
||||
These test the rendering and visual appearance of the diagrams.
|
||||
|
@ -301,8 +310,16 @@ This ensures that the rendering of that feature in the e2e will be reviewed in t
|
|||
|
||||
To start working with the e2e tests:
|
||||
|
||||
1. Run `pnpm dev` to start the dev server
|
||||
2. Start **Cypress** by running `pnpm cypress:open`.
|
||||
**Host**
|
||||
|
||||
- Run `pnpm dev` to start the dev server
|
||||
- Start **Cypress** by running `pnpm cypress:open`.
|
||||
|
||||
**Docker**
|
||||
|
||||
- Enable local connections for x11 server `xhost +local:`
|
||||
- Run `./run pnpm dev` to start the dev server
|
||||
- Start **Cypress** by running `./run pnpm cypress:open --project .`.
|
||||
|
||||
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.
|
||||
|
||||
|
@ -469,7 +486,7 @@ If you want to propose changes to how the documentation is _organized_, such as
|
|||
Do not forget to push your changes
|
||||
|
||||
```bash
|
||||
git push -u origin docs/2910_update-contributing-guidelines
|
||||
git push -u origin docs/2910_update-guidelines
|
||||
```
|
||||
````
|
||||
|
||||
|
@ -492,4 +509,4 @@ You have successfully submitted your improvements! What is next?
|
|||
- 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.
|
||||
|
||||
_knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs.
|
||||
Thanks for you help!
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
# Contributing Documentation
|
||||
|
||||
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?
|
||||
|
||||
## Where is the Documentation Located?
|
||||
|
||||
```warning
|
||||
DO NOT CHANGE FILES IN `/docs`
|
||||
|
||||
The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually.
|
||||
```
|
||||
|
||||
Documentation is located in the [`packages/mermaid/src/docs`](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) folder. 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.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
classDef default fill:#fff,color:black,stroke:black
|
||||
|
||||
source["Edit /packages/mermaid/src/docs"] -- automatic processing--> published["View /docs which will be publised on Official Website"]
|
||||
```
|
||||
|
||||
## Enable Github Actions
|
||||
|
||||
```warning
|
||||
So as to allow automatic compilation of documentation pages you have to enable github actions on your fork first
|
||||
```
|
||||
|
||||
## Running the Documentation Website Locally
|
||||
|
||||
**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).**
|
||||
|
||||
Start development server for the documentation site
|
||||
|
||||
**Host**
|
||||
|
||||
```bash
|
||||
pnpm --filter mermaid run docs:dev
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
cd packages/mermaid
|
||||
pnpm docs:dev
|
||||
```
|
||||
|
||||
**Docker**
|
||||
|
||||
```bash
|
||||
./run docs:dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3333/](http://localhost:3333/) in your browser.
|
||||
|
||||
## Format
|
||||
|
||||
The documentation is written in Markdown. To get acquainted with its syntax [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax).
|
||||
|
||||
You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box.
|
||||
|
||||
```danger
|
||||
Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly.
|
||||
```
|
||||
|
||||
````markdown
|
||||
```note
|
||||
This is a note
|
||||
```
|
||||
|
||||
```tip
|
||||
This is a tip
|
||||
```
|
||||
|
||||
```warning
|
||||
This is a warning
|
||||
```
|
||||
|
||||
```danger
|
||||
This is a danger alert
|
||||
```
|
||||
````
|
||||
|
||||
## 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).
|
|
@ -1,4 +1,4 @@
|
|||
# Contributing to Mermaid
|
||||
# Getting Started
|
||||
|
||||
So you want to help? That's great!
|
||||
|
||||
|
@ -25,21 +25,29 @@ mindmap
|
|||
Classification and monitoring of incoming issues
|
||||
```
|
||||
|
||||
## Join the development
|
||||
## Join the Development
|
||||
|
||||
Detailed information about contributing can be found in the [contribution guide](../contributing/contributing.md).
|
||||
```tip
|
||||
**Check out our** [**detailed contribution guide**](./contributing.md).
|
||||
```
|
||||
|
||||
<!-- ## Help with testing -->
|
||||
<!-- ## Manage tasks -->
|
||||
Where to start:
|
||||
|
||||
## Where do I start?
|
||||
- You could start getting some knowledge of the code base by working on [these "good first issues"](https://github.com/mermaid-js/mermaid/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22+).
|
||||
- You could jump right in and help us fix any of [these bugs](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug+%2F+Error%22++label%3A%22Contributor+needed%22+)!
|
||||
- You could help write and [improve the documentation](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22).
|
||||
- You could work on a new feature! [These](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Development%22+label%3A%22Type%3A+Enhancement%22+label%3A%22Status%3A+Approved%22+) are some ideas!
|
||||
- You could confirm the bugs in [these issues](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+Triage%22++label%3A%22Type%3A+Bug+%2F+Error%22).
|
||||
|
||||
- You could confirm the bugs in [these issues](https://github.com/knsv/mermaid/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug+%2F+Error%22+label%3A%22Status%3A+Pending%22).
|
||||
- You could help write and improve the documentation! [Here's ](https://github.com/knsv/mermaid/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Help+wanted%21%22+label%3A%22Area%3A+Documentation%22)some inspiration.
|
||||
- You could start getting some knowledge of the code base by working on [these "good first issues"](https://github.com/knsv/mermaid/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22+).
|
||||
- You could jump right in and help us fix any of [these bugs](https://github.com/knsv/mermaid/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug+%2F+Error%22+label%3A%22Help+wanted%21%22+label%3A%22Area%3A+Development%22)!
|
||||
- You could work on a new feature! [These](https://github.com/knsv/mermaid/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Development%22+label%3A%22Help+wanted%21%22+label%3A%22Type%3A+Enhancement%22+label%3A%22Status%3A+Approved%22) are some ideas!
|
||||
- [Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||
[Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||
|
||||
## A Question Or a Suggestion?
|
||||
|
||||
```tip
|
||||
**Have a look at** [**how to open an issue**](./questions-and-suggestions.md).
|
||||
```
|
||||
|
||||
If you have faced a vulnerability [report it to us](./security.md).
|
||||
|
||||
## Last Words
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# Questions or Suggestions?
|
||||
|
||||
**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_**
|
||||
## Search for Existing Issue
|
||||
|
||||
## First search to see if someone has already asked (and hopefully been answered) or suggested the same thing.
|
||||
First search to see if someone has already asked (and hopefully been answered) or suggested the same thing.
|
||||
|
||||
- [Search in Discussions](https://github.com/orgs/mermaid-js/discussions)
|
||||
- [Search in Issues (Open & Closed)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue)
|
||||
|
||||
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.
|
||||
Use the GitHub reactions to add a thumbs-up to the issue or discussion thread, or append to the issue if needed.
|
||||
|
||||
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.
|
||||
## Add a new Issue
|
||||
|
||||
If you can't find anything that already addresses your question or suggestion, _open a new issue:_
|
||||
You have not found anything that already addresses your request, or maybe you have come up with the new idea? Feel free to open a new issue or discussion.
|
||||
|
||||
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).
|
||||
Log in to [GitHub.com](https://www.github.com), and use [GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues). Press [https://github.com/mermaid-js/mermaid/issues/new/choose] issue, select the appropriate template and describe your problem.
|
||||
|
|
Loading…
Reference in New Issue