mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-03 14:19:38 +02:00
chore: Add isDefault to examples
This commit is contained in:
@@ -68,6 +68,14 @@ export const addDiagramDefinition = ({ id, ...definition }: DetectorRecord) => {
|
||||
if (diagramDefinitions[id]) {
|
||||
log.warn(`Detector with key ${id} already exists. Overwriting.`);
|
||||
}
|
||||
if (
|
||||
definition.examples &&
|
||||
definition.examples.filter(({ isDefault }) => isDefault).length !== 1
|
||||
) {
|
||||
throw new Error(
|
||||
`Diagram with key ${id} must have exactly one default example. Set isDefault to true for one example.`
|
||||
);
|
||||
}
|
||||
diagramDefinitions[id] = definition;
|
||||
log.debug(`Detector with key ${id} added${definition.loader ? ' with loader' : ''}`);
|
||||
};
|
||||
|
@@ -23,6 +23,7 @@ const architecture: ExternalDiagramDefinition = {
|
||||
description: 'Visualize system architecture and components',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `architecture-beta
|
||||
group api(cloud)[API]
|
||||
|
||||
|
@@ -19,6 +19,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Create block-based visualizations with beta styling',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `block-beta
|
||||
columns 1
|
||||
db(("DB"))
|
||||
|
@@ -24,6 +24,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
'Visualize software architecture using the C4 model (Context, Container, Component, Code)',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `C4Context
|
||||
title System Context diagram for Internet Banking System
|
||||
Enterprise_Boundary(b0, "BankBoundary0") {
|
||||
|
@@ -28,6 +28,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize class structures and relationships in object-oriented programming',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `classDiagram
|
||||
Animal <|-- Duck
|
||||
Animal <|-- Fish
|
||||
|
@@ -23,6 +23,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize database schemas and relationships between entities',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `erDiagram
|
||||
CUSTOMER ||--o{ ORDER : places
|
||||
ORDER ||--|{ ORDER_ITEM : contains
|
||||
|
@@ -35,6 +35,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize flowcharts and directed graphs',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `flowchart TD
|
||||
A[Christmas] -->|Get money| B(Go shopping)
|
||||
B --> C{Let me think}
|
||||
|
@@ -23,6 +23,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize project schedules and timelines',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `gantt
|
||||
title A Gantt Diagram
|
||||
dateFormat YYYY-MM-DD
|
||||
|
@@ -20,6 +20,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize Git repository history and branch relationships',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `gitGraph
|
||||
commit
|
||||
branch develop
|
||||
|
@@ -22,6 +22,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize work items in a Kanban board',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `---
|
||||
config:
|
||||
kanban:
|
||||
|
@@ -22,6 +22,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize ideas and concepts in a tree-like structure',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `mindmap
|
||||
root((mindmap))
|
||||
Origins
|
||||
|
@@ -23,6 +23,7 @@ export const packet: ExternalDiagramDefinition = {
|
||||
description: 'Visualize packet data and network traffic',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `---
|
||||
title: "TCP Packet"
|
||||
---
|
||||
|
@@ -23,6 +23,7 @@ export const pie: ExternalDiagramDefinition = {
|
||||
description: 'Visualize data as proportional segments of a circle',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `pie title Pets adopted by volunteers
|
||||
"Dogs" : 386
|
||||
"Cats" : 85
|
||||
|
@@ -23,6 +23,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize items in a 2x2 matrix based on two variables',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `quadrantChart
|
||||
title Reach and engagement of campaigns
|
||||
x-axis Low Reach --> High Reach
|
||||
|
@@ -23,6 +23,7 @@ export const radar: ExternalDiagramDefinition = {
|
||||
description: 'Visualize data in a radial format',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `---
|
||||
title: "Grades"
|
||||
---
|
||||
|
@@ -23,6 +23,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize system requirements and their relationships',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `requirementDiagram
|
||||
|
||||
requirement test_req {
|
||||
|
@@ -19,6 +19,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize flow quantities between different stages or processes',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `---
|
||||
config:
|
||||
sankey:
|
||||
|
@@ -23,6 +23,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize interactions between objects over time',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `sequenceDiagram
|
||||
Alice->>+John: Hello John, how are you?
|
||||
Alice->>+John: John, can you hear me?
|
||||
|
@@ -29,6 +29,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize state transitions and behaviors of a system',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `stateDiagram-v2
|
||||
[*] --> Still
|
||||
Still --> [*]
|
||||
|
@@ -23,6 +23,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize events and milestones in chronological order',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `timeline
|
||||
title History of Social Media Platform
|
||||
2002 : LinkedIn
|
||||
|
@@ -23,6 +23,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Visualize user interactions and experiences with a system',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `journey
|
||||
title My working day
|
||||
section Go to work
|
||||
|
@@ -23,6 +23,7 @@ const plugin: ExternalDiagramDefinition = {
|
||||
description: 'Create scatter plots and line charts with customizable axes',
|
||||
examples: [
|
||||
{
|
||||
isDefault: true,
|
||||
code: `xychart-beta
|
||||
title "Sales Revenue"
|
||||
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||
|
Reference in New Issue
Block a user