UNPKG

2.99 kBPlain TextView Raw
1import { COMPODOC_DEFAULTS } from '../utils/defaults';
2
3interface Page {
4 name: string;
5 context: string;
6 path?: string;
7 module?: any;
8 pipe?: any;
9 class?: any;
10 interface?: any;
11 directive?: any;
12 injectable?: any;
13 files?: any;
14 data?: any;
15 depth?: number;
16 pageType?: string;
17}
18
19interface IMainData {
20 output: string;
21 theme: string;
22 extTheme: string;
23 serve: boolean;
24 port: number;
25 open: boolean;
26 assetsFolder: string;
27 documentationMainName: string;
28 documentationMainDescription: string;
29 base: string;
30 hideGenerator: boolean;
31 modules: any;
32 readme: string;
33 additionalpages: Object;
34 pipes: any;
35 classes: any;
36 interfaces: any;
37 components: any;
38 directives: any;
39 injectables: any;
40 miscellaneous: any;
41 routes: any;
42 tsconfig: string;
43 includes: boolean;
44 includesName: string;
45 disableSourceCode: boolean;
46 disableGraph: boolean;
47 disableCoverage: boolean;
48 disablePrivateOrInternalSupport: boolean;
49}
50
51export interface IConfiguration {
52 mainData: IMainData;
53 pages:Array<Page>;
54 addPage(page: Page): void;
55}
56
57export class Configuration implements IConfiguration {
58 private static _instance:Configuration = new Configuration();
59
60 private _pages:Array<Page> = [];
61 private _mainData: IMainData = {
62 output: COMPODOC_DEFAULTS.folder,
63 theme: COMPODOC_DEFAULTS.theme,
64 extTheme: '',
65 serve: false,
66 port: COMPODOC_DEFAULTS.port,
67 open: false,
68 assetsFolder: '',
69 documentationMainName: COMPODOC_DEFAULTS.title,
70 documentationMainDescription: '',
71 base: COMPODOC_DEFAULTS.base,
72 hideGenerator: false,
73 modules: [],
74 readme: '',
75 additionalpages: {},
76 pipes: [],
77 classes: [],
78 interfaces: [],
79 components: [],
80 directives: [],
81 injectables: [],
82 routes: [],
83 miscellaneous: [],
84 tsconfig: '',
85 includes: false,
86 disableSourceCode: COMPODOC_DEFAULTS.disableSourceCode,
87 disableGraph: COMPODOC_DEFAULTS.disableGraph,
88 disableCoverage: COMPODOC_DEFAULTS.disableCoverage,
89 disablePrivateOrInternalSupport: COMPODOC_DEFAULTS.disablePrivateOrInternalSupport
90 };
91
92 constructor() {
93 if(Configuration._instance){
94 throw new Error('Error: Instantiation failed: Use Configuration.getInstance() instead of new.');
95 }
96 Configuration._instance = this;
97 }
98
99 public static getInstance():Configuration
100 {
101 return Configuration._instance;
102 }
103
104 addPage(page: Page) {
105 this._pages.push(page);
106 }
107
108 get pages():Array<Page> {
109 return this._pages;
110 }
111 set pages(pages:Array<Page>) {
112 this._pages = [];
113 }
114
115 get mainData():IMainData {
116 return this._mainData;
117 }
118 set mainData(data:IMainData) {
119 Object.assign(this._mainData, data);
120 }
121};