typedoc 0.17.7 → 0.17.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/application.js +5 -1
- package/dist/lib/application.js.map +1 -1
- package/dist/lib/converter/converter.js +1 -1
- package/dist/lib/converter/converter.js.map +1 -1
- package/dist/lib/converter/factories/declaration.js +21 -3
- package/dist/lib/converter/factories/declaration.js.map +1 -1
- package/dist/lib/converter/plugins/DynamicModulePlugin.js +3 -0
- package/dist/lib/converter/plugins/DynamicModulePlugin.js.map +1 -1
- package/dist/lib/converter/plugins/GitHubPlugin.js +2 -2
- package/dist/lib/converter/plugins/GitHubPlugin.js.map +1 -1
- package/dist/lib/converter/plugins/SourcePlugin.js +3 -0
- package/dist/lib/converter/plugins/SourcePlugin.js.map +1 -1
- package/package.json +2 -2
- package/dist/lib/converter/types/anonymous.d.ts +0 -12
- package/dist/lib/converter/types/anonymous.js +0 -36
- package/dist/lib/converter/types/anonymous.js.map +0 -1
- package/dist/lib/converter2/converter.d.ts +0 -16
- package/dist/lib/converter2/converter.js +0 -35
- package/dist/lib/converter2/converter.js.map +0 -1
- package/dist/lib/converter2/index.d.ts +0 -0
- package/dist/lib/converter2/index.js +0 -1
- package/dist/lib/converter2/index.js.map +0 -1
- package/dist/lib/converter2/symbols/enum.d.ts +0 -0
- package/dist/lib/converter2/symbols/enum.js +0 -1
- package/dist/lib/converter2/symbols/enum.js.map +0 -1
- package/dist/lib/models/types/object.d.ts +0 -12
- package/dist/lib/models/types/object.js +0 -26
- package/dist/lib/models/types/object.js.map +0 -1
package/dist/lib/application.js
CHANGED
|
@@ -124,6 +124,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
124
124
|
function isExcluded(fileName) {
|
|
125
125
|
return exclude.some(mm => mm.match(fileName));
|
|
126
126
|
}
|
|
127
|
+
const includeJson = this.options.getCompilerOptions().resolveJsonModule;
|
|
127
128
|
const supportedFileRegex = this.options.getCompilerOptions().allowJs ? /\.[tj]sx?$/ : /\.tsx?$/;
|
|
128
129
|
function add(file, entryPoint) {
|
|
129
130
|
let stats;
|
|
@@ -148,6 +149,9 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
148
149
|
else if (supportedFileRegex.test(file)) {
|
|
149
150
|
files.push(file);
|
|
150
151
|
}
|
|
152
|
+
else if (includeJson && file.endsWith('.json')) {
|
|
153
|
+
files.push(file);
|
|
154
|
+
}
|
|
151
155
|
}
|
|
152
156
|
inputFiles.forEach(file => {
|
|
153
157
|
add(Path.resolve(file), true);
|
|
@@ -163,7 +167,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
163
167
|
].join(typescript.sys.newLine);
|
|
164
168
|
}
|
|
165
169
|
};
|
|
166
|
-
Application.VERSION = '0.17.
|
|
170
|
+
Application.VERSION = '0.17.8';
|
|
167
171
|
__decorate([
|
|
168
172
|
utils_1.BindOption('logger')
|
|
169
173
|
], Application.prototype, "loggerType", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../src/lib/application.ts"],"names":[],"mappings":";;;;;;;;;AAQA,6BAA6B;AAC7B,yBAAyB;AACzB,yCAAyC;AAEzC,6CAA8C;AAC9C,gDAA6C;AAC7C,mDAA6C;AAC7C,0CAAmD;AACnD,yCAAuG;AACvG,yCAAgD;AAEhD,iDAK2B;AAC3B,mCAA8C;AAkB9C,IAAa,WAAW,mBAAxB,MAAa,WAAY,SAAQ,8BAGhC;IAqDG;QACI,KAAK,CAAC,mCAAuB,CAAC,CAAC;QAE/B,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAa,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,0BAAU,EAAE,CAAC;QACnC,IAAI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AAE,CAAC;GACtC,WAAW,CA6RvB;AA7RY,kCAAW","sourcesContent":["/**\n * The TypeDoc main module and namespace.\n *\n * The [[Application]] class holds the core logic of the cli application. All code related\n * to resolving reflections is stored in [[TypeDoc.Factories]], the actual data models can be found\n * in [[TypeDoc.Models]] and the final rendering is defined in [[TypeDoc.Output]].\n */\n\nimport * as Path from 'path';\nimport * as FS from 'fs';\nimport * as typescript from 'typescript';\n\nimport { Converter } from './converter/index';\nimport { Renderer } from './output/renderer';\nimport { Serializer } from './serialization';\nimport { ProjectReflection } from './models/index';\nimport { Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile, readFile } from './utils/index';\nimport { createMinimatch } from './utils/paths';\n\nimport {\n AbstractComponent,\n ChildableComponent,\n Component,\n DUMMY_APPLICATION_OWNER\n} from './utils/component';\nimport { Options, BindOption } from './utils';\nimport { TypeDocAndTSOptions, TypeDocOptions } from './utils/options/declaration';\n\n/**\n * The default TypeDoc main application class.\n *\n * This class holds the two main components of TypeDoc, the [[Dispatcher]] and\n * the [[Renderer]]. When running TypeDoc, first the [[Dispatcher]] is invoked which\n * generates a [[ProjectReflection]] from the passed in source files. The\n * [[ProjectReflection]] is a hierarchical model representation of the TypeScript\n * project. Afterwards the model is passed to the [[Renderer]] which uses an instance\n * of [[BaseTheme]] to generate the final documentation.\n *\n * Both the [[Dispatcher]] and the [[Renderer]] are subclasses of the [[EventDispatcher]]\n * and emit a series of events while processing the project. Subscribe to these Events\n * to control the application flow or alter the output.\n */\n@Component({ name: 'application', internal: true })\nexport class Application extends ChildableComponent<\n Application,\n AbstractComponent<Application>\n> {\n /**\n * The converter used to create the declaration reflections.\n */\n converter: Converter;\n\n /**\n * The renderer used to generate the documentation output.\n */\n renderer: Renderer;\n\n /**\n * The serializer used to generate JSON output.\n */\n serializer: Serializer;\n\n /**\n * The logger that should be used to output messages.\n */\n logger: Logger;\n\n options: Options;\n\n plugins: PluginHost;\n\n @BindOption('logger')\n loggerType!: string | Function;\n\n @BindOption('ignoreCompilerErrors')\n ignoreCompilerErrors!: boolean;\n\n @BindOption('exclude')\n exclude!: Array<string>;\n\n @BindOption('inputFiles')\n inputFiles!: string[];\n\n @BindOption('options')\n optionsFile!: string;\n\n @BindOption('tsconfig')\n project!: string;\n\n /**\n * The version number of TypeDoc.\n */\n static VERSION = '{{ VERSION }}';\n\n /**\n * Create a new TypeDoc application instance.\n *\n * @param options An object containing the options that should be used.\n */\n constructor() {\n super(DUMMY_APPLICATION_OWNER);\n\n this.logger = new ConsoleLogger();\n this.options = new Options(this.logger);\n this.options.addDefaultDeclarations();\n this.serializer = new Serializer();\n this.converter = this.addComponent<Converter>('converter', Converter);\n this.renderer = this.addComponent<Renderer>('renderer', Renderer);\n this.plugins = this.addComponent('plugins', PluginHost);\n }\n\n /**\n * Initialize TypeDoc with the given options object.\n *\n * @param options The desired options to set.\n */\n bootstrap(options: Partial<TypeDocAndTSOptions> = {}): { hasErrors: boolean, inputFiles: string[] } {\n for (const [key, val] of Object.entries(options)) {\n try {\n this.options.setValue(key as keyof TypeDocOptions, val);\n } catch {\n // Ignore errors, plugins haven't been loaded yet and may declare an option.\n }\n }\n this.options.read(new Logger());\n\n const logger = this.loggerType;\n if (typeof logger === 'function') {\n this.logger = new CallbackLogger(<any> logger);\n this.options.setLogger(this.logger);\n } else if (logger === 'none') {\n this.logger = new Logger();\n this.options.setLogger(this.logger);\n }\n\n this.plugins.load();\n\n this.options.reset();\n for (const [key, val] of Object.entries(options)) {\n try {\n this.options.setValue(key as keyof TypeDocOptions, val);\n } catch (error) {\n this.logger.error(error.message);\n }\n }\n this.options.read(this.logger);\n\n return {\n hasErrors: this.logger.hasErrors(),\n inputFiles: this.inputFiles\n };\n }\n\n /**\n * Return the application / root component instance.\n */\n get application(): Application {\n return this;\n }\n\n /**\n * Return the path to the TypeScript compiler.\n */\n public getTypeScriptPath(): string {\n return Path.dirname(require.resolve('typescript'));\n }\n\n public getTypeScriptVersion(): string {\n const tsPath = this.getTypeScriptPath();\n const json = JSON.parse(readFile(Path.join(tsPath, '..', 'package.json')));\n return json.version;\n }\n\n /**\n * Run the converter for the given set of files and return the generated reflections.\n *\n * @param src A list of source that should be compiled and converted.\n * @returns An instance of ProjectReflection on success, undefined otherwise.\n */\n public convert(src: string[]): ProjectReflection | undefined {\n this.logger.writeln(\n 'Using TypeScript %s from %s',\n this.getTypeScriptVersion(),\n this.getTypeScriptPath()\n );\n\n const result = this.converter.convert(src);\n if (result.errors && result.errors.length) {\n this.logger.diagnostics(result.errors);\n if (this.ignoreCompilerErrors) {\n this.logger.resetErrors();\n return result.project;\n } else {\n return;\n }\n } else {\n return result.project;\n }\n }\n\n /**\n * @param src A list of source files whose documentation should be generated.\n */\n public generateDocs(src: string[], out: string): boolean;\n\n /**\n * @param project The project the documentation should be generated for.\n */\n public generateDocs(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the documentation generator for the given set of files.\n *\n * @param out The path the documentation should be written to.\n * @returns TRUE if the documentation could be generated successfully, otherwise FALSE.\n */\n public generateDocs(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n this.renderer.render(project, out);\n if (this.logger.hasErrors()) {\n this.logger.error('Documentation could not be generated due to the errors above.');\n } else {\n this.logger.success('Documentation generated at %s', out);\n }\n\n return true;\n }\n\n /**\n * @param src A list of source that should be compiled and converted.\n */\n public generateJson(src: string[], out: string): boolean;\n\n /**\n * @param project The project that should be converted.\n */\n public generateJson(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the converter for the given set of files and write the reflections to a json file.\n *\n * @param out The path and file name of the target file.\n * @returns TRUE if the json file could be written successfully, otherwise FALSE.\n */\n public generateJson(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n const eventData = { outputDirectory: Path.dirname(out), outputFile: Path.basename(out) };\n const ser = this.serializer.projectToObject(project, { begin: eventData, end: eventData });\n writeFile(out, JSON.stringify(ser, null, '\\t'), false);\n this.logger.success('JSON written to %s', out);\n\n return true;\n }\n\n /**\n * Expand a list of input files.\n *\n * Searches for directories in the input files list and replaces them with a\n * listing of all TypeScript files within them. One may use the ```--exclude``` option\n * to filter out files with a pattern.\n *\n * @param inputFiles The list of files that should be expanded.\n * @returns The list of input files with expanded directories.\n */\n public expandInputFiles(inputFiles: string[] = []): string[] {\n const files: string[] = [];\n\n const exclude = this.exclude ? createMinimatch(this.exclude) : [];\n\n function isExcluded(fileName: string): boolean {\n return exclude.some(mm => mm.match(fileName));\n }\n\n const supportedFileRegex = this.options.getCompilerOptions().allowJs ? /\\.[tj]sx?$/ : /\\.tsx?$/;\n function add(file: string, entryPoint: boolean) {\n let stats: FS.Stats;\n try {\n stats = FS.statSync(file);\n } catch {\n // No permission or a symbolic link, do not resolve.\n return;\n }\n const fileIsDir = stats.isDirectory();\n if (fileIsDir && !file.endsWith('/')) {\n file = `${file}/`;\n }\n\n if ((!fileIsDir || !entryPoint) && isExcluded(file.replace(/\\\\/g, '/'))) {\n return;\n }\n\n if (fileIsDir) {\n FS.readdirSync(file).forEach(next => {\n add(Path.join(file, next), false);\n });\n } else if (supportedFileRegex.test(file)) {\n files.push(file);\n }\n }\n\n inputFiles.forEach(file => {\n add(Path.resolve(file), true);\n });\n\n return files;\n }\n\n /**\n * Print the version number.\n */\n toString() {\n return [\n '',\n `TypeDoc ${Application.VERSION}`,\n `Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`,\n ''\n ].join(typescript.sys.newLine);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../src/lib/application.ts"],"names":[],"mappings":";;;;;;;;;AAQA,6BAA6B;AAC7B,yBAAyB;AACzB,yCAAyC;AAEzC,6CAA8C;AAC9C,gDAA6C;AAC7C,mDAA6C;AAC7C,0CAAmD;AACnD,yCAAuG;AACvG,yCAAgD;AAE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AW,aAAW,CAAC,OAAO,EAAE;YAChC,oBAAoB,IAAI,CAAC,oBAAoB,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,EAAE;YAClF,EAAE;SACL,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACJ,CAAA;AA/OU,mBAAO,GAAG,eAAe,CAAC;AApBjC;IADC,kBAAU,CAAC,QAAQ,CAAC;+CACU;AAG/B;IADC,kBAAU,CAAC,sBAAsB,CAAC;yDACJ;AAG/B;IADC,kBAAU,CAAC,SAAS,CAAC;4CACE;AAGxB;IADC,kBAAU,CAAC,YAAY,CAAC;+CACH;AAGtB;IADC,kBAAU,CAAC,SAAS,CAAC;gDACD;AAGrB;IADC,kBAAU,CAAC,UAAU,CAAC;4CACN;AA5CR,WAAW;IADvB,qBAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACtC,WAAW,CAgSvB;AAhSY,kCAAW","sourcesContent":["/**\n * The TypeDoc main module and namespace.\n *\n * The [[Application]] class holds the core logic of the cli application. All code related\n * to resolving reflections is stored in [[TypeDoc.Factories]], the actual data models can be found\n * in [[TypeDoc.Models]] and the final rendering is defined in [[TypeDoc.Output]].\n */\n\nimport * as Path from 'path';\nimport * as FS from 'fs';\nimport * as typescript from 'typescript';\n\nimport { Converter } from './converter/index';\nimport { Renderer } from './output/renderer';\nimport { Serializer } from './serialization';\nimport { ProjectReflection } from './models/index';\nimport { Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile, readFile } from './utils/index';\nimport { createMinimatch } from './utils/paths';\n\nimport {\n AbstractComponent,\n ChildableComponent,\n Component,\n DUMMY_APPLICATION_OWNER\n} from './utils/component';\nimport { Options, BindOption } from './utils';\nimport { TypeDocAndTSOptions, TypeDocOptions } from './utils/options/declaration';\n\n/**\n * The default TypeDoc main application class.\n *\n * This class holds the two main components of TypeDoc, the [[Dispatcher]] and\n * the [[Renderer]]. When running TypeDoc, first the [[Dispatcher]] is invoked which\n * generates a [[ProjectReflection]] from the passed in source files. The\n * [[ProjectReflection]] is a hierarchical model representation of the TypeScript\n * project. Afterwards the model is passed to the [[Renderer]] which uses an instance\n * of [[BaseTheme]] to generate the final documentation.\n *\n * Both the [[Dispatcher]] and the [[Renderer]] are subclasses of the [[EventDispatcher]]\n * and emit a series of events while processing the project. Subscribe to these Events\n * to control the application flow or alter the output.\n */\n@Component({ name: 'application', internal: true })\nexport class Application extends ChildableComponent<\n Application,\n AbstractComponent<Application>\n> {\n /**\n * The converter used to create the declaration reflections.\n */\n converter: Converter;\n\n /**\n * The renderer used to generate the documentation output.\n */\n renderer: Renderer;\n\n /**\n * The serializer used to generate JSON output.\n */\n serializer: Serializer;\n\n /**\n * The logger that should be used to output messages.\n */\n logger: Logger;\n\n options: Options;\n\n plugins: PluginHost;\n\n @BindOption('logger')\n loggerType!: string | Function;\n\n @BindOption('ignoreCompilerErrors')\n ignoreCompilerErrors!: boolean;\n\n @BindOption('exclude')\n exclude!: Array<string>;\n\n @BindOption('inputFiles')\n inputFiles!: string[];\n\n @BindOption('options')\n optionsFile!: string;\n\n @BindOption('tsconfig')\n project!: string;\n\n /**\n * The version number of TypeDoc.\n */\n static VERSION = '{{ VERSION }}';\n\n /**\n * Create a new TypeDoc application instance.\n *\n * @param options An object containing the options that should be used.\n */\n constructor() {\n super(DUMMY_APPLICATION_OWNER);\n\n this.logger = new ConsoleLogger();\n this.options = new Options(this.logger);\n this.options.addDefaultDeclarations();\n this.serializer = new Serializer();\n this.converter = this.addComponent<Converter>('converter', Converter);\n this.renderer = this.addComponent<Renderer>('renderer', Renderer);\n this.plugins = this.addComponent('plugins', PluginHost);\n }\n\n /**\n * Initialize TypeDoc with the given options object.\n *\n * @param options The desired options to set.\n */\n bootstrap(options: Partial<TypeDocAndTSOptions> = {}): { hasErrors: boolean, inputFiles: string[] } {\n for (const [key, val] of Object.entries(options)) {\n try {\n this.options.setValue(key as keyof TypeDocOptions, val);\n } catch {\n // Ignore errors, plugins haven't been loaded yet and may declare an option.\n }\n }\n this.options.read(new Logger());\n\n const logger = this.loggerType;\n if (typeof logger === 'function') {\n this.logger = new CallbackLogger(<any> logger);\n this.options.setLogger(this.logger);\n } else if (logger === 'none') {\n this.logger = new Logger();\n this.options.setLogger(this.logger);\n }\n\n this.plugins.load();\n\n this.options.reset();\n for (const [key, val] of Object.entries(options)) {\n try {\n this.options.setValue(key as keyof TypeDocOptions, val);\n } catch (error) {\n this.logger.error(error.message);\n }\n }\n this.options.read(this.logger);\n\n return {\n hasErrors: this.logger.hasErrors(),\n inputFiles: this.inputFiles\n };\n }\n\n /**\n * Return the application / root component instance.\n */\n get application(): Application {\n return this;\n }\n\n /**\n * Return the path to the TypeScript compiler.\n */\n public getTypeScriptPath(): string {\n return Path.dirname(require.resolve('typescript'));\n }\n\n public getTypeScriptVersion(): string {\n const tsPath = this.getTypeScriptPath();\n const json = JSON.parse(readFile(Path.join(tsPath, '..', 'package.json')));\n return json.version;\n }\n\n /**\n * Run the converter for the given set of files and return the generated reflections.\n *\n * @param src A list of source that should be compiled and converted.\n * @returns An instance of ProjectReflection on success, undefined otherwise.\n */\n public convert(src: string[]): ProjectReflection | undefined {\n this.logger.writeln(\n 'Using TypeScript %s from %s',\n this.getTypeScriptVersion(),\n this.getTypeScriptPath()\n );\n\n const result = this.converter.convert(src);\n if (result.errors && result.errors.length) {\n this.logger.diagnostics(result.errors);\n if (this.ignoreCompilerErrors) {\n this.logger.resetErrors();\n return result.project;\n } else {\n return;\n }\n } else {\n return result.project;\n }\n }\n\n /**\n * @param src A list of source files whose documentation should be generated.\n */\n public generateDocs(src: string[], out: string): boolean;\n\n /**\n * @param project The project the documentation should be generated for.\n */\n public generateDocs(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the documentation generator for the given set of files.\n *\n * @param out The path the documentation should be written to.\n * @returns TRUE if the documentation could be generated successfully, otherwise FALSE.\n */\n public generateDocs(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n this.renderer.render(project, out);\n if (this.logger.hasErrors()) {\n this.logger.error('Documentation could not be generated due to the errors above.');\n } else {\n this.logger.success('Documentation generated at %s', out);\n }\n\n return true;\n }\n\n /**\n * @param src A list of source that should be compiled and converted.\n */\n public generateJson(src: string[], out: string): boolean;\n\n /**\n * @param project The project that should be converted.\n */\n public generateJson(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the converter for the given set of files and write the reflections to a json file.\n *\n * @param out The path and file name of the target file.\n * @returns TRUE if the json file could be written successfully, otherwise FALSE.\n */\n public generateJson(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n const eventData = { outputDirectory: Path.dirname(out), outputFile: Path.basename(out) };\n const ser = this.serializer.projectToObject(project, { begin: eventData, end: eventData });\n writeFile(out, JSON.stringify(ser, null, '\\t'), false);\n this.logger.success('JSON written to %s', out);\n\n return true;\n }\n\n /**\n * Expand a list of input files.\n *\n * Searches for directories in the input files list and replaces them with a\n * listing of all TypeScript files within them. One may use the ```--exclude``` option\n * to filter out files with a pattern.\n *\n * @param inputFiles The list of files that should be expanded.\n * @returns The list of input files with expanded directories.\n */\n public expandInputFiles(inputFiles: string[] = []): string[] {\n const files: string[] = [];\n\n const exclude = this.exclude ? createMinimatch(this.exclude) : [];\n\n function isExcluded(fileName: string): boolean {\n return exclude.some(mm => mm.match(fileName));\n }\n\n const includeJson = this.options.getCompilerOptions().resolveJsonModule;\n const supportedFileRegex = this.options.getCompilerOptions().allowJs ? /\\.[tj]sx?$/ : /\\.tsx?$/;\n function add(file: string, entryPoint: boolean) {\n let stats: FS.Stats;\n try {\n stats = FS.statSync(file);\n } catch {\n // No permission or a symbolic link, do not resolve.\n return;\n }\n const fileIsDir = stats.isDirectory();\n if (fileIsDir && !file.endsWith('/')) {\n file = `${file}/`;\n }\n\n if ((!fileIsDir || !entryPoint) && isExcluded(file.replace(/\\\\/g, '/'))) {\n return;\n }\n\n if (fileIsDir) {\n FS.readdirSync(file).forEach(next => {\n add(Path.join(file, next), false);\n });\n } else if (supportedFileRegex.test(file)) {\n files.push(file);\n } else if (includeJson && file.endsWith('.json')) {\n files.push(file);\n }\n }\n\n inputFiles.forEach(file => {\n add(Path.resolve(file), true);\n });\n\n return files;\n }\n\n /**\n * Print the version number.\n */\n toString() {\n return [\n '',\n `TypeDoc ${Application.VERSION}`,\n `Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`,\n ''\n ].join(typescript.sys.newLine);\n }\n}\n"]}
|
|
@@ -82,7 +82,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
82
82
|
this.typeNodeConverters = [];
|
|
83
83
|
}
|
|
84
84
|
convert(fileNames) {
|
|
85
|
-
const normalizedFiles = fileNames.map(fs_1.normalizePath);
|
|
85
|
+
const normalizedFiles = fileNames.map(fs_1.normalizePath).filter(path => !path.endsWith('.json'));
|
|
86
86
|
const program = ts.createProgram(normalizedFiles, this.application.options.getCompilerOptions());
|
|
87
87
|
const checker = program.getTypeChecker();
|
|
88
88
|
const context = new context_1.Context(this, normalizedFiles, checker, program);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../src/lib/converter/converter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iCAAiC;AAEjC,4BAA4B;AAI5B,uCAAoC;AACpC,6CAAwI;AACxI,kDAAmF;AACnF,oCAAsC;AACtC,oCAA4C;AAC5C,0CAAiD;AAqBjD,IAAa,SAAS,iBAAtB,MAAa,SAAU,SAAQ,8BAAmD;IA0I9E,UAAU;QACN,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,kBAAkB,GAAG,E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AG,OAAO,CAAC;AAOtB,mBAAS,GAAG,KAAK,CAAC;AAWlB,0BAAgB,GAAG,WAAW,CAAC;AAO/B,kCAAwB,GAAG,mBAAmB,CAAC;AAO/C,gCAAsB,GAAG,iBAAiB,CAAC;AAO3C,gCAAsB,GAAG,iBAAiB,CAAC;AAO3C,qCAA2B,GAAG,qBAAqB,CAAC;AAOpD,uCAA6B,GAAG,wBAAwB,CAAC;AAWzD,6BAAmB,GAAG,cAAc,CAAC;AAOrC,uBAAa,GAAG,mBAAmB,CAAC;AAOpC,2BAAiB,GAAG,YAAY,CAAC;AA7HxC;IADC,kBAAU,CAAC,MAAM,CAAC;uCACL;AAGd;IADC,kBAAU,CAAC,iBAAiB,CAAC;kDACE;AAGhC;IADC,kBAAU,CAAC,qBAAqB,CAAC;sDACJ;AAG9B;IADC,kBAAU,CAAC,kBAAkB,CAAC;mDACJ;AAG3B;IADC,kBAAU,CAAC,oBAAoB,CAAC;qDACJ;AAG7B;IADC,kBAAU,CAAC,sBAAsB,CAAC;uDACJ;AAG/B;IADC,kBAAU,CAAC,gBAAgB,CAAC;iDACJ;AAGzB;IADC,kBAAU,CAAC,kBAAkB,CAAC;mDACJ;AA1BlB,SAAS;IADrB,qBAAS,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,+BAAkB,EAAC,CAAC;GAClE,SAAS,CAuZrB;AAvZY,8BAAS","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../ts-internal';\nimport * as _ from 'lodash';\n\nimport { Application } from '../application';\nimport { Reflection, Type, ProjectReflection } from '../models/index';\nimport { Context } from './context';\nimport { ConverterComponent, ConverterNodeComponent, ConverterTypeComponent, TypeTypeConverter, TypeNodeConverter } from './components';\nimport { Component, ChildableComponent, ComponentClass } from '../utils/component';\nimport { BindOption } from '../utils';\nimport { normalizePath } from '../utils/fs';\nimport { createMinimatch } from '../utils/paths';\n\n/**\n * Result structure of the [[Converter.convert]] method.\n */\nexport interface ConverterResult {\n /**\n * An array containing all errors generated by the TypeScript compiler.\n */\n errors: ReadonlyArray<ts.Diagnostic>;\n\n /**\n * The resulting project reflection.\n */\n project: ProjectReflection;\n}\n\n/**\n * Compiles source files using TypeScript and converts compiler symbols to reflections.\n */\n@Component({name: 'converter', internal: true, childClass: ConverterComponent})\nexport class Converter extends ChildableComponent<Application, ConverterComponent> {\n /**\n * The human readable name of the project. Used within the templates to set the title of the document.\n */\n @BindOption('name')\n name!: string;\n\n @BindOption('externalPattern')\n externalPattern!: Array<string>;\n\n @BindOption('includeDeclarations')\n includeDeclarations!: boolean;\n\n @BindOption('excludeExternals')\n excludeExternals!: boolean;\n\n @BindOption('excludeNotExported')\n excludeNotExported!: boolean;\n\n @BindOption('excludeNotDocumented')\n excludeNotDocumented!: boolean;\n\n @BindOption('excludePrivate')\n excludePrivate!: boolean;\n\n @BindOption('excludeProtected')\n excludeProtected!: boolean;\n\n /**\n * Defined in the initialize method\n */\n private nodeConverters!: {[syntaxKind: number]: ConverterNodeComponent<ts.Node>};\n\n /**\n * Defined in the initialize method\n */\n private typeNodeConverters!: TypeNodeConverter<ts.Type, ts.Node>[];\n\n /**\n * Defined in the initialize method\n */\n private typeTypeConverters!: TypeTypeConverter<ts.Type>[];\n\n /**\n * General events\n */\n\n /**\n * Triggered when the converter begins converting a project.\n * The listener should implement [[IConverterCallback]].\n * @event\n */\n static EVENT_BEGIN = 'begin';\n\n /**\n * Triggered when the converter has finished converting a project.\n * The listener should implement [[IConverterCallback]].\n * @event\n */\n static EVENT_END = 'end';\n\n /**\n * Factory events\n */\n\n /**\n * Triggered when the converter begins converting a source file.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_FILE_BEGIN = 'fileBegin';\n\n /**\n * Triggered when the converter has created a declaration reflection.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_CREATE_DECLARATION = 'createDeclaration';\n\n /**\n * Triggered when the converter has created a signature reflection.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_CREATE_SIGNATURE = 'createSignature';\n\n /**\n * Triggered when the converter has created a parameter reflection.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_CREATE_PARAMETER = 'createParameter';\n\n /**\n * Triggered when the converter has created a type parameter reflection.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_CREATE_TYPE_PARAMETER = 'createTypeParameter';\n\n /**\n * Triggered when the converter has found a function implementation.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_FUNCTION_IMPLEMENTATION = 'functionImplementation';\n\n /**\n * Resolve events\n */\n\n /**\n * Triggered when the converter begins resolving a project.\n * The listener should implement [[IConverterCallback]].\n * @event\n */\n static EVENT_RESOLVE_BEGIN = 'resolveBegin';\n\n /**\n * Triggered when the converter resolves a reflection.\n * The listener should implement [[IConverterResolveCallback]].\n * @event\n */\n static EVENT_RESOLVE = 'resolveReflection';\n\n /**\n * Triggered when the converter has finished resolving a project.\n * The listener should implement [[IConverterCallback]].\n * @event\n */\n static EVENT_RESOLVE_END = 'resolveEnd';\n\n /**\n * Create a new Converter instance.\n *\n * @param application The application instance this converter relies on. The application\n * must expose the settings that should be used and serves as a global logging endpoint.\n */\n initialize() {\n this.nodeConverters = {};\n this.typeTypeConverters = [];\n this.typeNodeConverters = [];\n }\n\n addComponent<T extends ConverterComponent & Component>(name: string, componentClass: T | ComponentClass<T>): T {\n const component = super.addComponent(name, componentClass);\n if (component instanceof ConverterNodeComponent) {\n this.addNodeConverter(component);\n } else if (component instanceof ConverterTypeComponent) {\n this.addTypeConverter(component);\n }\n\n return component;\n }\n\n private addNodeConverter(converter: ConverterNodeComponent<any>) {\n for (const supports of converter.supports) {\n this.nodeConverters[supports] = converter;\n }\n }\n\n private addTypeConverter(converter: ConverterTypeComponent) {\n if ('supportsNode' in converter && 'convertNode' in converter) {\n this.typeNodeConverters.push(<TypeNodeConverter<any, any>> converter);\n this.typeNodeConverters.sort((a, b) => b.priority - a.priority);\n }\n\n if ('supportsType' in converter && 'convertType' in converter) {\n this.typeTypeConverters.push(<TypeTypeConverter<any>> converter);\n this.typeTypeConverters.sort((a, b) => b.priority - a.priority);\n }\n }\n\n removeComponent(name: string): ConverterComponent | undefined {\n const component = super.removeComponent(name);\n if (component instanceof ConverterNodeComponent) {\n this.removeNodeConverter(component);\n } else if (component instanceof ConverterTypeComponent) {\n this.removeTypeConverter(component);\n }\n\n return component;\n }\n\n private removeNodeConverter(converter: ConverterNodeComponent<any>) {\n const converters = this.nodeConverters;\n const keys = _.keys(this.nodeConverters);\n for (const key of keys) {\n if (converters[key] === converter) {\n delete converters[key];\n }\n }\n }\n\n private removeTypeConverter(converter: ConverterTypeComponent) {\n const typeIndex = this.typeTypeConverters.indexOf(<any> converter);\n if (typeIndex !== -1) {\n this.typeTypeConverters.splice(typeIndex, 1);\n }\n\n const nodeIndex = this.typeNodeConverters.indexOf(<any> converter);\n if (nodeIndex !== -1) {\n this.typeNodeConverters.splice(nodeIndex, 1);\n }\n }\n\n removeAllComponents() {\n super.removeAllComponents();\n\n this.nodeConverters = {};\n this.typeTypeConverters = [];\n this.typeNodeConverters = [];\n }\n\n /**\n * Compile the given source files and create a project reflection for them.\n *\n * @param fileNames Array of the file names that should be compiled.\n */\n convert(fileNames: string[]): ConverterResult {\n const normalizedFiles = fileNames.map(normalizePath);\n\n const program = ts.createProgram(normalizedFiles, this.application.options.getCompilerOptions());\n const checker = program.getTypeChecker();\n const context = new Context(this, normalizedFiles, checker, program);\n\n this.trigger(Converter.EVENT_BEGIN, context);\n\n const errors = this.compile(context);\n const project = this.resolve(context);\n\n const dangling = project.getDanglingReferences();\n if (dangling.length) {\n this.owner.logger.warn([\n 'Some names refer to reflections that do not exist.',\n 'This can be caused by exporting a reflection only under a different name than it is declared when excludeNotExported is set',\n 'or by a plugin removing reflections without removing references. The names that cannot be resolved are:',\n ...dangling\n ].join('\\n'));\n }\n\n this.trigger(Converter.EVENT_END, context);\n\n return {\n errors: errors,\n project: project\n };\n }\n\n /**\n * Analyze the given node and create a suitable reflection.\n *\n * This function checks the kind of the node and delegates to the matching function implementation.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The compiler node that should be analyzed.\n * @return The resulting reflection or undefined.\n */\n convertNode(context: Context, node: ts.Node): Reflection | undefined {\n if (context.visitStack.includes(node)) {\n return;\n }\n\n const oldVisitStack = context.visitStack;\n context.visitStack = oldVisitStack.slice();\n context.visitStack.push(node);\n\n let result: Reflection | undefined;\n if (node.kind in this.nodeConverters) {\n result = this.nodeConverters[node.kind].convert(context, node);\n }\n\n context.visitStack = oldVisitStack;\n return result;\n }\n\n /**\n * Convert the given TypeScript type into its TypeDoc type reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The node whose type should be reflected.\n * @param type The type of the node if already known.\n * @returns The TypeDoc type reflection representing the given node and type.\n */\n convertType(context: Context, node?: ts.Node, type?: ts.Type): Type | undefined {\n // Run all node based type conversions\n if (node) {\n type = type || context.getTypeAtLocation(node);\n\n for (const converter of this.typeNodeConverters) {\n if (converter.supportsNode(context, node, type)) {\n return converter.convertNode(context, node, type);\n }\n }\n }\n\n // Run all type based type conversions\n if (type) {\n for (const converter of this.typeTypeConverters) {\n if (converter.supportsType(context, type)) {\n return converter.convertType(context, type);\n }\n }\n }\n }\n\n /**\n * Helper function to convert multiple types at once, filtering out types which fail to convert.\n *\n * @param context\n * @param nodes\n */\n convertTypes(context: Context, nodes: ReadonlyArray<ts.Node> = [], types: ReadonlyArray<ts.Type> = []): Type[] {\n const result: Type[] = [];\n _.zip(nodes, types).forEach(([node, type]) => {\n const converted = this.convertType(context, node, type);\n if (converted) {\n result.push(converted);\n }\n });\n return result;\n }\n\n /**\n * Compile the files within the given context and convert the compiler symbols to reflections.\n *\n * @param context The context object describing the current state the converter is in.\n * @returns An array containing all errors generated by the TypeScript compiler.\n */\n private compile(context: Context): ReadonlyArray<ts.Diagnostic> {\n const program = context.program;\n const exclude = createMinimatch(this.application.exclude || []);\n const isExcluded = (file: ts.SourceFile) => exclude.some(mm => mm.match(file.fileName));\n const includedSourceFiles = program.getSourceFiles()\n .filter(file => !isExcluded(file));\n\n const errors = this.getCompilerErrors(program, includedSourceFiles);\n if (errors.length) {\n return errors;\n }\n\n includedSourceFiles.forEach((sourceFile) => {\n this.convertNode(context, sourceFile);\n });\n\n return [];\n }\n\n /**\n * Resolve the project within the given context.\n *\n * @param context The context object describing the current state the converter is in.\n * @returns The final project reflection.\n */\n private resolve(context: Context): ProjectReflection {\n this.trigger(Converter.EVENT_RESOLVE_BEGIN, context);\n const project = context.project;\n\n for (const id in project.reflections) {\n if (!project.reflections.hasOwnProperty(id)) {\n continue;\n }\n this.trigger(Converter.EVENT_RESOLVE, context, project.reflections[id]);\n }\n\n this.trigger(Converter.EVENT_RESOLVE_END, context);\n return project;\n }\n\n private getCompilerErrors(program: ts.Program, includedSourceFiles: readonly ts.SourceFile[]): ReadonlyArray<ts.Diagnostic> {\n if (this.application.ignoreCompilerErrors) {\n return [];\n }\n\n const isRelevantError = ({ file }: ts.Diagnostic) => !file || includedSourceFiles.includes(file);\n\n let diagnostics = program.getOptionsDiagnostics().filter(isRelevantError);\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getSyntacticDiagnostics().filter(isRelevantError);\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getGlobalDiagnostics().filter(isRelevantError);\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getSemanticDiagnostics().filter(isRelevantError);\n if (diagnostics.length) {\n return diagnostics;\n }\n\n return [];\n }\n\n /**\n * Return the basename of the default library that should be used.\n *\n * @returns The basename of the default library.\n */\n getDefaultLib(): string {\n return ts.getDefaultLibFileName(this.application.options.getCompilerOptions());\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../src/lib/converter/converter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iCAAiC;AAEjC,4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AAC;GAClE,SAAS,CAyZrB;AAzZY,8BAAS","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../ts-internal';\nimport * as _ from 'lodash';\n\nimport { Application } from '../application';\nimport { Reflection, Type, ProjectReflection } from '../models/index';\nimport { Context } from './context';\nimport { ConverterComponent, ConverterNodeComponent, ConverterTypeComponent, TypeTypeConverter, TypeNodeConverter } from './components';\nimport { Component, ChildableComponent, ComponentClass } from '../utils/component';\nimport { BindOption } from '../utils';\nimport { normalizePath } from '../utils/fs';\nimport { createMinimatch } from '../utils/paths';\n\n/**\n * Result structure of the [[Converter.convert]] method.\n */\nexport interface ConverterResult {\n /**\n * An array containing all errors generated by the TypeScript compiler.\n */\n errors: ReadonlyArray<ts.Diagnostic>;\n\n /**\n * The resulting project reflection.\n */\n project: ProjectReflection;\n}\n\n/**\n * Compiles source files using TypeScript and converts compiler symbols to reflections.\n */\n@Component({name: 'converter', internal: true, childClass: ConverterComponent})\nexport class Converter extends ChildableComponent<Application, ConverterComponent> {\n /**\n * The human readable name of the project. Used within the templates to set the title of the document.\n */\n @BindOption('name')\n name!: string;\n\n @BindOption('externalPattern')\n externalPattern!: Array<string>;\n\n @BindOption('includeDeclarations')\n includeDeclarations!: boolean;\n\n @BindOption('excludeExternals')\n excludeExternals!: boolean;\n\n @BindOption('excludeNotExported')\n excludeNotExported!: boolean;\n\n @BindOption('excludeNotDocumented')\n excludeNotDocumented!: boolean;\n\n @BindOption('excludePrivate')\n excludePrivate!: boolean;\n\n @BindOption('excludeProtected')\n excludeProtected!: boolean;\n\n /**\n * Defined in the initialize method\n */\n private nodeConverters!: {[syntaxKind: number]: ConverterNodeComponent<ts.Node>};\n\n /**\n * Defined in the initialize method\n */\n private typeNodeConverters!: TypeNodeConverter<ts.Type, ts.Node>[];\n\n /**\n * Defined in the initialize method\n */\n private typeTypeConverters!: TypeTypeConverter<ts.Type>[];\n\n /**\n * General events\n */\n\n /**\n * Triggered when the converter begins converting a project.\n * The listener should implement [[IConverterCallback]].\n * @event\n */\n static EVENT_BEGIN = 'begin';\n\n /**\n * Triggered when the converter has finished converting a project.\n * The listener should implement [[IConverterCallback]].\n * @event\n */\n static EVENT_END = 'end';\n\n /**\n * Factory events\n */\n\n /**\n * Triggered when the converter begins converting a source file.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_FILE_BEGIN = 'fileBegin';\n\n /**\n * Triggered when the converter has created a declaration reflection.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_CREATE_DECLARATION = 'createDeclaration';\n\n /**\n * Triggered when the converter has created a signature reflection.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_CREATE_SIGNATURE = 'createSignature';\n\n /**\n * Triggered when the converter has created a parameter reflection.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_CREATE_PARAMETER = 'createParameter';\n\n /**\n * Triggered when the converter has created a type parameter reflection.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_CREATE_TYPE_PARAMETER = 'createTypeParameter';\n\n /**\n * Triggered when the converter has found a function implementation.\n * The listener should implement [[IConverterNodeCallback]].\n * @event\n */\n static EVENT_FUNCTION_IMPLEMENTATION = 'functionImplementation';\n\n /**\n * Resolve events\n */\n\n /**\n * Triggered when the converter begins resolving a project.\n * The listener should implement [[IConverterCallback]].\n * @event\n */\n static EVENT_RESOLVE_BEGIN = 'resolveBegin';\n\n /**\n * Triggered when the converter resolves a reflection.\n * The listener should implement [[IConverterResolveCallback]].\n * @event\n */\n static EVENT_RESOLVE = 'resolveReflection';\n\n /**\n * Triggered when the converter has finished resolving a project.\n * The listener should implement [[IConverterCallback]].\n * @event\n */\n static EVENT_RESOLVE_END = 'resolveEnd';\n\n /**\n * Create a new Converter instance.\n *\n * @param application The application instance this converter relies on. The application\n * must expose the settings that should be used and serves as a global logging endpoint.\n */\n initialize() {\n this.nodeConverters = {};\n this.typeTypeConverters = [];\n this.typeNodeConverters = [];\n }\n\n addComponent<T extends ConverterComponent & Component>(name: string, componentClass: T | ComponentClass<T>): T {\n const component = super.addComponent(name, componentClass);\n if (component instanceof ConverterNodeComponent) {\n this.addNodeConverter(component);\n } else if (component instanceof ConverterTypeComponent) {\n this.addTypeConverter(component);\n }\n\n return component;\n }\n\n private addNodeConverter(converter: ConverterNodeComponent<any>) {\n for (const supports of converter.supports) {\n this.nodeConverters[supports] = converter;\n }\n }\n\n private addTypeConverter(converter: ConverterTypeComponent) {\n if ('supportsNode' in converter && 'convertNode' in converter) {\n this.typeNodeConverters.push(<TypeNodeConverter<any, any>> converter);\n this.typeNodeConverters.sort((a, b) => b.priority - a.priority);\n }\n\n if ('supportsType' in converter && 'convertType' in converter) {\n this.typeTypeConverters.push(<TypeTypeConverter<any>> converter);\n this.typeTypeConverters.sort((a, b) => b.priority - a.priority);\n }\n }\n\n removeComponent(name: string): ConverterComponent | undefined {\n const component = super.removeComponent(name);\n if (component instanceof ConverterNodeComponent) {\n this.removeNodeConverter(component);\n } else if (component instanceof ConverterTypeComponent) {\n this.removeTypeConverter(component);\n }\n\n return component;\n }\n\n private removeNodeConverter(converter: ConverterNodeComponent<any>) {\n const converters = this.nodeConverters;\n const keys = _.keys(this.nodeConverters);\n for (const key of keys) {\n if (converters[key] === converter) {\n delete converters[key];\n }\n }\n }\n\n private removeTypeConverter(converter: ConverterTypeComponent) {\n const typeIndex = this.typeTypeConverters.indexOf(<any> converter);\n if (typeIndex !== -1) {\n this.typeTypeConverters.splice(typeIndex, 1);\n }\n\n const nodeIndex = this.typeNodeConverters.indexOf(<any> converter);\n if (nodeIndex !== -1) {\n this.typeNodeConverters.splice(nodeIndex, 1);\n }\n }\n\n removeAllComponents() {\n super.removeAllComponents();\n\n this.nodeConverters = {};\n this.typeTypeConverters = [];\n this.typeNodeConverters = [];\n }\n\n /**\n * Compile the given source files and create a project reflection for them.\n *\n * @param fileNames Array of the file names that should be compiled.\n */\n convert(fileNames: string[]): ConverterResult {\n // JSON files should never result in extra members in the documentation, but need to be included so that TS\n // can find them.\n const normalizedFiles = fileNames.map(normalizePath).filter(path => !path.endsWith('.json'));\n\n const program = ts.createProgram(normalizedFiles, this.application.options.getCompilerOptions());\n const checker = program.getTypeChecker();\n const context = new Context(this, normalizedFiles, checker, program);\n\n this.trigger(Converter.EVENT_BEGIN, context);\n\n const errors = this.compile(context);\n const project = this.resolve(context);\n\n const dangling = project.getDanglingReferences();\n if (dangling.length) {\n this.owner.logger.warn([\n 'Some names refer to reflections that do not exist.',\n 'This can be caused by exporting a reflection only under a different name than it is declared when excludeNotExported is set',\n 'or by a plugin removing reflections without removing references. The names that cannot be resolved are:',\n ...dangling\n ].join('\\n'));\n }\n\n this.trigger(Converter.EVENT_END, context);\n\n return {\n errors: errors,\n project: project\n };\n }\n\n /**\n * Analyze the given node and create a suitable reflection.\n *\n * This function checks the kind of the node and delegates to the matching function implementation.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The compiler node that should be analyzed.\n * @return The resulting reflection or undefined.\n */\n convertNode(context: Context, node: ts.Node): Reflection | undefined {\n if (context.visitStack.includes(node)) {\n return;\n }\n\n const oldVisitStack = context.visitStack;\n context.visitStack = oldVisitStack.slice();\n context.visitStack.push(node);\n\n let result: Reflection | undefined;\n if (node.kind in this.nodeConverters) {\n result = this.nodeConverters[node.kind].convert(context, node);\n }\n\n context.visitStack = oldVisitStack;\n return result;\n }\n\n /**\n * Convert the given TypeScript type into its TypeDoc type reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The node whose type should be reflected.\n * @param type The type of the node if already known.\n * @returns The TypeDoc type reflection representing the given node and type.\n */\n convertType(context: Context, node?: ts.Node, type?: ts.Type): Type | undefined {\n // Run all node based type conversions\n if (node) {\n type = type || context.getTypeAtLocation(node);\n\n for (const converter of this.typeNodeConverters) {\n if (converter.supportsNode(context, node, type)) {\n return converter.convertNode(context, node, type);\n }\n }\n }\n\n // Run all type based type conversions\n if (type) {\n for (const converter of this.typeTypeConverters) {\n if (converter.supportsType(context, type)) {\n return converter.convertType(context, type);\n }\n }\n }\n }\n\n /**\n * Helper function to convert multiple types at once, filtering out types which fail to convert.\n *\n * @param context\n * @param nodes\n */\n convertTypes(context: Context, nodes: ReadonlyArray<ts.Node> = [], types: ReadonlyArray<ts.Type> = []): Type[] {\n const result: Type[] = [];\n _.zip(nodes, types).forEach(([node, type]) => {\n const converted = this.convertType(context, node, type);\n if (converted) {\n result.push(converted);\n }\n });\n return result;\n }\n\n /**\n * Compile the files within the given context and convert the compiler symbols to reflections.\n *\n * @param context The context object describing the current state the converter is in.\n * @returns An array containing all errors generated by the TypeScript compiler.\n */\n private compile(context: Context): ReadonlyArray<ts.Diagnostic> {\n const program = context.program;\n const exclude = createMinimatch(this.application.exclude || []);\n const isExcluded = (file: ts.SourceFile) => exclude.some(mm => mm.match(file.fileName));\n const includedSourceFiles = program.getSourceFiles()\n .filter(file => !isExcluded(file));\n\n const errors = this.getCompilerErrors(program, includedSourceFiles);\n if (errors.length) {\n return errors;\n }\n\n includedSourceFiles.forEach((sourceFile) => {\n this.convertNode(context, sourceFile);\n });\n\n return [];\n }\n\n /**\n * Resolve the project within the given context.\n *\n * @param context The context object describing the current state the converter is in.\n * @returns The final project reflection.\n */\n private resolve(context: Context): ProjectReflection {\n this.trigger(Converter.EVENT_RESOLVE_BEGIN, context);\n const project = context.project;\n\n for (const id in project.reflections) {\n if (!project.reflections.hasOwnProperty(id)) {\n continue;\n }\n this.trigger(Converter.EVENT_RESOLVE, context, project.reflections[id]);\n }\n\n this.trigger(Converter.EVENT_RESOLVE_END, context);\n return project;\n }\n\n private getCompilerErrors(program: ts.Program, includedSourceFiles: readonly ts.SourceFile[]): ReadonlyArray<ts.Diagnostic> {\n if (this.application.ignoreCompilerErrors) {\n return [];\n }\n\n const isRelevantError = ({ file }: ts.Diagnostic) => !file || includedSourceFiles.includes(file);\n\n let diagnostics = program.getOptionsDiagnostics().filter(isRelevantError);\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getSyntacticDiagnostics().filter(isRelevantError);\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getGlobalDiagnostics().filter(isRelevantError);\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getSemanticDiagnostics().filter(isRelevantError);\n if (diagnostics.length) {\n return diagnostics;\n }\n\n return [];\n }\n\n /**\n * Return the basename of the default library that should be used.\n *\n * @returns The basename of the default library.\n */\n getDefaultLib(): string {\n return ts.getDefaultLibFileName(this.application.options.getCompilerOptions());\n }\n}\n"]}
|
|
@@ -16,6 +16,26 @@ const nonStaticMergeKinds = [
|
|
|
16
16
|
ts.SyntaxKind.InterfaceDeclaration
|
|
17
17
|
];
|
|
18
18
|
const builtInSymbolRegExp = /^__@(\w+)$/;
|
|
19
|
+
function hasCommentOnParentAxis(node) {
|
|
20
|
+
let currentNode = node;
|
|
21
|
+
while (currentNode) {
|
|
22
|
+
if (Boolean(comment_js_1.getRawComment(currentNode))) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
currentNode = currentNode.parent;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
function shouldBeIgnoredAsNotDocumented(node, kind) {
|
|
30
|
+
if (kind === index_1.ReflectionKind.Module || kind === index_1.ReflectionKind.Global || kind === index_1.ReflectionKind.EnumMember) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (kind === index_1.ReflectionKind.Variable && hasCommentOnParentAxis(node)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const hasComment = Boolean(comment_js_1.getRawComment(node));
|
|
37
|
+
return !hasComment;
|
|
38
|
+
}
|
|
19
39
|
function createDeclaration(context, node, kind, name) {
|
|
20
40
|
var _a, _b;
|
|
21
41
|
if (!(context.scope instanceof index_1.ContainerReflection)) {
|
|
@@ -48,11 +68,9 @@ function createDeclaration(context, node, kind, name) {
|
|
|
48
68
|
}
|
|
49
69
|
}
|
|
50
70
|
const modifiers = ts.getCombinedModifierFlags(node);
|
|
51
|
-
let hasComment = Boolean(comment_js_1.getRawComment(node));
|
|
52
71
|
let isExported;
|
|
53
72
|
if (kind === index_1.ReflectionKind.Module || kind === index_1.ReflectionKind.Global) {
|
|
54
73
|
isExported = true;
|
|
55
|
-
hasComment = true;
|
|
56
74
|
}
|
|
57
75
|
else if (container.kind === index_1.ReflectionKind.Global) {
|
|
58
76
|
isExported = true;
|
|
@@ -81,7 +99,7 @@ function createDeclaration(context, node, kind, name) {
|
|
|
81
99
|
}
|
|
82
100
|
if ((!isExported && context.converter.excludeNotExported)
|
|
83
101
|
||
|
|
84
|
-
(context.converter.excludeNotDocumented && kind
|
|
102
|
+
(context.converter.excludeNotDocumented && shouldBeIgnoredAsNotDocumented(node, kind))) {
|
|
85
103
|
return;
|
|
86
104
|
}
|
|
87
105
|
const isPrivate = !!(modifiers & ts.ModifierFlags.Private);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/declaration.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,8CAAgH;AAEhH,4CAAyC;AACzC,6CAA6C;AAC7C,2CAAkD;AAKlD,MAAM,cAAc,GAAG;IACnB,sBAAc,CAAC,KAAK;IACpB,sBAAc,CAAC,SAAS;IACxB,sBAAc,CAAC,SAAS;CAC3B,CAAC;AAKF,MAAM,mBAAmB,GAAG;IACxB,EAAE,CAAC,UAAU,CAAC,gBAAgB;IAC9B,EAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,EAAE,CAAC,UAAU,CAAC,oBAAoB;CACrC,CAAC;AAEF,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAYzC,SAAgB,iBAAiB,CAAC,OAAgB,EAAE,IAAoB,EAAE,IAAoB,EAAE,IAAa;;IACzG,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,YAAY,2BAAmB,CAAC,EAAE;QACjD,MAAM,IAAI,KAAK,CAAC,gCAA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EAAE,IAAa,EAAE,IAAoB;IAC/G,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI,EAAE;QAC1B,MAAM,OAAO,GAAG,CAAC,sBAAc,CAAC,SAAS,EAAE,sBAAc,CAAC,IAAI,EAAE,sBAAc,CAAC,KAAK,CAAC,CAAC;QACtF,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,UAAU,GAAG,eAAe,EAAE;YAC9B,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;SAC1B;KACJ;IAED,IACI,OAAO,CAAC,SAAS;QACjB,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;QACnD,CAAC,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,aAAa,IAAI,UAAU,CAAC,KAAK,CAAC,qBAAqB,CAAC,EACnF;QACE,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YACxB,UAAU,CAAC,UAAU,GAAG,+BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACxE,UAAU,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBAChD,SAAS,CAAC,UAAU,GAAG,+BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC3E,CAAC,CAAC,CAAC;SACN;QACD,OAAO;KACV;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import * as ts from 'typescript';\n\nimport { ContainerReflection, DeclarationReflection, ReflectionFlag, ReflectionKind } from '../../models/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { getRawComment } from './comment.js';\nimport { createReferenceType } from './reference';\n\n/**\n * List of reflection kinds that never should be static.\n */\nconst nonStaticKinds = [\n ReflectionKind.Class,\n ReflectionKind.Interface,\n ReflectionKind.Namespace\n];\n\n/**\n * List of ts kinds leading to none static merge.\n */\nconst nonStaticMergeKinds = [\n ts.SyntaxKind.ClassDeclaration,\n ts.SyntaxKind.ClassExpression,\n ts.SyntaxKind.InterfaceDeclaration\n];\n\nconst builtInSymbolRegExp = /^__@(\\w+)$/;\n\n/**\n * Create a declaration reflection from the given TypeScript node.\n *\n * @param context The context object describing the current state the converter is in. The\n * scope of the context will be the parent of the generated reflection.\n * @param node The TypeScript node that should be converted to a reflection.\n * @param kind The desired kind of the reflection.\n * @param name The desired name of the reflection.\n * @returns The resulting reflection or undefined if an error is encountered.\n */\nexport function createDeclaration(context: Context, node: ts.Declaration, kind: ReflectionKind, name?: string): DeclarationReflection | undefined {\n if (!(context.scope instanceof ContainerReflection)) {\n throw new Error('Expected container reflection.');\n }\n const container = context.scope;\n\n // Ensure we have a name for the reflection\n if (!name) {\n if (node.localSymbol) {\n name = node.localSymbol.name;\n } else if (node.symbol) {\n name = node.symbol.name;\n } else {\n return;\n }\n\n // rename built-in symbols\n const match = builtInSymbolRegExp.exec(name);\n if (match) {\n name = `[Symbol.${match[1]}]`;\n } else if (kind & (ReflectionKind.ClassMember | ReflectionKind.VariableOrProperty) && name === '__computed') {\n // rename computed properties\n const declName = ts.getNameOfDeclaration(node);\n const symbol = declName && context.checker.getSymbolAtLocation(declName);\n if (symbol) {\n name = context.checker.symbolToString(symbol, /*enclosingDeclaration*/ undefined, ts.SymbolFlags.ClassMember);\n } else if (declName) {\n name = declName.getText();\n }\n }\n }\n\n const modifiers = ts.getCombinedModifierFlags(node);\n\n let hasComment: boolean = Boolean(getRawComment(node));\n // Test whether the node is exported\n let isExported: boolean;\n if (kind === ReflectionKind.Module || kind === ReflectionKind.Global) {\n isExported = true;\n hasComment = true;\n } else if (container.kind === ReflectionKind.Global) {\n // In file mode, everything is exported.\n isExported = true;\n } else if (container.kindOf([ReflectionKind.Namespace, ReflectionKind.Module])) {\n const symbol = context.getSymbolAtLocation(node);\n if (!symbol) {\n isExported = false;\n } else {\n let parentNode = node.parent;\n while (![ts.SyntaxKind.SourceFile, ts.SyntaxKind.ModuleDeclaration].includes(parentNode.kind)) {\n parentNode = parentNode.parent;\n }\n const parentSymbol = context.getSymbolAtLocation(parentNode);\n if (!parentSymbol) {\n // This is a file with no imports/exports, so everything is\n // global and therefore exported.\n isExported = true;\n } else {\n isExported = !!parentSymbol.exports?.get(symbol.escapedName);\n }\n }\n } else {\n isExported = container.flags.isExported;\n }\n\n if (\n (!isExported && context.converter.excludeNotExported)\n ||\n (context.converter.excludeNotDocumented && kind !== ReflectionKind.EnumMember && !hasComment)\n ) {\n return;\n }\n\n // Test whether the node is private, when inheriting ignore private members\n const isPrivate = !!(modifiers & ts.ModifierFlags.Private);\n if (context.isInherit && isPrivate) {\n return;\n }\n\n // Test whether the node is static, when merging a module to a class make the node static\n let isConstructorProperty = false;\n let isStatic = false;\n if (!nonStaticKinds.includes(kind)) {\n isStatic = !!(modifiers & ts.ModifierFlags.Static);\n if (container.kind === ReflectionKind.Class) {\n if (node.parent && node.parent.kind === ts.SyntaxKind.Constructor) {\n isConstructorProperty = true;\n } else if (!node.parent || !nonStaticMergeKinds.includes(node.parent.kind)) {\n isStatic = true;\n }\n }\n }\n\n // Check if we already have a child of the same kind, with the same name and static flag\n let child: DeclarationReflection | undefined;\n const children = container.children = container.children || [];\n children.forEach((n: DeclarationReflection) => {\n if (n.name === name && n.flags.isStatic === isStatic && canMergeReflectionsByKind(n.kind, kind)) {\n child = n;\n }\n });\n\n if (!child) {\n // Child does not exist, create a new reflection\n child = new DeclarationReflection(name, kind, container);\n child.setFlag(ReflectionFlag.Static, isStatic);\n child.setFlag(ReflectionFlag.Private, isPrivate);\n child.setFlag(ReflectionFlag.ConstructorProperty, isConstructorProperty);\n child.setFlag(ReflectionFlag.Exported, isExported);\n child = setupDeclaration(context, child, node);\n\n if (child) {\n children.push(child);\n context.registerReflection(child, context.getSymbolAtLocation(node) ?? node.symbol);\n }\n } else {\n // Merge the existent reflection with the given node\n child = mergeDeclarations(context, child, node, kind);\n }\n\n // If we have a reflection, trigger the corresponding event\n if (child) {\n context.trigger(Converter.EVENT_CREATE_DECLARATION, child, node);\n }\n\n return child;\n}\n\n/**\n * Setup a newly created declaration reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The newly created blank reflection.\n * @param node The TypeScript node whose properties should be applies to the given reflection.\n * @returns The reflection populated with the values of the given node.\n */\nfunction setupDeclaration(context: Context, reflection: DeclarationReflection, node: ts.Declaration) {\n const modifiers = ts.getCombinedModifierFlags(node);\n\n reflection.setFlag(ReflectionFlag.External, context.isExternal);\n reflection.setFlag(ReflectionFlag.Protected, !!(modifiers & ts.ModifierFlags.Protected));\n reflection.setFlag(ReflectionFlag.Public, !!(modifiers & ts.ModifierFlags.Public));\n reflection.setFlag(ReflectionFlag.Optional, !!(node['questionToken']));\n reflection.setFlag(ReflectionFlag.Readonly, !!(modifiers & ts.ModifierFlags.Readonly));\n\n if (\n context.isInherit &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.inheritedFrom) {\n reflection.inheritedFrom = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.inheritedFrom = createReferenceType(context, node.symbol, true);\n });\n }\n }\n\n return reflection;\n}\n\n// we should not be merging type and value with the same name,\n// because TypeScript has different namespaces for these two categories\nfunction canMergeReflectionsByKind(kind1: ReflectionKind, kind2: ReflectionKind): boolean {\n if (\n (kind1 & ReflectionKind.SomeType && kind2 & ReflectionKind.SomeValue)\n ||\n (kind2 & ReflectionKind.SomeType && kind1 & ReflectionKind.SomeValue)\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Merge the properties of the given TypeScript node with the pre existent reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The pre existent reflection.\n * @param node The TypeScript node whose properties should be merged with the given reflection.\n * @param kind The desired kind of the reflection.\n * @returns The reflection merged with the values of the given node or NULL if the merge is invalid.\n */\nfunction mergeDeclarations(context: Context, reflection: DeclarationReflection, node: ts.Node, kind: ReflectionKind) {\n if (reflection.kind !== kind) {\n const weights = [ReflectionKind.Namespace, ReflectionKind.Enum, ReflectionKind.Class];\n const kindWeight = weights.indexOf(kind);\n const childKindWeight = weights.indexOf(reflection.kind);\n if (kindWeight > childKindWeight) {\n reflection.kind = kind;\n }\n }\n\n if (\n context.isInherit &&\n (context.inherited || []).includes(reflection.name) &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.overwrites) {\n reflection.overwrites = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.overwrites = createReferenceType(context, node.symbol, true);\n });\n }\n return;\n }\n\n return reflection;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/declaration.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,8CAAgH;AAEhH,4CAAyC;AACzC,6CAA6C;AAC7C,2CAAkD;AAKlD,MAAM,cAAc,GAAG;IACnB,sBAAc,CAAC,KAAK;IACpB,sBAAc,CAAC,SAAS;IACxB,sBAAc,CAAC,SAAS;CAC3B,CAAC;AAKF,MAAM,mBAAmB,GAAG;IACxB,EAAE,CAAC,UAAU,CAAC,gBAAgB;IAC9B,EAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,EAAE,CAAC,UAAU,CAAC,oBAAoB;CACrC,CAAC;AAEF,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAEzC,SAAS,sBAAsB,CAAE,IAAa;IAC1C,IAAI,WAAW,GAAY,IAAI,CAAC;IAEhC,OAAO,WAAW,EAAE;QAChB,IAAI,OAAO,CAAC,0BAAa,CAAC,WAAW,CAAC,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;SAAE;QAEzD,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC;KACpC;I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,UAAU,GAAG,+BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACxE,UAAU,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBAChD,SAAS,CAAC,UAAU,GAAG,+BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC3E,CAAC,CAAC,CAAC;SACN;QACD,OAAO;KACV;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import * as ts from 'typescript';\n\nimport { ContainerReflection, DeclarationReflection, ReflectionFlag, ReflectionKind } from '../../models/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { getRawComment } from './comment.js';\nimport { createReferenceType } from './reference';\n\n/**\n * List of reflection kinds that never should be static.\n */\nconst nonStaticKinds = [\n ReflectionKind.Class,\n ReflectionKind.Interface,\n ReflectionKind.Namespace\n];\n\n/**\n * List of ts kinds leading to none static merge.\n */\nconst nonStaticMergeKinds = [\n ts.SyntaxKind.ClassDeclaration,\n ts.SyntaxKind.ClassExpression,\n ts.SyntaxKind.InterfaceDeclaration\n];\n\nconst builtInSymbolRegExp = /^__@(\\w+)$/;\n\nfunction hasCommentOnParentAxis (node: ts.Node): boolean {\n let currentNode: ts.Node = node;\n\n while (currentNode) {\n if (Boolean(getRawComment(currentNode))) { return true; }\n\n currentNode = currentNode.parent;\n }\n\n return false;\n}\n\nfunction shouldBeIgnoredAsNotDocumented (node: ts.Declaration, kind: ReflectionKind): boolean {\n // never ignore modules, global, and enum members\n if (kind === ReflectionKind.Module || kind === ReflectionKind.Global || kind === ReflectionKind.EnumMember) {\n return false;\n }\n\n // do not ignore properties of the object types, that has comment themselves, for example\n //\n // /**\n // * has docs\n // */\n // export SomeType = { prop1 : string }\n //\n // same applies to the inline types for function arguments:\n //\n // function someFunc(arg1 : { prop1 : string, prop2 : number }) {...}\n //\n // The `prop1` from above should be included in the docs, even that it has no documentation\n // Note, that this does not seem to apply to classes and interfaces - for those, even the class/interface\n // has docs, we still want to exclude the undocumented properties\n // Thankfully for object literals the kind of properties seems to be set to ReflectionKind.Variable\n if (kind === ReflectionKind.Variable && hasCommentOnParentAxis(node)) {\n return false;\n }\n\n const hasComment: boolean = Boolean(getRawComment(node));\n\n return !hasComment;\n}\n\n/**\n * Create a declaration reflection from the given TypeScript node.\n *\n * @param context The context object describing the current state the converter is in. The\n * scope of the context will be the parent of the generated reflection.\n * @param node The TypeScript node that should be converted to a reflection.\n * @param kind The desired kind of the reflection.\n * @param name The desired name of the reflection.\n * @returns The resulting reflection or undefined if an error is encountered.\n */\nexport function createDeclaration(context: Context, node: ts.Declaration, kind: ReflectionKind, name?: string): DeclarationReflection | undefined {\n if (!(context.scope instanceof ContainerReflection)) {\n throw new Error('Expected container reflection.');\n }\n const container = context.scope;\n\n // Ensure we have a name for the reflection\n if (!name) {\n if (node.localSymbol) {\n name = node.localSymbol.name;\n } else if (node.symbol) {\n name = node.symbol.name;\n } else {\n return;\n }\n\n // rename built-in symbols\n const match = builtInSymbolRegExp.exec(name);\n if (match) {\n name = `[Symbol.${match[1]}]`;\n } else if (kind & (ReflectionKind.ClassMember | ReflectionKind.VariableOrProperty) && name === '__computed') {\n // rename computed properties\n const declName = ts.getNameOfDeclaration(node);\n const symbol = declName && context.checker.getSymbolAtLocation(declName);\n if (symbol) {\n name = context.checker.symbolToString(symbol, /*enclosingDeclaration*/ undefined, ts.SymbolFlags.ClassMember);\n } else if (declName) {\n name = declName.getText();\n }\n }\n }\n\n const modifiers = ts.getCombinedModifierFlags(node);\n\n // Test whether the node is exported\n let isExported: boolean;\n if (kind === ReflectionKind.Module || kind === ReflectionKind.Global) {\n isExported = true;\n } else if (container.kind === ReflectionKind.Global) {\n // In file mode, everything is exported.\n isExported = true;\n } else if (container.kindOf([ReflectionKind.Namespace, ReflectionKind.Module])) {\n const symbol = context.getSymbolAtLocation(node);\n if (!symbol) {\n isExported = false;\n } else {\n let parentNode = node.parent;\n while (![ts.SyntaxKind.SourceFile, ts.SyntaxKind.ModuleDeclaration].includes(parentNode.kind)) {\n parentNode = parentNode.parent;\n }\n const parentSymbol = context.getSymbolAtLocation(parentNode);\n if (!parentSymbol) {\n // This is a file with no imports/exports, so everything is\n // global and therefore exported.\n isExported = true;\n } else {\n isExported = !!parentSymbol.exports?.get(symbol.escapedName);\n }\n }\n } else {\n isExported = container.flags.isExported;\n }\n\n if (\n (!isExported && context.converter.excludeNotExported)\n ||\n (context.converter.excludeNotDocumented && shouldBeIgnoredAsNotDocumented(node, kind))\n ) {\n return;\n }\n\n // Test whether the node is private, when inheriting ignore private members\n const isPrivate = !!(modifiers & ts.ModifierFlags.Private);\n if (context.isInherit && isPrivate) {\n return;\n }\n\n // Test whether the node is static, when merging a module to a class make the node static\n let isConstructorProperty = false;\n let isStatic = false;\n if (!nonStaticKinds.includes(kind)) {\n isStatic = !!(modifiers & ts.ModifierFlags.Static);\n if (container.kind === ReflectionKind.Class) {\n if (node.parent && node.parent.kind === ts.SyntaxKind.Constructor) {\n isConstructorProperty = true;\n } else if (!node.parent || !nonStaticMergeKinds.includes(node.parent.kind)) {\n isStatic = true;\n }\n }\n }\n\n // Check if we already have a child of the same kind, with the same name and static flag\n let child: DeclarationReflection | undefined;\n const children = container.children = container.children || [];\n children.forEach((n: DeclarationReflection) => {\n if (n.name === name && n.flags.isStatic === isStatic && canMergeReflectionsByKind(n.kind, kind)) {\n child = n;\n }\n });\n\n if (!child) {\n // Child does not exist, create a new reflection\n child = new DeclarationReflection(name, kind, container);\n child.setFlag(ReflectionFlag.Static, isStatic);\n child.setFlag(ReflectionFlag.Private, isPrivate);\n child.setFlag(ReflectionFlag.ConstructorProperty, isConstructorProperty);\n child.setFlag(ReflectionFlag.Exported, isExported);\n child = setupDeclaration(context, child, node);\n\n if (child) {\n children.push(child);\n context.registerReflection(child, context.getSymbolAtLocation(node) ?? node.symbol);\n }\n } else {\n // Merge the existent reflection with the given node\n child = mergeDeclarations(context, child, node, kind);\n }\n\n // If we have a reflection, trigger the corresponding event\n if (child) {\n context.trigger(Converter.EVENT_CREATE_DECLARATION, child, node);\n }\n\n return child;\n}\n\n/**\n * Setup a newly created declaration reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The newly created blank reflection.\n * @param node The TypeScript node whose properties should be applies to the given reflection.\n * @returns The reflection populated with the values of the given node.\n */\nfunction setupDeclaration(context: Context, reflection: DeclarationReflection, node: ts.Declaration) {\n const modifiers = ts.getCombinedModifierFlags(node);\n\n reflection.setFlag(ReflectionFlag.External, context.isExternal);\n reflection.setFlag(ReflectionFlag.Protected, !!(modifiers & ts.ModifierFlags.Protected));\n reflection.setFlag(ReflectionFlag.Public, !!(modifiers & ts.ModifierFlags.Public));\n reflection.setFlag(ReflectionFlag.Optional, !!(node['questionToken']));\n reflection.setFlag(ReflectionFlag.Readonly, !!(modifiers & ts.ModifierFlags.Readonly));\n\n if (\n context.isInherit &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.inheritedFrom) {\n reflection.inheritedFrom = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.inheritedFrom = createReferenceType(context, node.symbol, true);\n });\n }\n }\n\n return reflection;\n}\n\n// we should not be merging type and value with the same name,\n// because TypeScript has different namespaces for these two categories\nfunction canMergeReflectionsByKind(kind1: ReflectionKind, kind2: ReflectionKind): boolean {\n if (\n (kind1 & ReflectionKind.SomeType && kind2 & ReflectionKind.SomeValue)\n ||\n (kind2 & ReflectionKind.SomeType && kind1 & ReflectionKind.SomeValue)\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Merge the properties of the given TypeScript node with the pre existent reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The pre existent reflection.\n * @param node The TypeScript node whose properties should be merged with the given reflection.\n * @param kind The desired kind of the reflection.\n * @returns The reflection merged with the values of the given node or NULL if the merge is invalid.\n */\nfunction mergeDeclarations(context: Context, reflection: DeclarationReflection, node: ts.Node, kind: ReflectionKind) {\n if (reflection.kind !== kind) {\n const weights = [ReflectionKind.Namespace, ReflectionKind.Enum, ReflectionKind.Class];\n const kindWeight = weights.indexOf(kind);\n const childKindWeight = weights.indexOf(reflection.kind);\n if (kindWeight > childKindWeight) {\n reflection.kind = kind;\n }\n }\n\n if (\n context.isInherit &&\n (context.inherited || []).includes(reflection.name) &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.overwrites) {\n reflection.overwrites = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.overwrites = createReferenceType(context, node.symbol, true);\n });\n }\n return;\n }\n\n return reflection;\n}\n"]}
|
|
@@ -26,6 +26,9 @@ let DynamicModulePlugin = class DynamicModulePlugin extends components_1.Convert
|
|
|
26
26
|
onBegin(context) {
|
|
27
27
|
this.basePath.reset();
|
|
28
28
|
this.reflections = [];
|
|
29
|
+
if (context.getCompilerOptions().baseUrl) {
|
|
30
|
+
this.basePath.add(context.getCompilerOptions().baseUrl + '/file');
|
|
31
|
+
}
|
|
29
32
|
}
|
|
30
33
|
onDeclaration(context, reflection, node) {
|
|
31
34
|
if (reflection.kindOf(abstract_1.ReflectionKind.Module)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicModulePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/DynamicModulePlugin.ts"],"names":[],"mappings":";;;;;;;;AACA,6BAA6B;AAE7B,gEAA+E;AAC/E,8CAA8D;AAC9D,kDAA8C;AAC9C,4CAAyC;AAQzC,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,+BAAkB;IAA3D;;QAIY,aAAQ,GAAG,IAAI,oBAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"DynamicModulePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/DynamicModulePlugin.ts"],"names":[],"mappings":";;;;;;;;AACA,6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ACL,CAAC;IAOO,cAAc,CAAC,OAAgB;QACnC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACpC,IAAI,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7C,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;YAC/D,UAAU,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QAC3D,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAnEY,mBAAmB;IAD/B,sBAAS,CAAC,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC;GACvB,mBAAmB,CAmE/B;AAnEY,kDAAmB","sourcesContent":["import * as ts from 'typescript';\nimport * as Path from 'path';\n\nimport { Reflection, ReflectionKind } from '../../models/reflections/abstract';\nimport { Component, ConverterComponent } from '../components';\nimport { BasePath } from '../utils/base-path';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A handler that truncates the names of dynamic modules to not include the\n * project's base path.\n */\n@Component({name: 'dynamic-module'})\nexport class DynamicModulePlugin extends ConverterComponent {\n /**\n * Helper class for determining the base path.\n */\n private basePath = new BasePath();\n\n /**\n * List of reflections whose name must be trimmed.\n */\n private reflections!: Reflection[];\n\n /**\n * Create a new DynamicModuleHandler instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [Converter.EVENT_BEGIN]: this.onBegin,\n [Converter.EVENT_CREATE_DECLARATION]: this.onDeclaration,\n [Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve\n });\n }\n\n /**\n * Triggered when the converter begins converting a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onBegin(context: Context) {\n this.basePath.reset();\n this.reflections = [];\n if (context.getCompilerOptions().baseUrl) {\n this.basePath.add(context.getCompilerOptions().baseUrl as string + '/file');\n }\n }\n\n /**\n * Triggered when the converter has created a declaration reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onDeclaration(context: Context, reflection: Reflection, node?: ts.Node) {\n if (reflection.kindOf(ReflectionKind.Module)) {\n let name = reflection.name;\n if (!name.includes('/')) {\n return;\n }\n\n name = name.replace(/\"/g, '');\n this.reflections.push(reflection);\n this.basePath.add(name);\n }\n }\n\n /**\n * Triggered when the converter begins resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onBeginResolve(context: Context) {\n this.reflections.forEach((reflection) => {\n let name = reflection.name.replace(/\"/g, '');\n name = name.substr(0, name.length - Path.extname(name).length);\n reflection.name = '\"' + this.basePath.trim(name) + '\"';\n });\n }\n}\n"]}
|
|
@@ -66,11 +66,11 @@ class Repository {
|
|
|
66
66
|
static tryCreateRepository(path, gitRevision, gitRemote) {
|
|
67
67
|
ShellJS.pushd(path);
|
|
68
68
|
const out = ShellJS.exec('git rev-parse --show-toplevel', { silent: true });
|
|
69
|
+
const remotesOutput = ShellJS.exec(`git remote get-url ${gitRemote}`, { silent: true });
|
|
69
70
|
ShellJS.popd();
|
|
70
|
-
if (!out || out.code !== 0) {
|
|
71
|
+
if (!out || out.code !== 0 || !remotesOutput || remotesOutput.code !== 0) {
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
|
-
const remotesOutput = ShellJS.exec(`git remote get-url ${gitRemote}`, { silent: true });
|
|
74
74
|
let remotes = (remotesOutput.code === 0) ? remotesOutput.stdout.split('\n') : [];
|
|
75
75
|
return new Repository(base_path_1.BasePath.normalize(out.stdout.replace('\n', '')), gitRevision, remotes);
|
|
76
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/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EAAE,EAAE;YACjC,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;YAC/D,IAAI,UAAU,EAAE;gBACZ,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;aACrE;QACL,CAAC,CAAC,CAAC;QAEH,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE;YACjC,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,UAAU,CAAC,OAAO,EAAE;gBACpB,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAuB,EAAE,EAAE;oBACnD,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;wBAChC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;qBACrD;gBACL,CAAC,CAAC,CAAC;aACN;SACJ;IACL,CAAC;CACJ,CAAA;AAjFG;IADC,kBAAU,CAAC,aAAa,CAAC;iDACI;AAG9B;IADC,kBAAU,CAAC,WAAW,CAAC;+CACI;AAfnB,YAAY;IADxB,sBAAS,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;GAChB,YAAY,CA6FxB;AA7FY,oCAAY","sourcesContent":["import * as ShellJS from 'shelljs';\nimport * as Path from 'path';\n\nimport { SourceReference } from '../../models/sources/file';\nimport { Component, ConverterComponent } from '../components';\nimport { BasePath } from '../utils/base-path';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { BindOption } from '../../utils';\n\n/**\n * Stores data of a repository.\n */\nexport class Repository {\n /**\n * The root path of this repository.\n */\n path: string;\n\n /**\n * The name of the branch this repository is on right now.\n */\n branch: string;\n\n /**\n * A list of all files tracked by the repository.\n */\n files: string[] = [];\n\n /**\n * The user/organization name of this repository on GitHub.\n */\n gitHubUser?: string;\n\n /**\n * The project name of this repository on GitHub.\n */\n gitHubProject?: string;\n\n /**\n * The hostname for this github project.\n *\n * Defaults to: `github.com` (for normal, public GitHub instance projects)\n *\n * Or the hostname for an enterprise version of GitHub, e.g. `github.acme.com`\n * (if found as a match in the list of git remotes).\n */\n gitHubHostname = 'github.com';\n\n /**\n * Create a new Repository instance.\n *\n * @param path The root path of the repository.\n */\n constructor(path: string, gitRevision: string, repoLinks: string[]) {\n this.path = path;\n this.branch = gitRevision || 'master';\n ShellJS.pushd(path);\n\n for (let i = 0, c = repoLinks.length; i < c; i++) {\n const url = /(github(?:\\.[a-z]+)*\\.com)[:\\/]([^\\/]+)\\/(.*)/.exec(repoLinks[i]);\n\n if (url) {\n this.gitHubHostname = url[1];\n this.gitHubUser = url[2];\n this.gitHubProject = url[3];\n if (this.gitHubProject.substr(-4) === '.git') {\n this.gitHubProject = this.gitHubProject.substr(0, this.gitHubProject.length - 4);\n }\n break;\n }\n }\n\n let out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git ls-files', {silent: true});\n if (out.code === 0) {\n out.stdout.split('\\n').forEach((file) => {\n if (file !== '') {\n this.files.push(BasePath.normalize(path + '/' + file));\n }\n });\n }\n\n if (!gitRevision) {\n out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git rev-parse --short HEAD', {silent: true});\n if (out.code === 0) {\n this.branch = out.stdout.replace('\\n', '');\n }\n }\n\n ShellJS.popd();\n }\n\n /**\n * Check whether the given file is tracked by this repository.\n *\n * @param fileName The name of the file to test for.\n * @returns TRUE when the file is part of the repository, otherwise FALSE.\n */\n contains(fileName: string): boolean {\n return this.files.includes(fileName);\n }\n\n /**\n * Get the URL of the given file on GitHub.\n *\n * @param fileName The file whose GitHub URL should be determined.\n * @returns An url pointing to the web preview of the given file or NULL.\n */\n getGitHubURL(fileName: string): string | undefined {\n if (!this.gitHubUser || !this.gitHubProject || !this.contains(fileName)) {\n return;\n }\n\n return [\n `https://${this.gitHubHostname}`,\n this.gitHubUser,\n this.gitHubProject,\n 'blob',\n this.branch,\n fileName.substr(this.path.length + 1)\n ].join('/');\n }\n\n /**\n * Try to create a new repository instance.\n *\n * Checks whether the given path is the root of a valid repository and if so\n * creates a new instance of [[Repository]].\n *\n * @param path The potential repository root.\n * @returns A new instance of [[Repository]] or undefined.\n */\n static tryCreateRepository(path: string, gitRevision: string, gitRemote: string): Repository | undefined {\n ShellJS.pushd(path);\n const out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git rev-parse --show-toplevel', {silent: true});\n ShellJS.popd();\n\n if (!out || out.code !== 0) {\n return;\n }\n\n const remotesOutput = <ShellJS.ExecOutputReturnValue> ShellJS.exec(`git remote get-url ${gitRemote}`, {silent: true});\n let remotes: string[] = (remotesOutput.code === 0) ? remotesOutput.stdout.split('\\n') : [];\n\n return new Repository(BasePath.normalize(out.stdout.replace('\\n', '')), gitRevision, remotes);\n }\n}\n\n/**\n * A handler that watches for repositories with GitHub origin and links\n * their source files to the related GitHub pages.\n */\n@Component({name: 'git-hub'})\nexport class GitHubPlugin extends ConverterComponent {\n /**\n * List of known repositories.\n */\n private repositories: {[path: string]: Repository} = {};\n\n /**\n * List of paths known to be not under git control.\n */\n private ignoredPaths: string[] = [];\n\n @BindOption('gitRevision')\n readonly gitRevision!: string;\n\n @BindOption('gitRemote')\n readonly gitRemote!: string;\n\n /**\n * Create a new GitHubHandler instance.\n *\n * @param converter The converter this plugin should be attached to.\n */\n initialize() {\n ShellJS.config.silent = true;\n if (ShellJS.which('git')) {\n this.listenTo(this.owner, Converter.EVENT_RESOLVE_END, this.onEndResolve);\n }\n }\n\n /**\n * Check whether the given file is placed inside a repository.\n *\n * @param fileName The name of the file a repository should be looked for.\n * @returns The found repository info or undefined.\n */\n private getRepository(fileName: string): Repository | undefined {\n // Check for known non-repositories\n const dirName = Path.dirname(fileName);\n for (let i = 0, c = this.ignoredPaths.length; i < c; i++) {\n if (this.ignoredPaths[i] === dirName) {\n return;\n }\n }\n\n // Check for known repositories\n for (let path in this.repositories) {\n if (!this.repositories.hasOwnProperty(path)) {\n continue;\n }\n if (fileName.substr(0, path.length).toLowerCase() === path) {\n return this.repositories[path];\n }\n }\n\n // Try to create a new repository\n const repository = Repository.tryCreateRepository(dirName, this.gitRevision, this.gitRemote);\n if (repository) {\n this.repositories[repository.path.toLowerCase()] = repository;\n return repository;\n }\n\n // No repository found, add path to ignored paths\n const segments = dirName.split('/');\n for (let i = segments.length; i > 0; i--) {\n this.ignoredPaths.push(segments.slice(0, i).join('/'));\n }\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onEndResolve(context: Context) {\n const project = context.project;\n project.files.forEach((sourceFile) => {\n const repository = this.getRepository(sourceFile.fullFileName);\n if (repository) {\n sourceFile.url = repository.getGitHubURL(sourceFile.fullFileName);\n }\n });\n\n for (let key in project.reflections) {\n const reflection = project.reflections[key];\n if (reflection.sources) {\n reflection.sources.forEach((source: SourceReference) => {\n if (source.file && source.file.url) {\n source.url = source.file.url + '#L' + source.line;\n }\n });\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GitHubPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/GitHubPlugin.ts"],"names":[],"mappings":";;;;;;;;AAAA,mCAAmC;AACnC,6BAA6B;AAG7B,8CAA8D;AAC9D,kDAA8C;AAC9C,4CAAyC;AAEzC,uCAAyC;AAKzC,MAAa,UAAU;IAyCnB,YAAY,IAAY,EAAE,WAAmB,EAAE,SAAmB;QA3BlE,UAAK,GAAa,EAAE,CAAC;QAoBrB,mBAAc,GAAG,YAAY,CAAC;QAQ1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,WAAW,IAAI,QAAQ,CAAC;QACtC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC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AC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAuB,EAAE,EAAE;oBACnD,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;wBAChC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;qBACrD;gBACL,CAAC,CAAC,CAAC;aACN;SACJ;IACL,CAAC;CACJ,CAAA;AAjFG;IADC,kBAAU,CAAC,aAAa,CAAC;iDACI;AAG9B;IADC,kBAAU,CAAC,WAAW,CAAC;+CACI;AAfnB,YAAY;IADxB,sBAAS,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;GAChB,YAAY,CA6FxB;AA7FY,oCAAY","sourcesContent":["import * as ShellJS from 'shelljs';\nimport * as Path from 'path';\n\nimport { SourceReference } from '../../models/sources/file';\nimport { Component, ConverterComponent } from '../components';\nimport { BasePath } from '../utils/base-path';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { BindOption } from '../../utils';\n\n/**\n * Stores data of a repository.\n */\nexport class Repository {\n /**\n * The root path of this repository.\n */\n path: string;\n\n /**\n * The name of the branch this repository is on right now.\n */\n branch: string;\n\n /**\n * A list of all files tracked by the repository.\n */\n files: string[] = [];\n\n /**\n * The user/organization name of this repository on GitHub.\n */\n gitHubUser?: string;\n\n /**\n * The project name of this repository on GitHub.\n */\n gitHubProject?: string;\n\n /**\n * The hostname for this github project.\n *\n * Defaults to: `github.com` (for normal, public GitHub instance projects)\n *\n * Or the hostname for an enterprise version of GitHub, e.g. `github.acme.com`\n * (if found as a match in the list of git remotes).\n */\n gitHubHostname = 'github.com';\n\n /**\n * Create a new Repository instance.\n *\n * @param path The root path of the repository.\n */\n constructor(path: string, gitRevision: string, repoLinks: string[]) {\n this.path = path;\n this.branch = gitRevision || 'master';\n ShellJS.pushd(path);\n\n for (let i = 0, c = repoLinks.length; i < c; i++) {\n const url = /(github(?:\\.[a-z]+)*\\.com)[:\\/]([^\\/]+)\\/(.*)/.exec(repoLinks[i]);\n\n if (url) {\n this.gitHubHostname = url[1];\n this.gitHubUser = url[2];\n this.gitHubProject = url[3];\n if (this.gitHubProject.substr(-4) === '.git') {\n this.gitHubProject = this.gitHubProject.substr(0, this.gitHubProject.length - 4);\n }\n break;\n }\n }\n\n let out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git ls-files', {silent: true});\n if (out.code === 0) {\n out.stdout.split('\\n').forEach((file) => {\n if (file !== '') {\n this.files.push(BasePath.normalize(path + '/' + file));\n }\n });\n }\n\n if (!gitRevision) {\n out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git rev-parse --short HEAD', {silent: true});\n if (out.code === 0) {\n this.branch = out.stdout.replace('\\n', '');\n }\n }\n\n ShellJS.popd();\n }\n\n /**\n * Check whether the given file is tracked by this repository.\n *\n * @param fileName The name of the file to test for.\n * @returns TRUE when the file is part of the repository, otherwise FALSE.\n */\n contains(fileName: string): boolean {\n return this.files.includes(fileName);\n }\n\n /**\n * Get the URL of the given file on GitHub.\n *\n * @param fileName The file whose GitHub URL should be determined.\n * @returns An url pointing to the web preview of the given file or NULL.\n */\n getGitHubURL(fileName: string): string | undefined {\n if (!this.gitHubUser || !this.gitHubProject || !this.contains(fileName)) {\n return;\n }\n\n return [\n `https://${this.gitHubHostname}`,\n this.gitHubUser,\n this.gitHubProject,\n 'blob',\n this.branch,\n fileName.substr(this.path.length + 1)\n ].join('/');\n }\n\n /**\n * Try to create a new repository instance.\n *\n * Checks whether the given path is the root of a valid repository and if so\n * creates a new instance of [[Repository]].\n *\n * @param path The potential repository root.\n * @returns A new instance of [[Repository]] or undefined.\n */\n static tryCreateRepository(path: string, gitRevision: string, gitRemote: string): Repository | undefined {\n ShellJS.pushd(path);\n const out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git rev-parse --show-toplevel', {silent: true});\n const remotesOutput = <ShellJS.ExecOutputReturnValue> ShellJS.exec(`git remote get-url ${gitRemote}`, {silent: true});\n ShellJS.popd();\n\n if (!out || out.code !== 0 || !remotesOutput || remotesOutput.code !== 0) {\n return;\n }\n\n let remotes: string[] = (remotesOutput.code === 0) ? remotesOutput.stdout.split('\\n') : [];\n\n return new Repository(BasePath.normalize(out.stdout.replace('\\n', '')), gitRevision, remotes);\n }\n}\n\n/**\n * A handler that watches for repositories with GitHub origin and links\n * their source files to the related GitHub pages.\n */\n@Component({name: 'git-hub'})\nexport class GitHubPlugin extends ConverterComponent {\n /**\n * List of known repositories.\n */\n private repositories: {[path: string]: Repository} = {};\n\n /**\n * List of paths known to be not under git control.\n */\n private ignoredPaths: string[] = [];\n\n @BindOption('gitRevision')\n readonly gitRevision!: string;\n\n @BindOption('gitRemote')\n readonly gitRemote!: string;\n\n /**\n * Create a new GitHubHandler instance.\n *\n * @param converter The converter this plugin should be attached to.\n */\n initialize() {\n ShellJS.config.silent = true;\n if (ShellJS.which('git')) {\n this.listenTo(this.owner, Converter.EVENT_RESOLVE_END, this.onEndResolve);\n }\n }\n\n /**\n * Check whether the given file is placed inside a repository.\n *\n * @param fileName The name of the file a repository should be looked for.\n * @returns The found repository info or undefined.\n */\n private getRepository(fileName: string): Repository | undefined {\n // Check for known non-repositories\n const dirName = Path.dirname(fileName);\n for (let i = 0, c = this.ignoredPaths.length; i < c; i++) {\n if (this.ignoredPaths[i] === dirName) {\n return;\n }\n }\n\n // Check for known repositories\n for (let path in this.repositories) {\n if (!this.repositories.hasOwnProperty(path)) {\n continue;\n }\n if (fileName.substr(0, path.length).toLowerCase() === path) {\n return this.repositories[path];\n }\n }\n\n // Try to create a new repository\n const repository = Repository.tryCreateRepository(dirName, this.gitRevision, this.gitRemote);\n if (repository) {\n this.repositories[repository.path.toLowerCase()] = repository;\n return repository;\n }\n\n // No repository found, add path to ignored paths\n const segments = dirName.split('/');\n for (let i = segments.length; i > 0; i--) {\n this.ignoredPaths.push(segments.slice(0, i).join('/'));\n }\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onEndResolve(context: Context) {\n const project = context.project;\n project.files.forEach((sourceFile) => {\n const repository = this.getRepository(sourceFile.fullFileName);\n if (repository) {\n sourceFile.url = repository.getGitHubURL(sourceFile.fullFileName);\n }\n });\n\n for (let key in project.reflections) {\n const reflection = project.reflections[key];\n if (reflection.sources) {\n reflection.sources.forEach((source: SourceReference) => {\n if (source.file && source.file.url) {\n source.url = source.file.url + '#L' + source.line;\n }\n });\n }\n }\n }\n}\n"]}
|
|
@@ -49,6 +49,9 @@ let SourcePlugin = class SourcePlugin extends components_1.ConverterComponent {
|
|
|
49
49
|
}
|
|
50
50
|
const fileName = node.fileName;
|
|
51
51
|
this.basePath.add(fileName);
|
|
52
|
+
if (context.getCompilerOptions().baseUrl) {
|
|
53
|
+
this.basePath.add(context.getCompilerOptions().baseUrl + '/file');
|
|
54
|
+
}
|
|
52
55
|
this.getSourceFile(fileName, context.project);
|
|
53
56
|
}
|
|
54
57
|
onDeclaration(context, reflection, node) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourcePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/SourcePlugin.ts"],"names":[],"mappings":";;;;;;;;AAAA,6BAA6B;AAC7B,iCAAiC;AAGjC,0DAAsG;AACtG,sDAAyE;AACzE,8CAA8D;AAC9D,kDAA8C;AAC9C,4CAAyC;AAEzC,uCAAyC;AAMzC,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,+BAAkB;IAApD;;QAOY,aAAQ,GAAG,IAAI,oBAAQ,EAAE,CAAC;QAK1B,iBAAY,GAAiC,EAAE,CAAC;IA0J5D,CAAC;IArJG,UAAU;QACN,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;YACtB,CAAC,qBAAS,CAAC,WAAW,CAAC,EAAe,IAAI,CAAC,OAAO;YAClD,CAAC,qBAAS,CAAC,gBAAgB,CAAC,EAAU,IAAI,CAAC,e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WAAW,CAAC,SAAS,CAAC,CAAC;gBACjD,CAAC,CAAC,CAAC;aACN;YAED,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE3B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;YACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AApKG;IADC,kBAAU,CAAC,gBAAgB,CAAC;oDACK;AAFzB,YAAY;IADxB,sBAAS,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;GACf,YAAY,CAsKxB;AAtKY,oCAAY","sourcesContent":["import * as Path from 'path';\nimport * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection, ProjectReflection, DeclarationReflection } from '../../models/reflections/index';\nimport { SourceDirectory, SourceFile } from '../../models/sources/index';\nimport { Component, ConverterComponent } from '../components';\nimport { BasePath } from '../utils/base-path';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { BindOption } from '../../utils';\n\n/**\n * A handler that attaches source file information to reflections.\n */\n@Component({name: 'source'})\nexport class SourcePlugin extends ConverterComponent {\n @BindOption('disableSources')\n readonly disableSources!: boolean;\n\n /**\n * Helper for resolving the base path of all source files.\n */\n private basePath = new BasePath();\n\n /**\n * A map of all generated [[SourceFile]] instances.\n */\n private fileMappings: {[name: string]: SourceFile} = {};\n\n /**\n * Create a new SourceHandler instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [Converter.EVENT_BEGIN]: this.onBegin,\n [Converter.EVENT_FILE_BEGIN]: this.onBeginDocument,\n [Converter.EVENT_CREATE_DECLARATION]: this.onDeclaration,\n [Converter.EVENT_CREATE_SIGNATURE]: this.onDeclaration,\n [Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,\n [Converter.EVENT_RESOLVE]: this.onResolve,\n [Converter.EVENT_RESOLVE_END]: this.onEndResolve\n });\n }\n\n private getSourceFile(fileName: string, project: ProjectReflection): SourceFile {\n if (!this.fileMappings[fileName]) {\n const file = new SourceFile(fileName);\n this.fileMappings[fileName] = file;\n project.files.push(file);\n }\n\n return this.fileMappings[fileName];\n }\n\n /**\n * Triggered once per project before the dispatcher invokes the compiler.\n *\n * @param event An event object containing the related project and compiler instance.\n */\n private onBegin() {\n this.basePath.reset();\n this.fileMappings = {};\n }\n\n /**\n * Triggered when the converter begins converting a source file.\n *\n * Create a new [[SourceFile]] instance for all TypeScript files.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onBeginDocument(context: Context, reflection: Reflection, node?: ts.SourceFile) {\n if (!node) {\n return;\n }\n const fileName = node.fileName;\n this.basePath.add(fileName);\n this.getSourceFile(fileName, context.project);\n }\n\n /**\n * Triggered when the converter has created a declaration reflection.\n *\n * Attach the current source file to the [[DeclarationReflection.sources]] array.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onDeclaration(context: Context, reflection: Reflection, node?: ts.Node) {\n if (!node || this.disableSources) {\n return;\n }\n const sourceFile = node.getSourceFile();\n const fileName = sourceFile.fileName;\n this.basePath.add(fileName);\n const file: SourceFile = this.getSourceFile(fileName, context.project);\n\n let position: ts.LineAndCharacter;\n if (node['name'] && node['name'].end) {\n position = ts.getLineAndCharacterOfPosition(sourceFile, node['name'].end);\n } else {\n position = ts.getLineAndCharacterOfPosition(sourceFile, node.pos);\n }\n\n if (reflection instanceof DeclarationReflection) {\n file.reflections.push(reflection);\n }\n\n if (!reflection.sources) {\n reflection.sources = [];\n }\n\n reflection.sources.push({\n file: file,\n fileName: fileName,\n line: position.line + 1,\n character: position.character\n });\n }\n\n /**\n * Triggered when the converter begins resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onBeginResolve(context: Context) {\n context.project.files.forEach((file) => {\n const fileName = file.fileName = this.basePath.trim(file.fileName);\n this.fileMappings[fileName] = file;\n });\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: Reflection) {\n if (!reflection.sources) {\n return;\n }\n reflection.sources.forEach((source) => {\n source.fileName = this.basePath.trim(source.fileName);\n });\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onEndResolve(context: Context) {\n const project = context.project;\n const home = project.directory;\n project.files.forEach((file) => {\n const reflections: Reflection[] = [];\n file.reflections.forEach((reflection) => {\n reflections.push(reflection);\n });\n\n let directory = home;\n const path = Path.dirname(file.fileName);\n if (path !== '.') {\n path.split('/').forEach((pathPiece) => {\n if (!Object.prototype.hasOwnProperty.call(directory.directories, pathPiece)) {\n directory.directories[pathPiece] = new SourceDirectory(pathPiece, directory);\n }\n directory = directory.directories[pathPiece];\n });\n }\n\n directory.files.push(file);\n // reflections.sort(GroupHandler.sortCallback);\n file.parent = directory;\n file.reflections = reflections;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SourcePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/SourcePlugin.ts"],"names":[],"mappings":";;;;;;;;AAAA,6BAA6B;AAC7B,iCAAiC;AAGjC,0DAAsG;AACtG,sDAAyE;AACzE,8CAA8D;AAC9D,kDAA8C;AAC9C,4CAAyC;AAEzC,uCAAyC;AAMzC,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,+BAAkB;IAApD;;QAOY,aAAQ,GAAG,IAAI,oBAAQ,EAAE,CAAC;QAK1B,iBAAY,GAAiC,EAAE,CAAC;IA6J5D,CAAC;IAxJG,UAAU;QACN,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;YACtB,CAAC,qBAAS,CAAC,WAAW,CAAC,EAAe,IAAI,CAAC,OAAO;YAClD,CAAC,qBAAS,CAAC,gBAAgB,CAAC,EAAU,IAAI,CAAC,eAAe;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AAW,EAAE,SAAS,CAAC,EAAE;wBACzE,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI,uBAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;qBAChF;oBACD,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBACjD,CAAC,CAAC,CAAC;aACN;YAED,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE3B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;YACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAvKG;IADC,kBAAU,CAAC,gBAAgB,CAAC;oDACK;AAFzB,YAAY;IADxB,sBAAS,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;GACf,YAAY,CAyKxB;AAzKY,oCAAY","sourcesContent":["import * as Path from 'path';\nimport * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection, ProjectReflection, DeclarationReflection } from '../../models/reflections/index';\nimport { SourceDirectory, SourceFile } from '../../models/sources/index';\nimport { Component, ConverterComponent } from '../components';\nimport { BasePath } from '../utils/base-path';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { BindOption } from '../../utils';\n\n/**\n * A handler that attaches source file information to reflections.\n */\n@Component({name: 'source'})\nexport class SourcePlugin extends ConverterComponent {\n @BindOption('disableSources')\n readonly disableSources!: boolean;\n\n /**\n * Helper for resolving the base path of all source files.\n */\n private basePath = new BasePath();\n\n /**\n * A map of all generated [[SourceFile]] instances.\n */\n private fileMappings: {[name: string]: SourceFile} = {};\n\n /**\n * Create a new SourceHandler instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [Converter.EVENT_BEGIN]: this.onBegin,\n [Converter.EVENT_FILE_BEGIN]: this.onBeginDocument,\n [Converter.EVENT_CREATE_DECLARATION]: this.onDeclaration,\n [Converter.EVENT_CREATE_SIGNATURE]: this.onDeclaration,\n [Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,\n [Converter.EVENT_RESOLVE]: this.onResolve,\n [Converter.EVENT_RESOLVE_END]: this.onEndResolve\n });\n }\n\n private getSourceFile(fileName: string, project: ProjectReflection): SourceFile {\n if (!this.fileMappings[fileName]) {\n const file = new SourceFile(fileName);\n this.fileMappings[fileName] = file;\n project.files.push(file);\n }\n\n return this.fileMappings[fileName];\n }\n\n /**\n * Triggered once per project before the dispatcher invokes the compiler.\n *\n * @param event An event object containing the related project and compiler instance.\n */\n private onBegin() {\n this.basePath.reset();\n this.fileMappings = {};\n }\n\n /**\n * Triggered when the converter begins converting a source file.\n *\n * Create a new [[SourceFile]] instance for all TypeScript files.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onBeginDocument(context: Context, reflection: Reflection, node?: ts.SourceFile) {\n if (!node) {\n return;\n }\n const fileName = node.fileName;\n this.basePath.add(fileName);\n if (context.getCompilerOptions().baseUrl) {\n this.basePath.add(context.getCompilerOptions().baseUrl as string + '/file');\n }\n this.getSourceFile(fileName, context.project);\n }\n\n /**\n * Triggered when the converter has created a declaration reflection.\n *\n * Attach the current source file to the [[DeclarationReflection.sources]] array.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onDeclaration(context: Context, reflection: Reflection, node?: ts.Node) {\n if (!node || this.disableSources) {\n return;\n }\n const sourceFile = node.getSourceFile();\n const fileName = sourceFile.fileName;\n this.basePath.add(fileName);\n const file: SourceFile = this.getSourceFile(fileName, context.project);\n\n let position: ts.LineAndCharacter;\n if (node['name'] && node['name'].end) {\n position = ts.getLineAndCharacterOfPosition(sourceFile, node['name'].end);\n } else {\n position = ts.getLineAndCharacterOfPosition(sourceFile, node.pos);\n }\n\n if (reflection instanceof DeclarationReflection) {\n file.reflections.push(reflection);\n }\n\n if (!reflection.sources) {\n reflection.sources = [];\n }\n\n reflection.sources.push({\n file: file,\n fileName: fileName,\n line: position.line + 1,\n character: position.character\n });\n }\n\n /**\n * Triggered when the converter begins resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onBeginResolve(context: Context) {\n context.project.files.forEach((file) => {\n const fileName = file.fileName = this.basePath.trim(file.fileName);\n this.fileMappings[fileName] = file;\n });\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: Reflection) {\n if (!reflection.sources) {\n return;\n }\n reflection.sources.forEach((source) => {\n source.fileName = this.basePath.trim(source.fileName);\n });\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onEndResolve(context: Context) {\n const project = context.project;\n const home = project.directory;\n project.files.forEach((file) => {\n const reflections: Reflection[] = [];\n file.reflections.forEach((reflection) => {\n reflections.push(reflection);\n });\n\n let directory = home;\n const path = Path.dirname(file.fileName);\n if (path !== '.') {\n path.split('/').forEach((pathPiece) => {\n if (!Object.prototype.hasOwnProperty.call(directory.directories, pathPiece)) {\n directory.directories[pathPiece] = new SourceDirectory(pathPiece, directory);\n }\n directory = directory.directories[pathPiece];\n });\n }\n\n directory.files.push(file);\n // reflections.sort(GroupHandler.sortCallback);\n file.parent = directory;\n file.reflections = reflections;\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typedoc",
|
|
3
3
|
"description": "Create api documentation for TypeScript projects.",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.8",
|
|
5
5
|
"homepage": "https://typedoc.org",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"typings": "dist/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"minimatch": "^3.0.0",
|
|
30
30
|
"progress": "^2.0.3",
|
|
31
31
|
"shelljs": "^0.8.4",
|
|
32
|
-
"typedoc-default-themes": "^0.10.
|
|
32
|
+
"typedoc-default-themes": "^0.10.2"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"typescript": ">=3.8.3"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
import { ConverterTypeComponent, TypeTypeConverter } from '../components';
|
|
3
|
-
import { Context } from '../context';
|
|
4
|
-
import { Type } from '../../models';
|
|
5
|
-
export declare class ObjectType extends Type {
|
|
6
|
-
readonly type = "object";
|
|
7
|
-
clone(): ObjectType;
|
|
8
|
-
}
|
|
9
|
-
export declare class ConditionalConverter extends ConverterTypeComponent implements TypeTypeConverter<ts.ObjectType> {
|
|
10
|
-
supportsType(context: Context, type: ts.Type): boolean;
|
|
11
|
-
convertType(context: Context, type: ts.ObjectType): ObjectType | undefined;
|
|
12
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const ts = require("typescript");
|
|
10
|
-
const components_1 = require("../components");
|
|
11
|
-
const models_1 = require("../../models");
|
|
12
|
-
class ObjectType extends models_1.Type {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
this.type = 'object';
|
|
16
|
-
}
|
|
17
|
-
clone() {
|
|
18
|
-
return new ObjectType;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.ObjectType = ObjectType;
|
|
22
|
-
let ConditionalConverter = class ConditionalConverter extends components_1.ConverterTypeComponent {
|
|
23
|
-
supportsType(context, type) {
|
|
24
|
-
return !!(type.flags & ts.TypeFlags.Object)
|
|
25
|
-
&& !!(type.objectFlags & ts.ObjectFlags.Anonymous)
|
|
26
|
-
&& !type.symbol;
|
|
27
|
-
}
|
|
28
|
-
convertType(context, type) {
|
|
29
|
-
return new ObjectType;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
ConditionalConverter = __decorate([
|
|
33
|
-
components_1.Component({ name: 'type:anonymous' })
|
|
34
|
-
], ConditionalConverter);
|
|
35
|
-
exports.ConditionalConverter = ConditionalConverter;
|
|
36
|
-
//# sourceMappingURL=anonymous.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anonymous.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/anonymous.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAAiC;AAEjC,8CAAqF;AAErF,yCAAoC;AAEpC,MAAa,UAAW,SAAQ,aAAI;IAApC;;QACa,SAAI,GAAG,QAAQ,CAAA;IAK5B,CAAC;IAHG,KAAK;QACD,OAAO,IAAI,UAAU,CAAA;IACzB,CAAC;CACJ;AAND,gCAMC;AAGD,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,mCAAsB;IAC5D,YAAY,CAAC,OAAgB,EAAE,IAAa;QACxC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC;eACpC,CAAC,CAAC,CAAE,IAAsB,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;eAClE,CAAC,IAAI,CAAC,MAAM,CAAA;IACvB,CAAC;IAED,WAAW,CAAC,OAAgB,EAAE,IAAmB;QAC7C,OAAO,IAAI,UAAU,CAAA;IACzB,CAAC;CACJ,CAAA;AAVY,oBAAoB;IADhC,sBAAS,CAAC,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC;GACvB,oBAAoB,CAUhC;AAVY,oDAAoB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Component, ConverterTypeComponent, TypeTypeConverter } from '../components';\nimport { Context } from '../context';\nimport { Type } from '../../models';\n\nexport class ObjectType extends Type {\n readonly type = 'object'\n\n clone() {\n return new ObjectType\n }\n}\n\n@Component({name: 'type:anonymous'})\nexport class ConditionalConverter extends ConverterTypeComponent implements TypeTypeConverter<ts.ObjectType> {\n supportsType(context: Context, type: ts.Type): boolean {\n return !!(type.flags & ts.TypeFlags.Object)\n && !!((type as ts.ObjectType).objectFlags & ts.ObjectFlags.Anonymous)\n && !type.symbol // No anonymous classes... not sure how to handle them yet.\n }\n\n convertType(context: Context, type: ts.ObjectType): ObjectType | undefined {\n return new ObjectType\n }\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
export declare class BaseReflection {
|
|
3
|
-
id: number;
|
|
4
|
-
parent?: BaseReflection;
|
|
5
|
-
}
|
|
6
|
-
export declare class EnumReflection extends BaseReflection {
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly members: EnumMemberReflection[];
|
|
9
|
-
constructor(name: string, members: EnumMemberReflection[]);
|
|
10
|
-
}
|
|
11
|
-
export declare class EnumMemberReflection extends BaseReflection {
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly value: string | number;
|
|
14
|
-
constructor(name: string, value: string | number);
|
|
15
|
-
}
|
|
16
|
-
export declare function convertEnum(symbol: ts.Symbol): EnumReflection | undefined;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ts = require("typescript");
|
|
4
|
-
let foo = 1;
|
|
5
|
-
class BaseReflection {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.id = foo++;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.BaseReflection = BaseReflection;
|
|
11
|
-
class EnumReflection extends BaseReflection {
|
|
12
|
-
constructor(name, members) {
|
|
13
|
-
super();
|
|
14
|
-
this.name = name;
|
|
15
|
-
this.members = members;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.EnumReflection = EnumReflection;
|
|
19
|
-
class EnumMemberReflection extends BaseReflection {
|
|
20
|
-
constructor(name, value) {
|
|
21
|
-
super();
|
|
22
|
-
this.name = name;
|
|
23
|
-
this.value = value;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.EnumMemberReflection = EnumMemberReflection;
|
|
27
|
-
function convertEnum(symbol) {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
const declarations = (_b = (_a = symbol.getDeclarations()) === null || _a === void 0 ? void 0 : _a.filter(ts.isEnumDeclaration)) !== null && _b !== void 0 ? _b : [];
|
|
30
|
-
if (!declarations.length) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.convertEnum = convertEnum;
|
|
35
|
-
//# sourceMappingURL=converter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../src/lib/converter2/converter.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,IAAI,GAAG,GAAG,CAAC,CAAA;AAEX,MAAa,cAAc;IAA3B;QACI,OAAE,GAAG,GAAG,EAAE,CAAA;IAEd,CAAC;CAAA;AAHD,wCAGC;AAED,MAAa,cAAe,SAAQ,cAAc;IAC9C,YACa,IAAY,EACZ,OAA+B;QAExC,KAAK,EAAE,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAwB;IAG5C,CAAC;CACJ;AAPD,wCAOC;AAED,MAAa,oBAAqB,SAAQ,cAAc;IACpD,YACa,IAAY,EACZ,KAAsB;QAE/B,KAAK,EAAE,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAiB;IAGnC,CAAC;CACJ;AAPD,oDAOC;AAED,SAAgB,WAAW,CAAC,MAAiB;;IACzC,MAAM,YAAY,eAAG,MAAM,CAAC,eAAe,EAAE,0CAAE,MAAM,CAAC,EAAE,CAAC,iBAAiB,oCAAK,EAAE,CAAC;IAElF,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACtB,OAAO;KACV;AACL,CAAC;AAND,kCAMC","sourcesContent":["import * as ts from 'typescript';\n\nlet foo = 1\n\nexport class BaseReflection {\n id = foo++\n parent?: BaseReflection\n}\n\nexport class EnumReflection extends BaseReflection {\n constructor(\n readonly name: string,\n readonly members: EnumMemberReflection[]\n ) {\n super();\n }\n}\n\nexport class EnumMemberReflection extends BaseReflection {\n constructor(\n readonly name: string,\n readonly value: string | number\n ) {\n super();\n }\n}\n\nexport function convertEnum(symbol: ts.Symbol): EnumReflection | undefined {\n const declarations = symbol.getDeclarations()?.filter(ts.isEnumDeclaration) ?? [];\n\n if (!declarations.length) {\n return;\n }\n}\n"]}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/converter2/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=enum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/lib/converter2/symbols/enum.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Type } from './abstract';
|
|
2
|
-
export interface ObjectProperty {
|
|
3
|
-
name: string;
|
|
4
|
-
type: Type;
|
|
5
|
-
}
|
|
6
|
-
export declare class ObjectType extends Type {
|
|
7
|
-
readonly type = "object";
|
|
8
|
-
properties: ObjectProperty[];
|
|
9
|
-
constructor(properties: ObjectProperty[]);
|
|
10
|
-
clone(): ObjectType;
|
|
11
|
-
equals(type: unknown): boolean;
|
|
12
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const abstract_1 = require("./abstract");
|
|
4
|
-
var ObjectPropertyFlags;
|
|
5
|
-
(function (ObjectPropertyFlags) {
|
|
6
|
-
ObjectPropertyFlags[ObjectPropertyFlags["Readonly"] = 1] = "Readonly";
|
|
7
|
-
ObjectPropertyFlags[ObjectPropertyFlags["Optional"] = 2] = "Optional";
|
|
8
|
-
})(ObjectPropertyFlags = exports.ObjectPropertyFlags || (exports.ObjectPropertyFlags = {}));
|
|
9
|
-
class ObjectType extends abstract_1.Type {
|
|
10
|
-
constructor(properties) {
|
|
11
|
-
super();
|
|
12
|
-
this.type = 'object';
|
|
13
|
-
this.properties = properties;
|
|
14
|
-
}
|
|
15
|
-
clone() {
|
|
16
|
-
return new ObjectType(this.properties);
|
|
17
|
-
}
|
|
18
|
-
equals(type) {
|
|
19
|
-
if (!(type instanceof ObjectType)) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.ObjectType = ObjectType;
|
|
26
|
-
//# sourceMappingURL=object.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../src/lib/models/types/object.ts"],"names":[],"mappings":";;AAAA,yCAAiC;AAEjC,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC3B,qEAAiB,CAAA;IACjB,qEAAiB,CAAA;AACrB,CAAC,EAHW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAG9B;AAeD,MAAa,UAAW,SAAQ,eAAI;IAShC,YACI,UAA4B;QAE5B,KAAK,EAAE,CAAC;QAXH,SAAI,GAAG,QAAQ,CAAC;QAYrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,KAAK;QACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,CAAC,IAAa;QAChB,IAAI,CAAC,CAAC,IAAI,YAAY,UAAU,CAAC,EAAE;YAC/B,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA1BD,gCA0BC","sourcesContent":["import { Type } from './abstract'\n\nexport enum ObjectPropertyFlags {\n Readonly = 1 << 0,\n Optional = 1 << 1\n}\n\nexport interface ObjectProperty {\n name: string\n type: Type\n flags: ObjectPropertyFlags\n}\n\nexport interface Signature {\n parameters: Parameter[]\n typeParameters: TypeParameter[]\n returnType: Type\n\n}\n\nexport class ObjectType extends Type {\n readonly type = 'object';\n\n properties: ObjectProperty[];\n signatures: Signature[];\n constructSignatures: Signature[];\n stringIndexSignature?: Type;\n numberIndexSignature?: Type;\n\n constructor(\n properties: ObjectProperty[],\n ) {\n super();\n this.properties = properties;\n }\n\n clone() {\n return new ObjectType(this.properties)\n }\n\n equals(type: unknown) {\n if (!(type instanceof ObjectType)) {\n return false;\n }\n return true;\n }\n}\n"]}
|