Skip to content

Commit

Permalink
Merge pull request #70 from demike/fix/link-for-not-exported-types
Browse files Browse the repository at this point in the history
fix: link for not exported types
  • Loading branch information
demike authored Aug 27, 2023
2 parents 1631b66 + 8747b1a commit b87034e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 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.10.0",
"version": "0.12.0",
"description": "UML diagrams for TypeScript",
"main": "dist/lib/index.js",
"bin": {
Expand Down
17 changes: 12 additions & 5 deletions src/core/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export function parseClasses(classDeclaration: SimpleAST.ClassDeclaration) {
const methodDeclarations = classDeclaration.getMethods();
const ctors = classDeclaration.getConstructors();

let id = classDeclaration.getSymbol()?.getFullyQualifiedName() ?? "";
const sourceFile = classDeclaration.getSourceFile();
let id = `"${sourceFile.getDirectoryPath()}/${sourceFile.getBaseNameWithoutExtension()}".${className}`;

if (!id.length) {
console.error("missing class id");
}
Expand Down Expand Up @@ -49,7 +51,9 @@ export function parseInterfaces(interfaceDeclaration: SimpleAST.InterfaceDeclara
const propertyDeclarations = interfaceDeclaration.getProperties();
const methodDeclarations = interfaceDeclaration.getMethods();

let id = interfaceDeclaration.getSymbol()?.getFullyQualifiedName() ?? "";
const sourceFile = interfaceDeclaration.getSourceFile();
let id = `"${sourceFile.getDirectoryPath()}/${sourceFile.getBaseNameWithoutExtension()}".${interfaceName}`;

if (!id.length) {
console.error("missing interface id");
}
Expand Down Expand Up @@ -78,9 +82,10 @@ export function parseTypes(typeDeclaration: SimpleAST.TypeAliasDeclaration) {
return;
}


const sourceFile = typeDeclaration.getSourceFile();
let id = `"${sourceFile.getDirectoryPath()}/${sourceFile.getBaseNameWithoutExtension()}".${name}`;


let id = typeDeclaration.getSymbol()?.getFullyQualifiedName() ?? "";
if (!id.length) {
console.error("missing type id");
}
Expand Down Expand Up @@ -129,7 +134,9 @@ function parseMethod(methodDeclaration: SimpleAST.MethodDeclaration | SimpleAST.
export function parseEnum(enumDeclaration: SimpleAST.EnumDeclaration) {
const enumName = enumDeclaration.getSymbol()!.getName();

let id = enumDeclaration.getSymbol()?.getFullyQualifiedName() ?? "";
const sourceFile = enumDeclaration.getSourceFile();
let id = `"${sourceFile.getDirectoryPath()}/${sourceFile.getBaseNameWithoutExtension()}".${enumName}`;

if (!id.length) {
console.error("missing class id");
}
Expand Down
7 changes: 7 additions & 0 deletions src/demo/ninja.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { Weapon, Gender } from "./interfaces";

interface Blockade {
magic: number;
physical: number;
}

export class Ninja {

public gender: Gender = Gender.Else;
public static IdCnt=0;
private _weapon: Weapon;
protected secondaryWeapon?: Weapon;
private blockade?: Blockade; // private interface test
public id: number;
public constructor(weapon: Weapon) {
this.id = Ninja.IdCnt++;
Expand Down

0 comments on commit b87034e

Please sign in to comment.