fix spacing
This commit is contained in:
		| @@ -2,7 +2,9 @@ export class Element { | ||||
|   public name: string; | ||||
|   public parent: string; | ||||
|   public get full_name (): string { | ||||
|     return `${this.parent}_${this.name}`; | ||||
|     if (this.parent) | ||||
|       return `${this.parent}_${this.name}`; | ||||
|     return this.name; | ||||
|   } | ||||
|  | ||||
|   public constructor (name: string, parent = '') { | ||||
|   | ||||
							
								
								
									
										25
									
								
								lib/Graph.ts
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								lib/Graph.ts
									
									
									
									
									
								
							| @@ -10,16 +10,25 @@ export class Graph extends Element { | ||||
|  | ||||
|   // eslint-disable-next-line @typescript-eslint/naming-convention | ||||
|   public toString (level = 0): string { | ||||
|     return `subgraph cluster_${this.full_name} { | ||||
|   ${this.children.map ((c) => c.toString (level + 1)) | ||||
|     .join ('\n  ')} | ||||
|     const header = this.parent | ||||
|       ? `subgraph cluster_${this.full_name}` | ||||
|       : `digraph ${this.full_name}`; | ||||
|     let children = `\n  ${this.children.map ((c) => c.toString (level + 1)) | ||||
|       .join ('\n  ')}\n`; | ||||
|     let nodes = `\n  ${this.nodes.map ((c) => c.toString ()) | ||||
|       .join ('\n  ')}\n`; | ||||
|     let edges = `\n  ${this.edges.map ((c) => c.toString ()) | ||||
|       .join ('\n  ')}\n`; | ||||
|  | ||||
|   ${this.nodes.map ((c) => c.toString ()) | ||||
|     .join ('\n  ')} | ||||
|     if (children === '\n  \n') | ||||
|       children = ''; | ||||
|     if (nodes === '\n  \n') | ||||
|       nodes = ''; | ||||
|     if (edges === '\n  \n') | ||||
|       edges = ''; | ||||
|  | ||||
|   ${this.edges.map ((c) => c.toString ()) | ||||
|     .join ('\n  ')} | ||||
| }`.replace (/\n/gu, `\n${'  '.repeat (level)}`) | ||||
|     return `${header} {${children}${nodes}${edges}}` | ||||
|       .replace (/\n/gu, `\n${'  '.repeat (level)}`) | ||||
|       .replace (/^\s+$/gmu, ''); | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user