Skip to content

Commit

Permalink
Merge pull request #79 from demike/feat/mermaid-layout-options
Browse files Browse the repository at this point in the history
feat: add mermaid styling and layouting options
  • Loading branch information
demike authored Mar 10, 2024
2 parents 7579605 + 3addb40 commit 0c8d6d3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ tsuml2 --glob "./src/**/!(*.d|*.spec).ts"
-g, --glob pattern to match the source files (i.e.:
./src/**/*.ts) [string] [required]
--tsconfig the path to tsconfig.json file
[default: "./tsconfig.json"]
-o, --outFile the path to the output file [default: "out.svg"]
--propertyTypes show property types and method return types
[boolean] [default: true]
Expand All @@ -56,6 +55,9 @@ tsuml2 --glob "./src/**/!(*.d|*.spec).ts"
--nomnoml "#arrowSize: 1" "#.interface: fill=#8f8
dashed" [array]
--outDsl the path to the output DSL file (nomnoml) [string]
--mermaid mermaid layouting and styling options (an array of
strings, each representing a mermaid line), i.e.:
--mermaid "direction LR" [array]
--outMermaidDsl the path to the output mermaid DSL file [string]
-m, --memberAssociations show associations between classes, interfaces, types
and their member types [boolean] [default: false]
Expand Down
2 changes: 1 addition & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function getNomnomlDSLHeader(settings: TsUML2Settings): string {
}

function getMermaidDSLHeader(settings: TsUML2Settings): string {
return '\nclassDiagram\n';
return '\nclassDiagram\n' + settings.mermaid.join("\n") + '\n';
}


Expand Down
8 changes: 8 additions & 0 deletions src/core/parse-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ import * as fs from "fs";
describe: "the path to the output DSL file (nomnoml)",
string: true,
required: false,
}).option('mermaid', {
describe: "mermaid layouting and styling options (an array of strings, each representing a mermaid line), i.e.: --mermaid \"direction LR\" ",
array: true,
string: true
}).option('outMermaidDsl', {
describe: "the path to the output mermaid DSL file",
string: true,
Expand Down Expand Up @@ -103,6 +107,10 @@ import * as fs from "fs";
settings.outDsl = argv.outDsl;
}

if(argv.mermaid) {
settings.mermaid = argv.mermaid;
}

if(argv.outMermaidDsl != null && !(yargs.parsed as any).defaulted.outMermaidDsl) {
settings.outMermaidDsl = argv.outMermaidDsl;
}
Expand Down
5 changes: 5 additions & 0 deletions src/core/tsuml2-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export class TsUML2Settings {
*/
outMermaidDsl: string = "";

/**
* mermaid layouting and styling options
*/
mermaid: string[] = [];

/**
* show associations between classes, interfaces, types and their member types
*/
Expand Down

0 comments on commit 0c8d6d3

Please sign in to comment.