Update docs/random_docs/Mermaid.md

This commit is contained in:
2024-03-02 21:00:04 +00:00
parent 625d55b4a2
commit 6eea33f977

View File

@@ -380,3 +380,109 @@ graph TD;
Mermaid is a powerful tool for creating diagrams directly within your Markdown documents. By learning its syntax and exploring different diagram types, you can enhance your documentation with visual elements that are easy to maintain and update. For more detailed information and advanced features, refer to the [Mermaid Documentation](https://mermaid-js.github.io/mermaid/#/).
---
Certainly! Below is a basic guide to Mermaid syntax suitable for reference in Markdown format. This guide includes common elements you might use in creating various diagrams, including organization charts, flowcharts, sequence diagrams, and more.
```markdown
# Mermaid Syntax Guide
Mermaid allows you to create diagrams using text-based syntax. It's versatile and can be used for various types of diagrams. Here's a quick reference guide.
## Basic Structure
Start a Mermaid diagram with triple backticks, followed by `mermaid`, and close with triple backticks.
```mermaid
graph TD;
A-->B;
```
## Diagram Types
### Flowchart
Use `graph TD;` (top-down), `graph LR;` (left-right), `graph RL;` (right-left), or `graph BT;` (bottom-top) to set direction.
```mermaid
graph TD;
A-->B;
B-->C;
C-->D;
```
### Sequence Diagram
Defines how processes interact with each other.
```mermaid
sequenceDiagram;
participant A;
participant B;
A->>B: Request;
B->>A: Response;
```
### Gantt Chart
Visualizes project schedules.
```mermaid
gantt;
title A Gantt Diagram;
section Section;
A task: a1, 2022-01-01, 30d;
```
### Class Diagram
Shows structure of a system by modeling its classes, attributes, operations, and relationships.
```mermaid
classDiagram;
Class01 <|-- AveryLongClass : Cool;
Class03 *-- Class04;
```
### State Diagram
Represents state transitions in a system.
```mermaid
stateDiagram;
[*] --> Still;
Still --> [*];
```
### Pie Chart
Visualizes numerical proportions.
```mermaid
pie;
"Dogs": 386;
"Cats": 85;
```
## Styling
Apply styles using `classDef` and `class`.
```mermaid
graph TD;
A-->B;
classDef someclass fill:#f9f,stroke:#333,stroke-width:4px;
class A someclass;
```
## Links
Add clickable links to nodes.
```mermaid
graph TD;
A-->B;
click A href "http://example.com" "Tooltip";
```
Use this guide as a starting point for creating your diagrams. Mermaid's syntax is powerful and flexible, allowing for complex and detailed visualizations.