mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 16:29:40 +02:00
add tsdoc comments
This commit is contained in:
@@ -16,13 +16,32 @@ export interface ClassNode {
|
|||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Visibility = '#' | '+' | '~' | '-' | '';
|
||||||
|
export const visibilityValues = ['#', '+', '~', '-', ''];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses and stores class diagram member variables/methods.
|
||||||
|
*
|
||||||
|
*/
|
||||||
export class ClassMember {
|
export class ClassMember {
|
||||||
id!: string;
|
id!: string;
|
||||||
cssStyle!: string;
|
cssStyle!: string;
|
||||||
memberType!: 'method' | 'attribute';
|
memberType!: 'method' | 'attribute';
|
||||||
visibility!: string;
|
visibility!: Visibility;
|
||||||
|
/**
|
||||||
|
* denote if static or to determine which css class to apply to the node
|
||||||
|
* @defaultValue ''
|
||||||
|
*/
|
||||||
classifier!: string;
|
classifier!: string;
|
||||||
|
/**
|
||||||
|
* parameters for method
|
||||||
|
* @defaultValue ''
|
||||||
|
*/
|
||||||
parameters!: string;
|
parameters!: string;
|
||||||
|
/**
|
||||||
|
* return type for method
|
||||||
|
* @defaultValue ''
|
||||||
|
*/
|
||||||
returnType!: string;
|
returnType!: string;
|
||||||
|
|
||||||
constructor(input: string, memberType: 'method' | 'attribute') {
|
constructor(input: string, memberType: 'method' | 'attribute') {
|
||||||
@@ -57,7 +76,12 @@ export class ClassMember {
|
|||||||
const methodRegEx = /([#+~-])?(.+)\((.*)\)([\s$*])?(.*)([$*])?/;
|
const methodRegEx = /([#+~-])?(.+)\((.*)\)([\s$*])?(.*)([$*])?/;
|
||||||
const match = input.match(methodRegEx);
|
const match = input.match(methodRegEx);
|
||||||
if (match) {
|
if (match) {
|
||||||
this.visibility = match[1] ? match[1].trim() : '';
|
const detectedVisibility = match[1] ? match[1].trim() : '';
|
||||||
|
|
||||||
|
if (visibilityValues.includes(detectedVisibility)) {
|
||||||
|
this.visibility = detectedVisibility as Visibility;
|
||||||
|
}
|
||||||
|
|
||||||
this.id = match[2].trim();
|
this.id = match[2].trim();
|
||||||
this.parameters = match[3] ? match[3].trim() : '';
|
this.parameters = match[3] ? match[3].trim() : '';
|
||||||
potentialClassifier = match[4] ? match[4].trim() : '';
|
potentialClassifier = match[4] ? match[4].trim() : '';
|
||||||
@@ -76,8 +100,8 @@ export class ClassMember {
|
|||||||
const firstChar = input.substring(0, 1);
|
const firstChar = input.substring(0, 1);
|
||||||
const lastChar = input.substring(length - 1);
|
const lastChar = input.substring(length - 1);
|
||||||
|
|
||||||
if (firstChar.match(/[#+~-]/)) {
|
if (visibilityValues.includes(firstChar)) {
|
||||||
this.visibility = firstChar;
|
this.visibility = firstChar as Visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastChar.match(/[*?]/)) {
|
if (lastChar.match(/[*?]/)) {
|
||||||
|
Reference in New Issue
Block a user