Skip to content

Commit

Permalink
Merge pull request #82 from demike/fix/declaration-mutation
Browse files Browse the repository at this point in the history
fix/declaration mutation
  • Loading branch information
demike authored Apr 29, 2024
2 parents 0c8d6d3 + 40c0599 commit 485865a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsuml2",
"version": "0.15.0",
"version": "0.16.0",
"description": "UML diagrams for TypeScript",
"main": "dist/lib/index.js",
"bin": {
Expand Down
25 changes: 3 additions & 22 deletions src/core/renderer/nomnoml-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ export class NomnomlTemplate implements Template {
}

private methodTemplate(method: MethodDetails): string {
method = escapeMethodDetails(method);

let retVal = method.name + "()";
if (method.returnType && this.settings.propertyTypes) {
retVal += ": " + method.returnType;
retVal += ": " + escapeNomnoml(method.returnType);
}

retVal = this.modifierTemplate(method.modifierFlags) + retVal;
Expand All @@ -63,14 +61,13 @@ export class NomnomlTemplate implements Template {
}

private propertyTemplate(property: PropertyDetails): string {
property = escapePropertyDetails(property)

let retVal = property.name;
let retVal = escapeNomnoml(property.name);
if (property.type && this.settings.propertyTypes) {
if(property?.optional) {
retVal += "?";
}
retVal += ": " + property.type;
retVal += ": " + escapeNomnoml(property.type);

}

Expand Down Expand Up @@ -115,19 +112,3 @@ export class NomnomlTemplate implements Template {
function escapeNomnoml(str: string) {
return str.replace(/[|\][\#]/g, '\\$&');
}


function escapeMethodDetails(details: MethodDetails) {
if(details.returnType) {
details.returnType = escapeNomnoml(details.returnType);
}
return details;
}

function escapePropertyDetails(details: PropertyDetails) {
details.name = escapeNomnoml(details.name);
if(details.type) {
details.type = escapeNomnoml(details.type);
}
return details;
}

0 comments on commit 485865a

Please sign in to comment.