Created
September 16, 2021 00:06
-
-
Save TravisMullen/3a358e084e6461b482df148c4d879273 to your computer and use it in GitHub Desktop.
Helper for Mermaid Diagrams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// classDiagram | |
// [classA][Arrow][ClassB]:LabelText | |
// classA <|-- classB | |
// classC *-- classD | |
// classE o-- classF | |
// classG <-- classH | |
// classI -- classJ | |
// classK <.. classL | |
// classM <|.. classN | |
// classO .. classP | |
// Type Description | |
const relationshipTypes = Object.assign({}, | |
...Object.entries({ | |
'<|--': 'Inheritance', | |
'*--': 'Composition', | |
'o--': 'Aggregation', | |
'-->': 'Association', | |
'--': 'Link Solid', | |
'..>': 'Dependency', | |
'..|>': 'Realization', | |
'..': 'Link Dashed' | |
}) | |
.map(([ type, desc ]) => ({ | |
[ desc.toLowerCase().replace(' ', '-') ] : type | |
})) | |
) | |
console.log(relationshipTypes) | |
const defineRelationship = (classNameA, classNameB, relationshipLabel = 'requires', relationship = 'dependency') => { | |
return `${classNameA} ${relationshipTypes[relationship]} ${classNameB}: ${relationshipLabel}` | |
} | |
console.log(defineRelationship('Entity Service','Search Service')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment