├── .gitignore
├── CHANGELOG.md
├── EXAMPLES.md
├── PSMermaid.psd1
├── PSMermaid.psm1
├── PSMermaidLogo.png
├── Public
├── ClassDiagram
│ ├── New-MermaidClass.ps1
│ ├── New-MermaidClassDiagram.ps1
│ ├── New-MermaidClassMethod.ps1
│ ├── New-MermaidClassProperty.ps1
│ └── New-MermaidClassRelationShip.ps1
├── ERDiagram
│ ├── New-MermaidERDiagram.ps1
│ ├── New-MermaidERDiagramEntity.ps1
│ ├── New-MermaidERDiagramEntityAttribute.ps1
│ ├── New-MermaidERDiagramRelationShip.ps1
│ └── New-MermaidERDiagramRelationShipType.ps1
├── GitGraph
│ ├── New-MermaidGitGraph.ps1
│ └── New-MermaidGitGraphEntry.ps1
├── Graph
│ ├── New-MermaidGraph.ps1
│ ├── New-MermaidGraphLink.ps1
│ ├── New-MermaidGraphNode.ps1
│ ├── New-MermaidGraphNodeConnection.ps1
│ └── New-MermaidGraphStyleClassDefinition.ps1
├── Journey
│ ├── New-MermaidJourney.ps1
│ ├── New-MermaidJourneySection.ps1
│ └── New-MermaidJourneyTask.ps1
├── Pie
│ ├── New-MermaidPie.ps1
│ └── New-MermaidPieDataSet.ps1
├── QuadrantChart
│ ├── New-MermaidQuadrantChart.ps1
│ ├── New-MermaidQuadrantChartAxis.ps1
│ ├── New-MermaidQuadrantChartDataSet.ps1
│ └── New-MermaidQuadrantChartQuadrant.ps1
└── Timeline
│ ├── New-MermaidTimeline.ps1
│ ├── New-MermaidTimelineDataSet.ps1
│ ├── New-MermaidTimelineDirective.ps1
│ └── New-MermaidTimelineSection.ps1
├── README.md
└── example.ps1
/.gitignore:
--------------------------------------------------------------------------------
1 | Tests/
2 | Public/Experimental
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## Version 0.1.1
4 |
5 | - Added basic functionality to create a 'gitGraphs'
6 | - Following new functions: 'New-MermaidGitGraph', 'New-MermaidGitGraphEntry' created
7 |
8 | ```mermaid
9 | gitGraph
10 | commit id: "ZERO"
11 | branch develop
12 | commit id: "A"
13 | checkout main
14 | commit id: "ONE"
15 | checkout develop
16 | commit id: "B"
17 | checkout main
18 | commit id: "TWO"
19 | cherry-pick id: "A"
20 | commit id: "THREE"
21 | checkout develop
22 | commit id: "C"
23 |
24 | ```
25 |
26 | ## Version 0.1.0
27 |
28 | - Added basic functionality to create a 'ERDiagram' (EntityRelationship-Diagram)
29 | - Following new functions: 'New-MermaidERDiagram','New-MermaidERDiagramEntity', 'New-MermaidERDiagramEntityAttribute','New-MermaidERDiagramRelationShip', 'New-MermaidERDiagramRelationShipType' created
30 |
31 | ```mermaid
32 | erDiagram
33 | CAR {
34 | string registrationNumber PK
35 | string make
36 | string model
37 | string[] parts
38 | }
39 |
40 | PERSON {
41 | string driversLicense PK "The license #"
42 | string(99) firstname "Only 99 characters are allowed"
43 | string lastname
44 | string phone UK
45 | int age
46 | }
47 |
48 | NAMED-DRIVER {
49 | string carRegistrationNumber PK,FK
50 | string driverLicence PK,FK
51 | }
52 |
53 | CAR ||--o{ NAMED-DRIVER : allows
54 | PERSON ||--o{ NAMED-DRIVER : is
55 | ```
56 |
57 | ## Version 0.0.9
58 |
59 | - Added basic functionality to create a 'QuardrantChart'
60 | - Following new functions: 'New-MermaidQuadrantChart','New-MermaidQuadrantChartAxis', 'New-MermaidQuadrantChartDataSet','New-MermaidQuadrantChartQuadrant' created
61 |
62 | ## Version 0.0.8
63 |
64 | - Added basic functionality to create a 'Timeline'
65 | - Following new functions: 'New-MermaidTimeLine','New-MermaidTimelineDataSet', 'New-MermaidTimelineSection','New-MermaidTimelineDirective' created
66 |
67 | ```mermaid
68 | timeline
69 | title History of Social Media Platform
70 | 2002 : LinkedIn
71 | 2004 : Facebook : Google
72 | 2005 : Youtube
73 | 2006 : Twitter
74 | ```
75 |
76 | ## Version 0.0.7
77 |
78 | - Added basic functionality to create a 'pie chart'
79 | - Following new functions: 'New-MermaidPie','New-MermaidPieDataSet' created
80 |
81 | ```mermaid
82 | %%{init: {"pie": {"textPosition": 0.5}, "themeVariables": {"pieOuterStrokeWidth": "5px"}} }%%
83 | pie showData
84 | title Key elements in Product X
85 | "Calcium" : 42.96
86 | "Potassium" : 50.05
87 | "Magnesium" : 10.01
88 | "Iron" : 5
89 |
90 | ```
91 |
92 | ## Version 0.0.6
93 |
94 | - Added basic functionality to create a 'userjourney'
95 | - Following new functions: 'New-MermaidJourney','New-MermaidJourneySection','New-MermaidJourneyTask' created
96 |
97 | ```mermaid
98 | journey
99 | title My working day
100 | section Go to work
101 | Make teak: 5: Me
102 | Go upstairs: 3: Me
103 | Do work: 1: Me, Cat
104 |
105 | section Go home
106 | Go downstairs: 5: Me
107 | Sit down: 5: Me
108 | ```
109 |
110 | ## Version 0.0.5
111 |
112 | - Added basic functionality to create ClassDiagrams
113 | - Following new functions: 'New-MermaidClass','New-MermaidClassDiagram','New-MermaidClassMethod','New-MermaidClassProperty','New-MermaidClassRelationShip' created
114 |
115 | ```mermaid
116 | classDiagram
117 | class Animal{
118 | +int age
119 | +String Gender
120 | +isMammal()
121 | +mate()
122 | }
123 | class Fish{
124 | -int sizeInFeet
125 | -canEat()
126 | }
127 | class Duck{
128 | +string beackColor
129 | +swim()
130 | +quack()
131 | }
132 | Animal <|-- Duck
133 | Animal <|-- Fish
134 | ```
135 |
136 | ## Version 0.0.4
137 |
138 | ### Changes
139 |
140 | - Added function 'New-MermaidClassDefinition' to create class definitions to MermaidNodes
141 | - Updated parameter from 'New-MermaidGraph' to accept ClassDefinitions
142 |
143 | ## Version 0.0.3
144 |
145 | ### Changes
146 |
147 | - Added functionality to 'New-MermaidGraphLink' to generate Bidirectional links, added new arrow types (Arrow, Dot and Cross).
148 |
149 | ```mermaid
150 | flowchart LR
151 | A o-.-o|Example| B
152 | C x-.-x|Example| D
153 | E <.->|Example| F
154 | ```
155 |
--------------------------------------------------------------------------------
/EXAMPLES.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | ## Graph/Workflow
4 |
5 | ### Creating a Node
6 |
7 | ```powershell
8 | $Node1 = New-MermaidGraphNode -Shape Parallelogram -ID ID1 -Text "Frankfurt am Main"
9 | # Output: ID1[/Frankfurt am Main/]
10 | ```
11 |
12 | ```mermaid
13 | graph LR
14 | ID1[/Frankfurt am Main/]
15 | ```
16 |
17 | ### Creating another Node
18 |
19 | ```powershell
20 | $Node2 = New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)"
21 | # Output: ID2(((PSConfEU2024)))
22 | ```
23 |
24 | ```mermaid
25 | graph LR
26 | ID2(((PSConfEU2024)))
27 | ```
28 |
29 | ### Creating a Link
30 |
31 | ```powershell
32 | $Link = New-MermaidGraphLink -Text "traveling to:" -Linktype ArrowLink
33 | # Output: -->|traveling to:|
34 | ```
35 |
36 | ```mermaid
37 | graph LR
38 | A-->|traveling to:|B
39 | ```
40 |
41 | ### Creating a Connection
42 |
43 | ```powershell
44 | $Connection = New-MermaidGraphNodeConnection -FirstNode $Node1 -SecondNode $Node2 -Link $Link
45 | # Output: ID1[/Frankfurt am Main/]-->|traveling to:|ID2(((PSConfEU2024)))
46 | ```
47 |
48 | ```mermaid
49 | graph LR
50 | ID1[/Frankfurt am Main/]-->|traveling to:|ID2(((PSConfEU2024)))
51 | ```
52 |
53 | ### Creating a Graph
54 |
55 | ```powershell
56 | $Graph = New-MermaidGraph -Direction LR -NodeConnections $Connection
57 | <# Outpout:
58 | \`\`\`mermaid
59 | graph LR
60 | ID1[/Frankfurt am Main/]-->|traveling to:|ID2(((PSConfEU2024)))
61 | \`\`\`
62 | #>
63 | ```
64 |
65 | ```mermaid
66 | graph LR
67 | ID1[/Frankfurt am Main/]-->|traveling to:|ID2(((PSConfEU2024)))
68 | ```
69 |
70 | ### Creating another Graph in one big step
71 |
72 | ```powershell
73 | New-MermaidGraph -Direction LR -NodeConnections @(
74 | $(
75 | $newMermaidNodeConnectionSplat = @{
76 | FirstNode = $(New-MermaidGraphNode -Shape RoundEdges -ID ID1 -Text "Frankfurt am Main")
77 | SecondNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
78 | Link = $(New-MermaidGraphLink -Text "traveling to:" -Linktype ArrowLink)
79 | }
80 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
81 | ),
82 | $(
83 | $newMermaidNodeConnectionSplat = @{
84 | FirstNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
85 | SecondNode = $(New-MermaidGraphNode -Shape subroutine -ID ID3 -Text "Enjoying for 4 Days")
86 | Link = $(New-MermaidGraphLink -Linktype DottedLink)
87 | }
88 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
89 | ),
90 | $(
91 | $newMermaidNodeConnectionSplat = @{
92 | FirstNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
93 | SecondNode = $(New-MermaidGraphNode -Shape RoundEdges -ID ID1 -Text "Frankfurt am Main")
94 | Link = $(New-MermaidGraphLink -Text "traveling home:" -Linktype ArrowLink)
95 | }
96 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
97 | )
98 | )
99 | <# Outpout:
100 | \`\`\`mermaid
101 | graph LR
102 | ID1(Frankfurt am Main)-->|traveling to:|ID2(((PSConfEU2024)))
103 | ID2(((PSConfEU2024)))-.->ID3[[Enjoying for 4 Days]]
104 | ID2(((PSConfEU2024)))-->|traveling home:|ID1(Frankfurt am Main)
105 | \`\`\`
106 | #>
107 | ```
108 |
109 | ```mermaid
110 | graph LR
111 | ID1(Frankfurt am Main)-->|traveling to:|ID2(((PSConfEU2024)))
112 | ID2(((PSConfEU2024)))-.->ID3[[Enjoying for 4 Days]]
113 | ID2(((PSConfEU2024)))-->|traveling home:|ID1(Frankfurt am Main)
114 | ```
115 |
--------------------------------------------------------------------------------
/PSMermaid.psd1:
--------------------------------------------------------------------------------
1 | #
2 | # Module manifest for module 'PSMermaid'
3 | #
4 | # Generated by: Christian Ritter
5 | #
6 | # Generated on: 9/9/2023
7 | #
8 |
9 | @{
10 |
11 | # Script module or binary module file associated with this manifest.
12 | RootModule = 'PSMermaid.psm1'
13 |
14 | # Version number of this module.
15 | ModuleVersion = '0.1.0'
16 |
17 | # Supported PSEditions
18 | CompatiblePSEditions = 'Core'
19 |
20 | # ID used to uniquely identify this module
21 | GUID = 'd16d5345-183a-423d-802f-90769131b0a0'
22 |
23 | # Author of this module
24 | Author = 'Christian Ritter'
25 |
26 | # Company or vendor of this module
27 | CompanyName = 'Christian Ritter'
28 |
29 | # Copyright statement for this module
30 | Copyright = '(c) Christian Ritter. All rights reserved.'
31 |
32 | # Description of the functionality provided by this module
33 | Description = 'Easily Create Mermaid Markdown Files in PowerShell'
34 |
35 | # Minimum version of the PowerShell engine required by this module
36 | PowerShellVersion = '7.1'
37 |
38 | # Name of the PowerShell host required by this module
39 | # PowerShellHostName = ''
40 |
41 | # Minimum version of the PowerShell host required by this module
42 | # PowerShellHostVersion = ''
43 |
44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45 | # DotNetFrameworkVersion = ''
46 |
47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48 | # ClrVersion = ''
49 |
50 | # Processor architecture (None, X86, Amd64) required by this module
51 | # ProcessorArchitecture = ''
52 |
53 | # Modules that must be imported into the global environment prior to importing this module
54 | #RequiredModules = @()
55 |
56 | # Assemblies that must be loaded prior to importing this module
57 | # RequiredAssemblies = @()
58 |
59 |
60 |
61 | # Script files (.ps1) that are run in the caller's environment prior to importing this module.
62 | # ScriptsToProcess = @()
63 |
64 | # Type files (.ps1xml) to be loaded when importing this module
65 | # TypesToProcess = @()
66 |
67 | # Format files (.ps1xml) to be loaded when importing this module
68 | # FormatsToProcess = @()
69 |
70 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
71 | # NestedModules = @()
72 |
73 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
74 | FunctionsToExport = @(
75 | 'New-MermaidClass',
76 | 'New-MermaidClassDiagram',
77 | 'New-MermaidClassMethod',
78 | 'New-MermaidClassProperty',
79 | 'New-MermaidClassRelationShip',
80 | 'New-MermaidGraph',
81 | 'New-MermaidGraphLink',
82 | 'New-MermaidGraphNode',
83 | 'New-MermaidGraphNodeConnection',
84 | 'New-MermaidGraphStyleClassDefintion'
85 | 'New-MermaidJourney'
86 | 'New-MermaidJourneySection'
87 | 'New-MermaidJourneyTask'
88 | 'New-MermaidPie'
89 | 'New-MermaidPieDataSet'
90 | 'New-MermaidTimeline'
91 | 'New-MermaidTimelineDataSet'
92 | 'New-MermaidTimelineDirective'
93 | 'New-MermaidTimelineSection'
94 | 'New-MermaidQuadrantChart'
95 | 'New-MermaidQuadrantChartAxis'
96 | 'New-MermaidQuadrantChartDataSet'
97 | 'New-MermaidQuadrantChartQuadrant'
98 | 'New-MermaidERDiagram'
99 | 'New-MermaidERDiagramEntity'
100 | 'New-MermaidERDiagramEntityAttribute'
101 | 'New-MermaidERDiagramRelationShip'
102 | 'New-MermaidERDiagramRelationShipType'
103 | 'New-MermaidGitGraphEntry'
104 | 'New-MermaidGitGraph'
105 | )
106 |
107 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
108 | CmdletsToExport = @()
109 |
110 | # Variables to export from this module
111 | VariablesToExport = @()
112 |
113 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
114 | AliasesToExport = @()
115 |
116 | # DSC resources to export from this module
117 | # DscResourcesToExport = @()
118 |
119 | # List of all modules packaged with this module
120 | # ModuleList = @()
121 |
122 | # List of all files packaged with this module
123 | # FileList = @()
124 |
125 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
126 | PrivateData = @{
127 |
128 | PSData = @{
129 |
130 | # Tags applied to this module. These help with module discovery in online galleries.
131 | Tags = @('MarkDown','Mermaid','Wrapper','Diagram','UML')
132 |
133 | # A URL to the license for this module.
134 | # LicenseUri = ''
135 |
136 | # A URL to the main website for this project.
137 | ProjectUri = 'https://github.com/HCRitter/PSMermaid'
138 |
139 | # A URL to an icon representing this module.
140 | # IconUri = ''
141 |
142 | # ReleaseNotes of this module
143 | # ReleaseNotes = ''
144 |
145 | # Prerelease string of this module
146 | # Prerelease = ''
147 |
148 | # Flag to indicate whether the module requires explicit user acceptance for install/update/save
149 | # RequireLicenseAcceptance = $false
150 |
151 | # External dependent modules of this module
152 | # ExternalModuleDependencies = @()
153 |
154 | } # End of PSData hashtable
155 |
156 | } # End of PrivateData hashtable
157 |
158 | # HelpInfo URI of this module
159 | # HelpInfoURI = ''
160 |
161 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
162 | # DefaultCommandPrefix = ''
163 |
164 | }
165 |
166 |
--------------------------------------------------------------------------------
/PSMermaid.psm1:
--------------------------------------------------------------------------------
1 | # using smartAliases
2 | foreach($EntryType in @('Commit',"Branch",'Merge','Checkout','Cherrypick')){
3 | New-Alias -Name "New-MermaidGitGraphEntry$EntryType" -Value New-MermaidGitGraphEntry
4 | }
5 |
6 | $FunctionFiles = $("$PSScriptRoot\Public\","$PSScriptRoot\Private\")| Get-Childitem -file -Recurse -Include "*.ps1" -ErrorAction SilentlyContinue
7 |
8 | foreach($FunctionFile in $FunctionFiles){
9 | try {
10 | . $FunctionFile.FullName
11 | }
12 | catch {
13 | Write-Error -Message "Failed to import function: '$($FunctionFile.FullName)': $_"
14 | }
15 | }
16 |
17 | Export-ModuleMember -Function $FunctionFiles.BaseName -Alias *
--------------------------------------------------------------------------------
/PSMermaidLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HCRitter/PSMermaid/09daa198c02186571bca7751dac520e1c8c03aeb/PSMermaidLogo.png
--------------------------------------------------------------------------------
/Public/ClassDiagram/New-MermaidClass.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidClass {
2 | [CmdletBinding()]
3 | param (
4 | $Name,
5 | [String[]]$Property,
6 | [String[]]$Method
7 | )
8 |
9 | begin {
10 | $output = [System.Text.StringBuilder]::new()
11 | $output.AppendLine("class $Name{") | Out-Null
12 | }
13 |
14 | process {
15 | foreach($PropertyItem in $Property){
16 | $output.AppendLine("`t$PropertyItem") | Out-Null
17 | }
18 | foreach($MethodItem in $Method){
19 | $output.AppendLine("`t$MethodItem") | Out-Null
20 | }
21 | }
22 |
23 | end {
24 | $output.AppendLine("}") | Out-Null
25 | return $output.ToString()
26 | }
27 | }
--------------------------------------------------------------------------------
/Public/ClassDiagram/New-MermaidClassDiagram.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidClassDiagram {
2 | [CmdletBinding()]
3 | param (
4 | [string[]] $Notes,
5 | [string[]] $Class,
6 | [string[]] $Relationship
7 | )
8 |
9 | begin {
10 | $output = [System.Text.StringBuilder]::new()
11 | $output.AppendLine("classDiagram") | Out-Null
12 | }
13 |
14 | process {
15 | foreach($ClassItem in $Class){
16 | $output.Append($ClassItem) | Out-Null
17 | }
18 | foreach($RelationShipItem in $Relationship){
19 | $output.AppendLine($RelationShipItem) | Out-Null
20 | }
21 | }
22 |
23 | end {
24 | return $output.ToString()
25 | }
26 | }
--------------------------------------------------------------------------------
/Public/ClassDiagram/New-MermaidClassMethod.ps1:
--------------------------------------------------------------------------------
1 | class EncapsulationType : System.Management.Automation.IValidateSetValuesGenerator {
2 | [String[]] GetValidValues() {
3 | $Global:EncapsulationTypes = @{
4 | 'Public' = '+'
5 | 'Private' = '-'
6 | 'Protected' = '#'
7 | 'Package' = '~'
8 | }
9 | return ($Global:EncapsulationTypes).Keys
10 | }
11 | }
12 |
13 |
14 | function New-MermaidClassMethod {
15 | [CmdletBinding()]
16 | param (
17 | [ValidateSet([EncapsulationType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
18 | $Encapsulation = "Public",
19 | $Name,
20 | $Parameter,
21 | $ReturnType
22 | )
23 |
24 | begin {
25 | $SelectedEncapsulation = $Global:EncapsulationTypes[$Encapsulation]
26 | $ReturnString = ""
27 |
28 | }
29 |
30 | process {
31 |
32 | $ReturnString += "{0}{1}($Parameter) {2}" -f $SelectedEncapsulation,$Name, $ReturnType
33 | }
34 |
35 | end {
36 | return $ReturnString
37 | }
38 | }
--------------------------------------------------------------------------------
/Public/ClassDiagram/New-MermaidClassProperty.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidClassProperty {
2 | [CmdletBinding()]
3 | param (
4 | $Accessability = "Public",
5 | $Datatype,
6 | $Name
7 | )
8 |
9 | begin {
10 | $ReturnString = ""
11 |
12 | }
13 |
14 | process {
15 | switch ($Accessability) {
16 | 'private' {$ReturnString = '-' }
17 | Default {$ReturnString = '+'}
18 | }
19 | $ReturnString += "{0} {1}" -f $Datatype,$Name
20 | }
21 |
22 | end {
23 | return $ReturnString
24 | }
25 | }
--------------------------------------------------------------------------------
/Public/ClassDiagram/New-MermaidClassRelationShip.ps1:
--------------------------------------------------------------------------------
1 | class RelationShipType : System.Management.Automation.IValidateSetValuesGenerator {
2 | [String[]] GetValidValues() {
3 | $Global:RelationShipTypes = @{
4 | 'Inheritance' = '<|--'
5 | 'Composition' = '*--'
6 | 'Aggregation' = 'o--'
7 | 'Association' = '-->'
8 | 'LinkSolid' = '--'
9 | 'LinkDashed' = '..'
10 | 'Dependency' = '..>'
11 | 'Realization' = '..|>'
12 | }
13 | return ($Global:RelationShipTypes).Keys
14 | }
15 | }
16 | class CardinalityType : System.Management.Automation.IValidateSetValuesGenerator {
17 | [String[]] GetValidValues() {
18 | $Global:CardinalityTypes = @{
19 | 'OnlyOne' = '1'
20 | 'ZeroToOne' = '0..1'
21 | 'OneOrMore' = '1..*'
22 | 'Many' = '*'
23 | 'n' = 'n'
24 | 'ZeroToN' = '0..n'
25 | 'OneToN' = '1..n'
26 | }
27 | return ($Global:CardinalityTypes).Keys
28 | }
29 | }
30 |
31 |
32 |
33 | function New-MermaidClassRelationShip {
34 | [CmdletBinding()]
35 | param (
36 | [ValidateSet([RelationShipType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
37 | $RelationShipType = $Null,
38 | $FirstClass,
39 | $SecondClass,
40 | [ValidateSet([CardinalityType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
41 | $FirstCardinality,
42 | [ValidateSet([CardinalityType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
43 | $SecondCardinality
44 | )
45 |
46 | begin {
47 | $ReturnString = ""
48 | $SelectedFirstCardinality =""
49 | $SelectedSecondCardinality =""
50 | $SelectedRelationShipType = $Global:RelationShipTypes[$RelationShipType]
51 | if(-not [string]::IsNullOrEmpty($FirstCardinality)){
52 | $SelectedFirstCardinality = " `"$($Global:CardinalityTypes[$FirstCardinality])`""
53 | }
54 | if(-not [string]::IsNullOrEmpty($SecondCardinality)){
55 | $SelectedSecondCardinality = " `"$($Global:CardinalityTypes[$SecondCardinality])`""
56 | }
57 | }
58 |
59 | process {
60 | $ReturnString = "{0}{1} {2}{3} {4}" -f $FirstClass,$SelectedFirstCardinality,$SelectedRelationShipType, $SelectedSecondCardinality,$SecondClass
61 | }
62 |
63 | end {
64 | return $ReturnString
65 | }
66 | }
--------------------------------------------------------------------------------
/Public/ERDiagram/New-MermaidERDiagram.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidERDiagram {
2 | [CmdletBinding()]
3 | param (
4 | [string[]]$Entity,
5 | [string[]]$Relationship
6 | )
7 |
8 | begin {
9 | $output = [System.Text.StringBuilder]::new()
10 | $output.AppendLine("erDiagram ") | Out-Null
11 | }
12 |
13 | process {
14 | foreach($EntityElement in $Entity){
15 | $output.AppendLine("`t$EntityElement") | Out-Null
16 | }
17 | foreach($RelationshipElement in $Relationship){
18 | $output.AppendLine("`t$RelationshipElement") | Out-Null
19 | }
20 | }
21 |
22 | end {
23 | return $output.tostring()
24 | }
25 | }
--------------------------------------------------------------------------------
/Public/ERDiagram/New-MermaidERDiagramEntity.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidERDiagramEntity {
2 | [CmdletBinding()]
3 | param (
4 | $Name,
5 | [string[]]$Attribute
6 |
7 | )
8 |
9 | begin {
10 | $output = [System.Text.StringBuilder]::new()
11 | $output.AppendLine("$Name {") | Out-Null
12 | }
13 |
14 | process {
15 | foreach($AttributeElement in $Attribute){
16 | $output.AppendLine("`t`t$AttributeElement") | Out-Null
17 | }
18 | $output.AppendLine("`t}") | Out-Null
19 | }
20 |
21 | end {
22 | return $output.ToString()
23 | }
24 | }
--------------------------------------------------------------------------------
/Public/ERDiagram/New-MermaidERDiagramEntityAttribute.ps1:
--------------------------------------------------------------------------------
1 | class KeyType : System.Management.Automation.IValidateSetValuesGenerator {
2 | [String[]] GetValidValues() {
3 | $Script:KeyTypes = @{
4 | 'Unique' = 'UK'
5 | 'Foreign' = 'FK'
6 | 'Primary' = 'PK'
7 | }
8 | return ($Script:KeyTypes).Keys
9 | }
10 | }
11 |
12 | function New-MermaidERDiagramEntityAttribute {
13 | [CmdletBinding()]
14 | param (
15 | $Type,
16 | $Name,
17 | [ValidateSet([KeyType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
18 | $Key,
19 | $Comment
20 | )
21 |
22 | begin {
23 | $ReturnString =""
24 | $SelectedKey = foreach($KeyElement in $Key){
25 | $script:KeyTypes[$KeyElement]
26 | }
27 | $SelectedKey = $SelectedKey | Select-Object -Unique
28 | }
29 |
30 | process {
31 | if(-not ([string]::IsNullOrEmpty($Comment))){
32 | $Comment = "`"$Comment`""
33 | }
34 | $ReturnString = "{0} {1} {2} {3}" -f $Type,$Name,$($SelectedKey -join ','),$Comment
35 | }
36 |
37 | end {
38 | return $ReturnString
39 | }
40 | }
--------------------------------------------------------------------------------
/Public/ERDiagram/New-MermaidERDiagramRelationShip.ps1:
--------------------------------------------------------------------------------
1 | class LinkType : System.Management.Automation.IValidateSetValuesGenerator {
2 | [String[]] GetValidValues() {
3 | $Global:LinkTypes = @{
4 | 'Link' = '--'
5 | 'Dotted' = '..'
6 | }
7 | return ($Global:LinkTypes).Keys
8 | }
9 | }
10 | function New-MermaidERDiagramRelationShip {
11 | [CmdletBinding()]
12 | param (
13 | $FirstEntityName,
14 | $SecondEntityName,
15 | $RelationTypeLeft,
16 | $RelationTypeRight,
17 | [ValidateSet([LinkType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
18 | $LinkType = 'Link',
19 | $Comment
20 |
21 | )
22 |
23 | begin {
24 | $ReturnString = ""
25 | if(-not ([string]::IsNullOrEmpty($Comment))){
26 | $Comment = ": $Comment"
27 | }
28 | }
29 |
30 | process {
31 |
32 | $ReturnString = "{0} {1}{2}{3} {4} {5}" -f $FirstEntityName, $RelationTypeLeft, $Script:LinkTypes[$LinkType], $RelationTypeRight, $SecondEntityName, $Comment
33 | }
34 |
35 | end {
36 | return $ReturnString
37 | }
38 | }
--------------------------------------------------------------------------------
/Public/ERDiagram/New-MermaidERDiagramRelationShipType.ps1:
--------------------------------------------------------------------------------
1 | class RelationShipType : System.Management.Automation.IValidateSetValuesGenerator {
2 | [String[]] GetValidValues() {
3 | $Script:RelationShipTypes = @{
4 | 'ZeroOrOne' = '|o','o|'
5 | 'ExactlyOne' = '||','||'
6 | 'ZeroOrMore' = '}o','o{'
7 | 'OneOrMore' = '}|','|{'
8 | }
9 | return ($Script:RelationShipTypes).Keys
10 | }
11 | }
12 |
13 | function New-MermaidERDiagramRelationShipType {
14 | [CmdletBinding()]
15 | param (
16 | [ValidateSet([RelationShipType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
17 | $Relationshiptype,
18 | [ValidateSet("Left","Right")]
19 | $Direction
20 | )
21 |
22 | begin {
23 | $ReturnString =""
24 | }
25 |
26 | process {
27 | $ReturnString= switch ($Direction) {
28 | "Left" { $Script:RelationShipTypes[$Relationshiptype][0] }
29 | Default {$Script:RelationShipTypes[$Relationshiptype][1]}
30 | }
31 | }
32 |
33 | end {
34 | return $ReturnString
35 | }
36 | }
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Public/GitGraph/New-MermaidGitGraph.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidGitGraph {
2 | [CmdletBinding()]
3 | param (
4 | [string[]]$Entry
5 | )
6 |
7 | end {
8 | $output = [System.Text.StringBuilder]::new()
9 | $output.AppendLine("gitGraph ") | Out-Null
10 | foreach($EntryElement in $Entry){
11 | $output.AppendLine("`t$EntryElement") | Out-Null
12 | }
13 | return $output.ToString()
14 | }
15 | }
--------------------------------------------------------------------------------
/Public/GitGraph/New-MermaidGitGraphEntry.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Management.Automation
2 |
3 | function New-MermaidGitGraphEntry {
4 | [CmdletBinding()]
5 | param()
6 | dynamicparam{
7 | $TypeParameter = [ordered]@{
8 | "commit" = @("id","tag","type")
9 | "Branch" = @("name")
10 | "Merge" = @("name","id","tag","type")
11 | "Checkout" = @("name")
12 | "Cherrypick"= @("id")
13 | }
14 | $TypeName = $PSCmdlet.MyInvocation.InvocationName -replace 'New-MermaidGitGraphEntry'
15 | $SelectedType = $TypeParameter[$TypeName]
16 | $paramDictionary = [RuntimeDefinedParameterDictionary]::new()
17 | foreach($TypeParameterElement in $SelectedType){
18 | $paramDictionary.add($TypeParameterElement,$([RuntimeDefinedParameter]::new(
19 | $TypeParameterElement,
20 | [String],
21 | [Attribute[]]@(
22 | [Parameter]::new()
23 | )
24 | )))
25 | }
26 | # Return the collection of dynamic parameters
27 | $paramDictionary
28 |
29 | }
30 |
31 | end {
32 | if($TypeName -eq "cherrypick"){
33 | $TypeName = "cherry-pick"
34 | }
35 | # Make sure if a 'Name" parameter exists to set this right after the type
36 | $ReturnString = "{0} {1}" -f $($TypeName.ToLower()), $($PSBoundParameters['Name'])
37 |
38 | # Itterate through all parameters and add them to the return string with their value
39 | foreach ($ParameterName in $PSBoundParameters.Keys) {
40 | switch -Regex ($ParameterName) {
41 | 'ID|TAG' { $ReturnString += " $($PSItem): `"$($PSBoundParameters[$PSItem])`"" }
42 | 'Type' { $ReturnString += " $($PSItem): $($PSBoundParameters[$PSItem])" }
43 | }
44 | }
45 |
46 | # Clean things up before returning:
47 | $ReturnString = $ReturnString -replace '\s+', ' '
48 | return $ReturnString
49 | }
50 | }
--------------------------------------------------------------------------------
/Public/Graph/New-MermaidGraph.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidGraph {
2 | [CmdletBinding()]
3 | param (
4 | [ValidateSet("TB","TD","BT","RL","LR")]
5 | $Direction,
6 | [PSCustomObject[]] $NodeConnections,
7 | [switch] $Append,
8 | [string[]] $ClassDefinitions
9 | )
10 |
11 | begin {
12 | $output = [System.Text.StringBuilder]::new()
13 |
14 | }
15 |
16 | process {
17 | $Output.AppendLine("graph $Direction") | Out-Null
18 | foreach($NodeConnection in $NodeConnections){
19 | $Output.AppendLine("`t$NodeConnection") | Out-Null
20 | }
21 | foreach($ClassDefinition in $ClassDefinitions){
22 | $output.AppendLine("`t$ClassDefinition") | Out-Null
23 | }
24 | }
25 |
26 | end {
27 | if(-not $Append){
28 | $output.Insert(0,"``````mermaid`n") | Out-Null
29 | $output.AppendLine('```') | Out-Null
30 | }
31 | return $output.ToString()
32 | }
33 | }
--------------------------------------------------------------------------------
/Public/Graph/New-MermaidGraphLink.ps1:
--------------------------------------------------------------------------------
1 | class LinkType : System.Management.Automation.IValidateSetValuesGenerator {
2 | [String[]] GetValidValues() {
3 | $Global:LinkTypes = @{
4 | 'Link' = '---'
5 | 'Thick' = '==='
6 | 'Dotted' = '-.-'
7 | 'Invisible' = '~~~'
8 | }
9 | return ($Global:LinkTypes).Keys
10 | }
11 | }
12 | class ArrowType : System.Management.Automation.IValidateSetValuesGenerator {
13 | [String[]] GetValidValues() {
14 | $Global:ArrowTypes = @{
15 | 'Dot' = 'o'
16 | 'Cross' = 'x'
17 | 'Arrow' = '>'
18 | }
19 | return ($Global:ArrowTypes).Keys
20 | }
21 | }
22 |
23 |
24 | function New-MermaidGraphLink {
25 | [CmdletBinding()]
26 | param (
27 | $Text ='',
28 | [ValidateSet([LinkType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
29 | $Linktype = 'LinkType',
30 | [ValidateSet([ArrowType],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
31 | $ArrowType = $null,
32 | [switch] $BiDirectional
33 | )
34 |
35 | begin {
36 | $ReturnString = ''
37 | $SelectedLinkType = $Global:LinkTypes[$Linktype]
38 | if(-not([string]::IsNullOrEmpty($ArrowType))){
39 | $SelectedArrowType = $Global:ArrowTypes[$Arrowtype]
40 | $SelectedLinkType += $SelectedArrowType
41 | }
42 | }
43 |
44 | process {
45 | if($BiDirectional -and (-not([string]::IsNullOrEmpty($ArrowType)))){
46 | if($ArrowType -eq "Arrow"){
47 | $SelectedLinkType = $SelectedLinkType -replace '^(.)', '<'
48 | }else{
49 | $SelectedLinkType = "$SelectedArrowType$SelectedLinkType"
50 | }
51 | }
52 |
53 | if(-not [string]::IsNullOrEmpty($Text)){
54 | $Text = "|$Text|"
55 | }
56 | $ReturnString = "{0}{1}" -f $SelectedLinkType, $Text
57 | }
58 |
59 | end {
60 | return $ReturnString
61 | }
62 | }
--------------------------------------------------------------------------------
/Public/Graph/New-MermaidGraphNode.ps1:
--------------------------------------------------------------------------------
1 | class Shape : System.Management.Automation.IValidateSetValuesGenerator {
2 | [String[]] GetValidValues() {
3 | $Global:Shapes = @{
4 | 'RoundEdges' = '(TEXT)'
5 | 'Stadium' = '([TEXT])'
6 | 'subroutine' = '[[TEXT]]'
7 | 'cylindrical' = '[(TEXT)]'
8 | 'circle' = '((TEXT))'
9 | 'asymmetric' = '>TEXT]'
10 | 'rhombus' = '{TEXT}'
11 | 'Parallelogram' ='[/TEXT/]'
12 | 'hexagon' = '{{TEXT}}'
13 | 'AltParallelogram' = '[\TEXT\]'
14 | 'Trapezoid' = '[/TEXT\]'
15 | 'AltTrapezoid' = '[\TEXT/]'
16 | 'DoubleCircle' = '(((TEXT)))'
17 | }
18 | return ($Global:shapes).Keys
19 | }
20 | }
21 |
22 |
23 |
24 | function New-MermaidGraphNode {
25 | [CmdletBinding()]
26 | param (
27 | [ValidateSet([Shape],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
28 | $Shape,
29 | $ID,
30 | $Text,
31 | $Class = $null
32 | )
33 |
34 | begin {
35 | $ReturnString = ''
36 | $SelectedShape = $Global:Shapes[$Shape]
37 | if([string]::IsNullOrEmpty($Text)){
38 | $Text = $ID
39 | }
40 | }
41 |
42 | process {
43 | if(-not ([string]::IsNullOrEmpty($Class))){
44 | $Text = "`"$($Text)`""
45 | $ReturnString = "$ID$($SelectedShape.Replace('TEXT',$Text)):::$Class"
46 | }else {
47 | $ReturnString = "{0}{1}" -f $ID, $SelectedShape.Replace('TEXT',$Text)
48 | }
49 |
50 | }
51 |
52 | end {
53 | return $ReturnString
54 | }
55 | }
--------------------------------------------------------------------------------
/Public/Graph/New-MermaidGraphNodeConnection.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidGraphNodeConnection {
2 | [CmdletBinding()]
3 | param (
4 | $FirstNode,
5 | $SecondNode,
6 | $Link
7 | )
8 |
9 | begin {
10 | $ReturnString = ""
11 | }
12 |
13 | process {
14 | $ReturnString = "{0}{1}{2}" -f $FirstNode, $Link, $SecondNode
15 | }
16 |
17 | end {
18 | return $ReturnString
19 | }
20 | }
--------------------------------------------------------------------------------
/Public/Graph/New-MermaidGraphStyleClassDefinition.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidGraphStyleClassDefinition {
2 | [CmdletBinding()]
3 | param (
4 | $Name,
5 | [ValidateScript({
6 |
7 | switch ($psitem) {
8 | {$psitem -notmatch '^#(?:[0-9a-fA-F]{3}){1,2}$'}{
9 | throw "The provided color is not a valid hex value"
10 | }
11 | Default {
12 | $true
13 | }
14 | }
15 | })]
16 | $FillColor,
17 | [ValidateScript({
18 |
19 | switch ($psitem) {
20 | {$psitem -notmatch '^#(?:[0-9a-fA-F]{3}){1,2}$'}{
21 | throw "The provided color is not a valid hex value"
22 | }
23 | Default {
24 | $true
25 | }
26 | }
27 | })]
28 | $StrokeColor,
29 | [int]$StrokeWidth = 2
30 | )
31 |
32 | begin {
33 | $ReturnString = ""
34 | }
35 |
36 | process {
37 | $ReturnString += "classDef $Name "
38 | $Definitions =New-Object -TypeName "System.Collections.Generic.List[String]"
39 | if(-not([string]::IsNullOrEmpty($FillColor))){
40 | $Definitions.Add("fill:$FillColor")
41 | }
42 | if(-not([string]::IsNullOrEmpty($StrokeColor))){
43 | $Definitions.Add("stroke:$StrokeColor")
44 | }
45 | if(-not([string]::IsNullOrEmpty($StrokeWidth))){
46 | $Definitions.Add("stroke-width:$($StrokeWidth)px")
47 | }
48 | $ReturnString += $Definitions -join ","
49 | }
50 |
51 | end {
52 | return $ReturnString
53 | }
54 | }
--------------------------------------------------------------------------------
/Public/Journey/New-MermaidJourney.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidJourney {
2 | [CmdletBinding()]
3 | param (
4 | $Title,
5 | [string[]] $Section
6 | )
7 |
8 | begin {
9 | $output = [System.Text.StringBuilder]::new()
10 | $output.AppendLine("journey") | Out-Null
11 | }
12 |
13 | process {
14 | $output.AppendLine("`ttitle $Title") | Out-Null
15 | foreach($SectionElement in $Section){
16 | $output.AppendLine($SectionElement) |Out-Null
17 | }
18 | }
19 |
20 | end {
21 | return $output.ToString()
22 | }
23 | }
--------------------------------------------------------------------------------
/Public/Journey/New-MermaidJourneySection.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidJourneySection {
2 | [CmdletBinding()]
3 | param (
4 | $Title,
5 | [string[]]$Task
6 | )
7 |
8 | begin {
9 | $output = [System.Text.StringBuilder]::new()
10 | $output.AppendLine("`tsection $Title") | Out-Null
11 | }
12 |
13 | process {
14 | foreach($TaskElement in $Task){
15 | $output.AppendLine("`t`t$TaskElement") | Out-Null
16 | }
17 | }
18 |
19 | end {
20 | return $output.ToString()
21 | }
22 | }
--------------------------------------------------------------------------------
/Public/Journey/New-MermaidJourneyTask.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidJourneyTask {
2 | [CmdletBinding()]
3 | param (
4 | $Name,
5 | [string[]] $Actor,
6 | [ValidateRange(0, 7)]
7 | [int]$Score
8 | )
9 |
10 | begin {
11 | $ReturnString = ""
12 |
13 | }
14 |
15 | process {
16 | $ReturnString = "{0}: {1}: {2}" -f $Name,$Score,$($Actor -join ",")
17 | }
18 |
19 | end {
20 | return $ReturnString
21 | }
22 | }
--------------------------------------------------------------------------------
/Public/Pie/New-MermaidPie.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidPie {
2 | [CmdletBinding()]
3 | param (
4 | $Title,
5 | [switch] $ShowData,
6 | [string[]] $DataSet,
7 | [float]$TextPosition = 0.5,
8 | $PieOuterStrokeWidth = "5px"
9 | )
10 |
11 | begin {
12 | $output = [System.Text.StringBuilder]::new()
13 | $Preline = '%%{init: {"pie": {"textPosition": RPTEXTPOSITION}, "themeVariables": {"pieOuterStrokeWidth": "RPPieOuterStrokeWidth"}} }%%'
14 | $PreLine = ($Preline.Replace('RPTEXTPOSITION',$TextPosition)).Replace('RPPieOuterStrokeWidth',$PieOuterStrokeWidth)
15 | $output.AppendLine($Preline) | Out-Null
16 | $output.AppendLine("pie $(if($ShowData){'showData'})") | Out-Null
17 | }
18 |
19 | process {
20 | $output.AppendLine("`ttitle $Title") | Out-Null
21 | foreach($DataSetElement in $DataSet){
22 | $output.AppendLine("`t$DataSetElement") | Out-Null
23 | }
24 |
25 | }
26 |
27 | end {
28 | return $output.ToString()
29 | }
30 | }
--------------------------------------------------------------------------------
/Public/Pie/New-MermaidPieDataSet.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidPieDataSet {
2 | [CmdletBinding()]
3 | param (
4 | $Name,
5 | [float]$Value
6 | )
7 |
8 | begin {
9 | $Value = [math]::Round($Value,2)
10 | $ReturnString = ""
11 | }
12 |
13 | process {
14 | $ReturnString = "`"{0}`" : {1}" -f $Name, $Value
15 | }
16 |
17 | end {
18 | return $ReturnString
19 | }
20 | }
--------------------------------------------------------------------------------
/Public/QuadrantChart/New-MermaidQuadrantChart.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidQuadrantChart {
2 | [CmdletBinding()]
3 | param (
4 | $Title,
5 | $XAxis,
6 | $YAxis,
7 | [string[]]$Quadrant,
8 | [string[]]$DataSet
9 |
10 | )
11 |
12 | begin {
13 | $output = [System.Text.StringBuilder]::new()
14 | $output.AppendLine("quadrantChart") | Out-Null
15 | }
16 |
17 | process {
18 | if(-not ([string]::IsNullOrEmpty($Title))){
19 | $output.AppendLine("`ttitle $Title") | Out-Null
20 | }
21 | $output.AppendLine("`t$XAxis") | Out-Null
22 | $output.AppendLine("`t$yAxis") | Out-Null
23 | foreach($QuadrantElement in $Quadrant){
24 | $output.AppendLine("`t$QuadrantElement") | Out-Null
25 | }
26 | foreach($DataSetElement in $DataSet){
27 | $output.AppendLine("`t$DataSetElement") | Out-Null
28 | }
29 | }
30 |
31 | end {
32 | return $output.ToString()
33 | }
34 | }
--------------------------------------------------------------------------------
/Public/QuadrantChart/New-MermaidQuadrantChartAxis.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidQuadrantChartAxis {
2 | [CmdletBinding()]
3 | param (
4 | $From,
5 | $To,
6 | [ValidateSet("x","y")]
7 | $Axis
8 | )
9 |
10 | begin {
11 | $ReturnString = ""
12 | }
13 |
14 | process {
15 | $ReturnString = "{0}-axis {1} --> {2}" -f $Axis, $From, $To
16 | }
17 |
18 | end {
19 | return $ReturnString
20 | }
21 | }
--------------------------------------------------------------------------------
/Public/QuadrantChart/New-MermaidQuadrantChartDataSet.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidQuadrantChartDataSet {
2 | [CmdletBinding()]
3 | param (
4 | [ValidateRange(0.0, 1.0)]
5 | [float]$XPosition,
6 | [ValidateRange(0.0, 1.0)]
7 | [float]$YPosition,
8 | $Name
9 | )
10 |
11 | begin {
12 | $ReturnString = ""
13 | }
14 |
15 | process {
16 | $ReturnString = "{0}: [{1}, {2}]" -f $Name, $XPosition, $YPosition
17 | }
18 |
19 | end {
20 | return $ReturnString
21 | }
22 | }
--------------------------------------------------------------------------------
/Public/QuadrantChart/New-MermaidQuadrantChartQuadrant.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidQuadrantChartQuadrant {
2 | [CmdletBinding()]
3 | param (
4 | $Number,
5 | $Text
6 | )
7 |
8 | begin {
9 | $ReturnString = ""
10 | }
11 |
12 | process {
13 | $ReturnString = "quadrant-{0} {1}" -f $Number, $Text
14 | }
15 |
16 | end {
17 | return $ReturnString
18 | }
19 | }
--------------------------------------------------------------------------------
/Public/Timeline/New-MermaidTimeline.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidTimeline {
2 | [CmdletBinding()]
3 | param (
4 | $Directive,
5 | [Parameter(ParameterSetName="DataSet")]
6 | [String[]]$DataSet,
7 | [Parameter(ParameterSetName="Section")]
8 | [String[]]$Section,
9 | $Title = $null
10 | )
11 |
12 | begin {
13 | $output = [System.Text.StringBuilder]::new()
14 | $output.AppendLine("timeline") | Out-Null
15 | if(-not([string]::IsNullOrEmpty($Title))){
16 | $output.AppendLine("`ttitle $Title") | Out-Null
17 | }
18 | }
19 |
20 | process {
21 | switch ($PSCmdlet.ParameterSetName) {
22 | 'Section' {
23 | foreach($SectionElement in $Section){
24 | $output.Append($SectionElement) | Out-Null
25 | }
26 | }
27 | Default {
28 | foreach($DataSetElement in $DataSet){
29 | $output.AppendLine("`t$DataSetElement") | Out-Null
30 | }
31 | }
32 | }
33 |
34 | }
35 |
36 | end {
37 | return $output.ToString()
38 | }
39 | }
--------------------------------------------------------------------------------
/Public/Timeline/New-MermaidTimelineDataSet.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidTimelineDataSet {
2 | [CmdletBinding()]
3 | param (
4 | $TimePeriod,
5 | [string[]]$Events
6 | )
7 |
8 | begin {
9 | $ReturnString = ""
10 | }
11 |
12 | process {
13 | $ReturnString = "{0} : {1}" -f $TimePeriod, $($Events -join " : ")
14 | }
15 |
16 | end {
17 | return $ReturnString
18 | }
19 | }
--------------------------------------------------------------------------------
/Public/Timeline/New-MermaidTimelineDirective.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidTimelineDirective {
2 | [CmdletBinding()]
3 | param (
4 | [ValidateSet("base","forest","dark","default","neutral")]
5 | $Theme,
6 | [switch] $DisableMulticolor
7 | )
8 |
9 | begin {
10 | $ReturnString = ""
11 | }
12 |
13 | process {
14 | $ReturnString = (("%%{init: {'logLevel': 'debug', 'theme': 'RPTHEME', 'timeline': {'disableMulticolor': RPDISABLEMULTICOLOR}}}%%").Replace('RPTHEME',$Theme)).Replace('RPDISABLEMULTICOLOR',$DisableMulticolor)
15 |
16 | }
17 |
18 | end {
19 | return $ReturnString
20 | }
21 | }
--------------------------------------------------------------------------------
/Public/Timeline/New-MermaidTimelineSection.ps1:
--------------------------------------------------------------------------------
1 | function New-MermaidTimelineSection {
2 | [CmdletBinding()]
3 | param (
4 | $Name,
5 | [string[]]$DataSet
6 | )
7 |
8 | begin {
9 | $output = [System.Text.StringBuilder]::new()
10 | $output.AppendLine("`tsection $Name") | Out-Null
11 | }
12 |
13 | process {
14 | foreach($DataSetElement in $DataSet){
15 | $output.AppendLine("`t`t$DataSetElement") | Out-Null
16 | }
17 | }
18 |
19 | end {
20 | return $output.ToString()
21 | }
22 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PSMermaid
2 |
3 | 
4 |
5 | Easily Create Mermaid Markdown Files in PowerShell
6 |
7 | A large list with examples you can find [here](https://github.com/HCRitter/PSMermaid/blob/main/EXAMPLES.md).
8 |
9 | The full changelog you can find [here](https://github.com/HCRitter/PSMermaid/blob/main/CHANGELOG.md).
10 |
11 | ## Implementation overview
12 |
13 | - [x] Graph / FlowChart
14 | - [x] Class Diagram
15 | - [x] User Journey
16 | - [x] Pie Chart
17 | - [x] Timeline
18 | - [x] Quadrant Chart
19 | - [x] Entity Relationship Diagrams
20 | - [x] GitGraph
21 | - [ ] Sequence Diagram
22 | - [ ] State Diagram
23 | - [ ] Gantt
24 | - [ ] Requirement Diagram
25 |
26 | ## Changelog
27 |
28 | ### Version 0.1.1
29 |
30 | #### Changes
31 |
32 | - Added basic functionality to create a 'gitGraphs'
33 | - Following new functions: 'New-MermaidGitGraph', 'New-MermaidGitGraphEntry' created
34 |
35 | ### Version 0.1.0
36 |
37 | #### Changes
38 |
39 | - Added basic functionality to create a 'ERDiagram' (EntityRelationship-Diagram)
40 | - Following new functions: 'New-MermaidERDiagram','New-MermaidERDiagramEntity', 'New-MermaidERDiagramEntityAttribute','New-MermaidERDiagramRelationShip', 'New-MermaidERDiagramRelationShipType' created
41 |
42 | ### Version 0.0.9
43 |
44 | #### Changes
45 |
46 | - Added basic functionality to create a 'QuardrantChart'
47 | - Following new functions: 'New-MermaidQuadrantChart','New-MermaidQuadrantChartAxis', 'New-MermaidQuadrantChartDataSet','New-MermaidQuadrantChartQuadrant' created
48 |
49 | ### Version 0.0.8
50 |
51 | #### Changes
52 |
53 | - Added basic functionality to create a 'Timeline'
54 | - Following new functions: 'New-MermaidTimeLine','New-MermaidTimelineDataSet', 'New-MermaidTimelineSection','New-MermaidTimelineDirective' created
55 |
56 | ### Version 0.0.7
57 |
58 | #### Changes
59 |
60 | - Added basic functionality to create a 'pie chart'
61 | - Following new functions: 'New-MermaidPie','New-MermaidPieDataSet' created
62 |
63 | ## Examples
64 |
65 | ### Creating a Graph in one big step
66 |
67 | ```powershell
68 | New-MermaidGraph -Direction LR -NodeConnections @(
69 | $(
70 | $newMermaidNodeConnectionSplat = @{
71 | FirstNode = $(New-MermaidGraphNode -Shape RoundEdges -ID ID1 -Text "Frankfurt am Main" -Class "Starter")
72 | SecondNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
73 | Link = $(New-MermaidGraphLink -Text "traveling to:" -Linktype Link -ArrowType Cross)
74 | }
75 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
76 | ),
77 | $(
78 | $newMermaidNodeConnectionSplat = @{
79 | FirstNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
80 | SecondNode = $(New-MermaidGraphNode -Shape subroutine -ID ID3 -Text "Enjoying for 4 Days")
81 | Link = $(New-MermaidGraphLink -Linktype Dotted -ArrowType Arrow -BiDirectional)
82 | }
83 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
84 | ),
85 | $(
86 | $newMermaidNodeConnectionSplat = @{
87 | FirstNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
88 | SecondNode = $(New-MermaidGraphNode -Shape RoundEdges -ID ID1 -Text "Frankfurt am Main")
89 | Link = $(New-MermaidGraphLink -Text "traveling home:" -Linktype Link -ArrowType Dot)
90 | }
91 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
92 | )
93 | ) -ClassDefinitions @(
94 | New-MermaidGraphStyleClassDefinition -Name "Starter" -FillColor "#6699ff" -StrokeColor "#999966"
95 | )
96 | ```
97 |
98 | ```mermaid
99 | graph LR
100 | ID1("Frankfurt am Main"):::Starter---x|traveling to:|ID2(((PSConfEU2024)))
101 | ID2(((PSConfEU2024)))<.->ID3[[Enjoying for 4 Days]]
102 | ID2(((PSConfEU2024)))---o|traveling home:|ID1(Frankfurt am Main)
103 | classDef Starter fill:#6699ff,stroke:#999966,stroke-width:2px
104 | ```
105 |
106 | ### Creating a classDiagram in one big step
107 |
108 | ```powershell
109 | $newMermaidClassDiagramSplat = @{
110 | Class = @(
111 | $(
112 | $newMermaidClassSplat = @{
113 | Name = 'Animal'
114 | property = @(
115 | $(
116 | $newmermaidclasspropertySplat = @{
117 | Accessability = 'Public'
118 | Name = 'age'
119 | Datatype = 'int'
120 | }
121 | new-mermaidclassproperty @newmermaidclasspropertySplat
122 | ),
123 | $(
124 | $newmermaidclasspropertySplat = @{
125 | Accessability = 'Public'
126 | Name = 'Gender'
127 | Datatype = 'String'
128 | }
129 | new-mermaidclassproperty @newmermaidclasspropertySplat
130 | )
131 | )
132 | Method = @(
133 | $(
134 | $newMermaidClassMethodSplat = @{
135 | Encapsulation = 'Public'
136 | Name = 'isMammal'
137 | }
138 | New-MermaidClassMethod @newMermaidClassMethodSplat
139 | ),
140 | $(
141 | $newMermaidClassMethodSplat = @{
142 | Encapsulation = 'Public'
143 | Name = 'mate'
144 | }
145 | New-MermaidClassMethod @newMermaidClassMethodSplat
146 | )
147 | )
148 | }
149 | New-MermaidClass @newMermaidClassSplat
150 | ),
151 | $(
152 | $newMermaidClassSplat = @{
153 | Name = 'Fish'
154 | property = @(
155 | $(
156 | $newmermaidclasspropertySplat = @{
157 | Accessability = 'Private'
158 | Name = 'sizeInFeet'
159 | Datatype = 'int'
160 | }
161 | new-mermaidclassproperty @newmermaidclasspropertySplat
162 | )
163 | )
164 | Method = @(
165 | $(
166 | $newMermaidClassMethodSplat = @{
167 | Encapsulation = 'Private'
168 | Name = 'canEat'
169 | }
170 | New-MermaidClassMethod @newMermaidClassMethodSplat
171 | )
172 | )
173 | }
174 | New-MermaidClass @newMermaidClassSplat
175 | ),
176 | $(
177 | $newMermaidClassSplat = @{
178 | Name = 'Duck'
179 | property = @(
180 | $(
181 | $newmermaidclasspropertySplat = @{
182 | Accessability = 'Public'
183 | Name = 'beackColor'
184 | Datatype = 'string'
185 | }
186 | new-mermaidclassproperty @newmermaidclasspropertySplat
187 | )
188 | )
189 | Method = @(
190 | $(
191 | $newMermaidClassMethodSplat = @{
192 | Encapsulation = 'Public'
193 | Name = 'swim'
194 | }
195 | New-MermaidClassMethod @newMermaidClassMethodSplat
196 | ),
197 | $(
198 | $newMermaidClassMethodSplat = @{
199 | Encapsulation = 'Public'
200 | Name = 'quack'
201 | }
202 | New-MermaidClassMethod @newMermaidClassMethodSplat
203 | )
204 | )
205 | }
206 | New-MermaidClass @newMermaidClassSplat
207 | )
208 | )
209 | RelationShip = @(
210 | $(
211 | $newMermaidClassRelationShipSplat = @{
212 | RelationShipType = 'Inheritance'
213 | FirstClass = 'Animal'
214 | SecondClass = 'Duck'
215 | }
216 |
217 | New-MermaidClassRelationShip @newMermaidClassRelationShipSplat
218 | ),
219 | $(
220 | $newMermaidClassRelationShipSplat = @{
221 | RelationShipType = 'Inheritance'
222 | FirstClass = 'Animal'
223 | SecondClass = 'Fish'
224 | }
225 |
226 | New-MermaidClassRelationShip @newMermaidClassRelationShipSplat
227 | )
228 | )
229 | }
230 |
231 | New-MermaidClassDiagram @newMermaidClassDiagramSplat
232 | ```
233 |
234 | ```mermaid
235 | classDiagram
236 | class Animal{
237 | +int age
238 | +String Gender
239 | +isMammal()
240 | +mate()
241 | }
242 | class Fish{
243 | -int sizeInFeet
244 | -canEat()
245 | }
246 | class Duck{
247 | +string beackColor
248 | +swim()
249 | +quack()
250 | }
251 | Animal <|-- Duck
252 | Animal <|-- Fish
253 | ```
254 |
255 | ### Creating a UserJourney in one big step
256 |
257 | ```powershell
258 | New-MermaidJourney -Title "My working day" -Section @(
259 | $(
260 | New-MermaidJourneySection -Title "Go to work" -Task @(
261 | $(
262 | New-MermaidJourneyTask -Name "Make teak" -Score 5 -Actor @("Me")
263 | ),
264 | $(
265 | New-MermaidJourneyTask -Name "Go upstairs" -Score 3 -Actor @("Me")
266 | ),
267 | $(
268 | New-MermaidJourneyTask -Name "Do work" -Score 1 -Actor @("Me, Cat")
269 | )
270 | )
271 | ),
272 | $(
273 | New-MermaidJourneySection -Title "Go home" -Task @(
274 | $(
275 | New-MermaidJourneyTask -Name "Go downstairs" -Score 5 -Actor @("Me")
276 | ),
277 | $(
278 | New-MermaidJourneyTask -Name "Sit down" -Score 5 -Actor @("Me")
279 | )
280 | )
281 | )
282 | )
283 | ```
284 |
285 | ```mermaid
286 | journey
287 | title My working day
288 | section Go to work
289 | Make teak: 5: Me
290 | Go upstairs: 3: Me
291 | Do work: 1: Me, Cat
292 |
293 | section Go home
294 | Go downstairs: 5: Me
295 | Sit down: 5: Me
296 | ```
297 |
298 | ### Creating a Pie Chart in one big step
299 |
300 | ```powershell
301 | New-MermaidPie -Title "Key elements in Product X" -ShowData -DataSet @(
302 | $(
303 | New-MermaidPieDataSet -Name Calcium -Value 42.96
304 | ),
305 | $(
306 | New-MermaidPieDataSet -Name Potassium -Value 50.05
307 | ),
308 | $(
309 | New-MermaidPieDataSet -Name Magnesium -Value 10.01
310 | ),
311 | $(
312 | New-MermaidPieDataSet -Name Iron -Value 5
313 | )
314 | )
315 | ```
316 |
317 | ```mermaid
318 | %%{init: {"pie": {"textPosition": 0.5}, "themeVariables": {"pieOuterStrokeWidth": "5px"}} }%%
319 | pie showData
320 | title Key elements in Product X
321 | "Calcium" : 42.96
322 | "Potassium" : 50.05
323 | "Magnesium" : 10.01
324 | "Iron" : 5
325 |
326 | ```
327 |
328 | ### Creating a Time in one big step
329 |
330 | ```powershell
331 | New-MermaidTimeline -Title "England's History Timeline" -Section @(
332 | $(New-MermaidTimelineSection -Name "Stone Age" -DataSet @(
333 | $(New-MermaidTimelineDataSet -TimePeriod "7600 BC" -Events "Britain's oldest known house was built in Orkney, Scotland"),
334 | $(New-MermaidTimelineDataSet -TimePeriod "6000 BC" -Events "Sea levels rise and Britain becomes an island.
The people who live here are hunter-gatherers.")
335 | )),
336 | $(New-MermaidTimelineSection -Name "Bronze Age" -DataSet @(
337 | $(New-MermaidTimelineDataSet -TimePeriod "2300 BC" -Events @("People arrive from Europe and settle in Britain.
They bring farming and metalworking.","New styles of pottery and ways of burying the dead appear.")),
338 | $(New-MermaidTimelineDataSet -TimePeriod "2200 BC" -Events @("The last major building works are completed at Stonehenge.
People now bury their dead in stone circles.","The first metal objects are made in Britain.Some other nice things happen. it is a good time to be alive."))
339 | ))
340 | )
341 | ```
342 |
343 | ```mermaid
344 | timeline
345 | title England's History Timeline
346 | section Stone Age
347 | 7600 BC : Britain's oldest known house was built in Orkney, Scotland
348 | 6000 BC : Sea levels rise and Britain becomes an island.
The people who live here are hunter-gatherers.
349 | section Bronze Age
350 | 2300 BC : People arrive from Europe and settle in Britain.
They bring farming and metalworking. : New styles of pottery and ways of burying the
351 | dead appear.
352 | 2200 BC : The last major building works are completed at Stonehenge.
People now bury their dead in stone circles. : The first metal objects are
353 | made in Britain.Some other nice things happen. it is a good time to be alive.
354 | ```
355 |
356 | ### Creating a Quadrant Chart in one big step
357 |
358 | ```powershell
359 | New-MermaidQuadrantChart -Title "Reach and engagement of campaigns" -XAxis $(New-MermaidQuadrantChartAxis -From "Low Reach" -To "High Reach" -Axis x) -YAxis $(New-MermaidQuadrantChartAxis -From "Low Engagement" -To "High Engagement" -Axis y) -Quadrant @(
360 | $(New-MermaidQuadrantChartQuadrant -Number 1 -Text "We should expand"),
361 | $(New-MermaidQuadrantChartQuadrant -Number 2 -Text "Need to promote"),
362 | $(New-MermaidQuadrantChartQuadrant -Number 3 -Text "Re-evaluate"),
363 | $(New-MermaidQuadrantChartQuadrant -Number 4 -Text "May be improved")
364 | ) -DataSet @(
365 | $(New-MermaidQuadrantChartDataSet -XPosition 0.3 -YPosition 0.6 -Name "Campaign A"),
366 | $(New-MermaidQuadrantChartDataSet -XPosition 0.45 -YPosition 0.23 -Name "Campaign B"),
367 | $(New-MermaidQuadrantChartDataSet -XPosition 0.57 -YPosition 0.69 -Name "Campaign C"),
368 | $(New-MermaidQuadrantChartDataSet -XPosition 0.78 -YPosition 0.34 -Name "Campaign D"),
369 | $(New-MermaidQuadrantChartDataSet -XPosition 0.40 -YPosition 0.34 -Name "Campaign E"),
370 | $(New-MermaidQuadrantChartDataSet -XPosition 0.35 -YPosition 0.78 -Name "Campaign F")
371 | )
372 | ```
373 |
374 | ### Create a ERDiagram
375 |
376 | ```powershell
377 | New-MermaidERDiagram -Entity @(
378 | $(New-MermaidERDiagramEntity -Name "CAR" -Attribute @(
379 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "registrationNumber" -Key Primary ),
380 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "make" ),
381 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "model" ),
382 | $(New-MermaidERDiagramEntityAttribute -Type "string[]" -Name "parts" )
383 | )),
384 | $(New-MermaidERDiagramEntity -Name "PERSON" -Attribute @(
385 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "driversLicense" -Key Primary -Comment "The license #"),
386 | $(New-MermaidERDiagramEntityAttribute -Type "string(99)" -Name "firstname" -Comment "Only 99 characters are allowed"),
387 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "lastname"),
388 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "phone UK")
389 | $(New-MermaidERDiagramEntityAttribute -Type "int" -Name "age")
390 | )),
391 | $(New-MermaidERDiagramEntity -Name "NAMED-DRIVER" -Attribute @(
392 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "carRegistrationNumber" -Key Primary, Foreign),
393 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "driverLicence" -Key Primary, Foreign)
394 | ))
395 | ) -Relationship @(
396 | $(
397 | $newMermaidERDiagramRelationShipSplat = @{
398 | FirstEntityName = "CAR"
399 | SecondEntityName = "NAMED-DRIVER"
400 | RelationTypeLeft = $(New-MermaidERDiagramRelationShipType -Relationshiptype ExactlyOne -Direction Left)
401 | RelationTypeRight = $(New-MermaidERDiagramRelationShipType -Relationshiptype ZeroOrMore -Direction Right)
402 | Comment = "allows"
403 | }
404 | New-MermaidERDiagramRelationShip @newMermaidERDiagramRelationShipSplat
405 | ),
406 | $(
407 | $newMermaidERDiagramRelationShipSplat = @{
408 | FirstEntityName = "PERSON"
409 | SecondEntityName = "NAMED-DRIVER"
410 | RelationTypeLeft = $(New-MermaidERDiagramRelationShipType -Relationshiptype ExactlyOne -Direction Left)
411 | RelationTypeRight = $(New-MermaidERDiagramRelationShipType -Relationshiptype ZeroOrMore -Direction Right)
412 | Comment = "is"
413 | }
414 | New-MermaidERDiagramRelationShip @newMermaidERDiagramRelationShipSplat
415 | )
416 | )
417 | ```
418 |
419 | ```mermaid
420 | erDiagram
421 | CAR {
422 | string registrationNumber PK
423 | string make
424 | string model
425 | string[] parts
426 | }
427 |
428 | PERSON {
429 | string driversLicense PK "The license #"
430 | string(99) firstname "Only 99 characters are allowed"
431 | string lastname
432 | string phone UK
433 | int age
434 | }
435 |
436 | NAMED-DRIVER {
437 | string carRegistrationNumber PK,FK
438 | string driverLicence PK,FK
439 | }
440 |
441 | CAR ||--o{ NAMED-DRIVER : allows
442 | PERSON ||--o{ NAMED-DRIVER : is
443 | ```
444 |
445 |
446 | ### Create a Git Graph
447 | ```powershell
448 | new-MermaidGitGraph -Entry @(
449 | $(New-MermaidGitGraphEntryCommit -id "ZERO"),
450 | $(New-MermaidGitGraphEntryBranch -Name "develop"),
451 | $(New-MermaidGitGraphEntryCommit -id "A"),
452 | $(New-MermaidGitGraphEntryCheckOut -name "main"),
453 | $(New-MermaidGitGraphEntryCommit -id "ONE"),
454 | $(New-MermaidGitGraphEntryCheckOut -name "develop"),
455 | $(New-MermaidGitGraphEntryCommit -id "B"),
456 | $(New-MermaidGitGraphEntryCheckOut -name "main"),
457 | $(New-MermaidGitGraphEntryCommit -id "TWO"),
458 | $(New-MermaidGitGraphEntryCherrypick -id "A"),
459 | $(New-MermaidGitGraphEntryCommit -id "THREE"),
460 | $(New-MermaidGitGraphEntryCheckOut -name "develop"),
461 | $(New-MermaidGitGraphEntryCommit -id "C")
462 | )
463 | ```
464 |
465 | ```mermaid
466 | gitGraph
467 | commit id: "ZERO"
468 | branch develop
469 | commit id: "A"
470 | checkout main
471 | commit id: "ONE"
472 | checkout develop
473 | commit id: "B"
474 | checkout main
475 | commit id: "TWO"
476 | cherry-pick id: "A"
477 | commit id: "THREE"
478 | checkout develop
479 | commit id: "C"
480 | ```
--------------------------------------------------------------------------------
/example.ps1:
--------------------------------------------------------------------------------
1 |
2 | # Create a complex graph / workflow
3 | New-MermaidGraph -Direction LR -NodeConnections @(
4 | $(
5 | $newMermaidNodeConnectionSplat = @{
6 | FirstNode = $(New-MermaidGraphNode -Shape RoundEdges -ID ID1 -Text "Frankfurt am Main" -Class "Starter")
7 | SecondNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
8 | Link = $(New-MermaidGraphLink -Text "traveling to:" -Linktype Link -ArrowType Cross)
9 | }
10 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
11 | ),
12 | $(
13 | $newMermaidNodeConnectionSplat = @{
14 | FirstNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
15 | SecondNode = $(New-MermaidGraphNode -Shape subroutine -ID ID3 -Text "Enjoying for 4 Days")
16 | Link = $(New-MermaidGraphLink -Linktype Dotted -ArrowType Arrow -BiDirectional)
17 | }
18 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
19 | ),
20 | $(
21 | $newMermaidNodeConnectionSplat = @{
22 | FirstNode = $(New-MermaidGraphNode -Shape DoubleCircle -ID ID2 -Text "PSConfEU$((Get-Date).Year +1)")
23 | SecondNode = $(New-MermaidGraphNode -Shape RoundEdges -ID ID1 -Text "Frankfurt am Main")
24 | Link = $(New-MermaidGraphLink -Text "traveling home:" -Linktype Link -ArrowType Dot)
25 | }
26 | New-MermaidGraphNodeConnection @newMermaidNodeConnectionSplat
27 | )
28 | ) -ClassDefinitions @(
29 | New-MermaidGraphStyleClassDefinition -Name "Starter" -FillColor "#6699ff" -StrokeColor "#999966"
30 | )
31 |
32 | # Create a complex class diagram
33 | $newMermaidClassDiagramSplat = @{
34 | Class = @(
35 | $(
36 | $newMermaidClassSplat = @{
37 | Name = 'Animal'
38 | property = @(
39 | $(
40 | $newmermaidclasspropertySplat = @{
41 | Accessability = 'Public'
42 | Name = 'age'
43 | Datatype = 'int'
44 | }
45 | new-mermaidclassproperty @newmermaidclasspropertySplat
46 | ),
47 | $(
48 | $newmermaidclasspropertySplat = @{
49 | Accessability = 'Public'
50 | Name = 'Gender'
51 | Datatype = 'String'
52 | }
53 | new-mermaidclassproperty @newmermaidclasspropertySplat
54 | )
55 | )
56 | Method = @(
57 | $(
58 | $newMermaidClassMethodSplat = @{
59 | Encapsulation = 'Public'
60 | Name = 'isMammal'
61 | }
62 | New-MermaidClassMethod @newMermaidClassMethodSplat
63 | ),
64 | $(
65 | $newMermaidClassMethodSplat = @{
66 | Encapsulation = 'Public'
67 | Name = 'mate'
68 | }
69 | New-MermaidClassMethod @newMermaidClassMethodSplat
70 | )
71 | )
72 | }
73 | New-MermaidClass @newMermaidClassSplat
74 | ),
75 | $(
76 | $newMermaidClassSplat = @{
77 | Name = 'Fish'
78 | property = @(
79 | $(
80 | $newmermaidclasspropertySplat = @{
81 | Accessability = 'Private'
82 | Name = 'sizeInFeet'
83 | Datatype = 'int'
84 | }
85 | new-mermaidclassproperty @newmermaidclasspropertySplat
86 | )
87 | )
88 | Method = @(
89 | $(
90 | $newMermaidClassMethodSplat = @{
91 | Encapsulation = 'Private'
92 | Name = 'canEat'
93 | }
94 | New-MermaidClassMethod @newMermaidClassMethodSplat
95 | )
96 | )
97 | }
98 | New-MermaidClass @newMermaidClassSplat
99 | ),
100 | $(
101 | $newMermaidClassSplat = @{
102 | Name = 'Duck'
103 | property = @(
104 | $(
105 | $newmermaidclasspropertySplat = @{
106 | Accessability = 'Public'
107 | Name = 'beackColor'
108 | Datatype = 'string'
109 | }
110 | new-mermaidclassproperty @newmermaidclasspropertySplat
111 | )
112 | )
113 | Method = @(
114 | $(
115 | $newMermaidClassMethodSplat = @{
116 | Encapsulation = 'Public'
117 | Name = 'swim'
118 | }
119 | New-MermaidClassMethod @newMermaidClassMethodSplat
120 | ),
121 | $(
122 | $newMermaidClassMethodSplat = @{
123 | Encapsulation = 'Public'
124 | Name = 'quack'
125 | }
126 | New-MermaidClassMethod @newMermaidClassMethodSplat
127 | )
128 | )
129 | }
130 | New-MermaidClass @newMermaidClassSplat
131 | )
132 | )
133 | RelationShip = @(
134 | $(
135 | $newMermaidClassRelationShipSplat = @{
136 | RelationShipType = 'Inheritance'
137 | FirstClass = 'Animal'
138 | SecondClass = 'Duck'
139 | }
140 |
141 | New-MermaidClassRelationShip @newMermaidClassRelationShipSplat
142 | ),
143 | $(
144 | $newMermaidClassRelationShipSplat = @{
145 | RelationShipType = 'Inheritance'
146 | FirstClass = 'Animal'
147 | SecondClass = 'Fish'
148 | }
149 |
150 | New-MermaidClassRelationShip @newMermaidClassRelationShipSplat
151 | )
152 | )
153 | }
154 |
155 | New-MermaidClassDiagram @newMermaidClassDiagramSplat
156 |
157 | # Create a UserJourney
158 | New-MermaidJourney -Title "My working day" -Section @(
159 | $(
160 | New-MermaidJourneySection -Title "Go to work" -Task @(
161 | $(
162 | New-MermaidJourneyTask -Name "Make teak" -Score 5 -Actor @("Me")
163 | ),
164 | $(
165 | New-MermaidJourneyTask -Name "Go upstairs" -Score 3 -Actor @("Me")
166 | ),
167 | $(
168 | New-MermaidJourneyTask -Name "Do work" -Score 1 -Actor @("Me, Cat")
169 | )
170 | )
171 | ),
172 | $(
173 | New-MermaidJourneySection -Title "Go home" -Task @(
174 | $(
175 | New-MermaidJourneyTask -Name "Go downstairs" -Score 5 -Actor @("Me")
176 | ),
177 | $(
178 | New-MermaidJourneyTask -Name "Sit down" -Score 5 -Actor @("Me")
179 | )
180 | )
181 | )
182 | )
183 |
184 | # Create a Pie Chart
185 | New-MermaidPie -Title "Key elements in Product X" -ShowData -DataSet @(
186 | $(
187 | New-MermaidPieDataSet -Name Calcium -Value 42.96
188 | ),
189 | $(
190 | New-MermaidPieDataSet -Name Potassium -Value 50.05
191 | ),
192 | $(
193 | New-MermaidPieDataSet -Name Magnesium -Value 10.01
194 | ),
195 | $(
196 | New-MermaidPieDataSet -Name Iron -Value 5
197 | )
198 | )
199 |
200 | # Create a basic Timeline
201 | New-MermaidTimeline -Title "History of Social Media Platform" -DataSet @(
202 | $(New-MermaidTimelineDataSet -TimePeriod "2002" -Events "LinkedIn"),
203 | $(New-MermaidTimelineDataSet -TimePeriod "2004" -Events @("Facebook","Google")),
204 | $(New-MermaidTimelineDataSet -TimePeriod "2005" -Events "Youtube"),
205 | $(New-MermaidTimelineDataSet -TimePeriod "2006" -Events "Twitter")
206 | )
207 |
208 |
209 | # Create a Timeline with sections
210 | New-MermaidTimeline -Title "England's History Timeline" -Section @(
211 | $(New-MermaidTimelineSection -Name "Stone Age" -DataSet @(
212 | $(New-MermaidTimelineDataSet -TimePeriod "7600 BC" -Events "Britain's oldest known house was built in Orkney, Scotland"),
213 | $(New-MermaidTimelineDataSet -TimePeriod "6000 BC" -Events "Sea levels rise and Britain becomes an island.
The people who live here are hunter-gatherers.")
214 | )),
215 | $(New-MermaidTimelineSection -Name "Bronze Age" -DataSet @(
216 | $(New-MermaidTimelineDataSet -TimePeriod "2300 BC" -Events @("People arrive from Europe and settle in Britain.
They bring farming and metalworking.","New styles of pottery and ways of burying the dead appear.")),
217 | $(New-MermaidTimelineDataSet -TimePeriod "2200 BC" -Events @("The last major building works are completed at Stonehenge.
People now bury their dead in stone circles.","The first metal objects are made in Britain.Some other nice things happen. it is a good time to be alive."))
218 | ))
219 | )
220 |
221 | # Create a Quadrant Chart
222 | New-MermaidQuadrantChart -Title "Reach and engagement of campaigns" -XAxis $(New-MermaidQuadrantChartAxis -From "Low Reach" -To "High Reach" -Axis x) -YAxis $(New-MermaidQuadrantChartAxis -From "Low Engagement" -To "High Engagement" -Axis y) -Quadrant @(
223 | $(New-MermaidQuadrantChartQuadrant -Number 1 -Text "We should expand"),
224 | $(New-MermaidQuadrantChartQuadrant -Number 2 -Text "Need to promote"),
225 | $(New-MermaidQuadrantChartQuadrant -Number 3 -Text "Re-evaluate"),
226 | $(New-MermaidQuadrantChartQuadrant -Number 4 -Text "May be improved")
227 | ) -DataSet @(
228 | $(New-MermaidQuadrantChartDataSet -XPosition 0.3 -YPosition 0.6 -Name "Campaign A"),
229 | $(New-MermaidQuadrantChartDataSet -XPosition 0.45 -YPosition 0.23 -Name "Campaign B"),
230 | $(New-MermaidQuadrantChartDataSet -XPosition 0.57 -YPosition 0.69 -Name "Campaign C"),
231 | $(New-MermaidQuadrantChartDataSet -XPosition 0.78 -YPosition 0.34 -Name "Campaign D"),
232 | $(New-MermaidQuadrantChartDataSet -XPosition 0.40 -YPosition 0.34 -Name "Campaign E"),
233 | $(New-MermaidQuadrantChartDataSet -XPosition 0.35 -YPosition 0.78 -Name "Campaign F")
234 | )
235 |
236 |
237 |
238 | # Create a ERDiagram
239 | New-MermaidERDiagram -Entity @(
240 | $(New-MermaidERDiagramEntity -Name "CAR" -Attribute @(
241 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "registrationNumber" -Key Primary ),
242 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "make" ),
243 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "model" ),
244 | $(New-MermaidERDiagramEntityAttribute -Type "string[]" -Name "parts" )
245 | )),
246 | $(New-MermaidERDiagramEntity -Name "PERSON" -Attribute @(
247 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "driversLicense" -Key Primary -Comment "The license #"),
248 | $(New-MermaidERDiagramEntityAttribute -Type "string(99)" -Name "firstname" -Comment "Only 99 characters are allowed"),
249 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "lastname"),
250 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "phone UK")
251 | $(New-MermaidERDiagramEntityAttribute -Type "int" -Name "age")
252 | )),
253 | $(New-MermaidERDiagramEntity -Name "NAMED-DRIVER" -Attribute @(
254 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "carRegistrationNumber" -Key Primary, Foreign),
255 | $(New-MermaidERDiagramEntityAttribute -Type "string" -Name "driverLicence" -Key Primary, Foreign)
256 | ))
257 | ) -Relationship @(
258 | $(
259 | $newMermaidERDiagramRelationShipSplat = @{
260 | FirstEntityName = "CAR"
261 | SecondEntityName = "NAMED-DRIVER"
262 | RelationTypeLeft = $(New-MermaidERDiagramRelationShipType -Relationshiptype ExactlyOne -Direction Left)
263 | RelationTypeRight = $(New-MermaidERDiagramRelationShipType -Relationshiptype ZeroOrMore -Direction Right)
264 | Comment = "allows"
265 | }
266 | New-MermaidERDiagramRelationShip @newMermaidERDiagramRelationShipSplat
267 | ),
268 | $(
269 | $newMermaidERDiagramRelationShipSplat = @{
270 | FirstEntityName = "PERSON"
271 | SecondEntityName = "NAMED-DRIVER"
272 | RelationTypeLeft = $(New-MermaidERDiagramRelationShipType -Relationshiptype ExactlyOne -Direction Left)
273 | RelationTypeRight = $(New-MermaidERDiagramRelationShipType -Relationshiptype ZeroOrMore -Direction Right)
274 | Comment = "is"
275 | }
276 | New-MermaidERDiagramRelationShip @newMermaidERDiagramRelationShipSplat
277 | )
278 | )
279 |
280 | # Create a Git Graph
281 | new-MermaidGitGraph -Entry @(
282 | $(New-MermaidGitGraphEntryCommit -id "ZERO"),
283 | $(New-MermaidGitGraphEntryBranch -Name "develop"),
284 | $(New-MermaidGitGraphEntryCommit -id "A"),
285 | $(New-MermaidGitGraphEntryCheckOut -name "main"),
286 | $(New-MermaidGitGraphEntryCommit -id "ONE"),
287 | $(New-MermaidGitGraphEntryCheckOut -name "develop"),
288 | $(New-MermaidGitGraphEntryCommit -id "B"),
289 | $(New-MermaidGitGraphEntryCheckOut -name "main"),
290 | $(New-MermaidGitGraphEntryCommit -id "TWO"),
291 | $(New-MermaidGitGraphEntryCherrypick -id "A"),
292 | $(New-MermaidGitGraphEntryCommit -id "THREE"),
293 | $(New-MermaidGitGraphEntryCheckOut -name "develop"),
294 | $(New-MermaidGitGraphEntryCommit -id "C")
295 | )
--------------------------------------------------------------------------------