typedoc 0.15.4 → 0.15.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.
Files changed (72) hide show
  1. package/dist/lib/application.js +1 -1
  2. package/dist/lib/converter/converter.js +3 -0
  3. package/dist/lib/converter/converter.js.map +1 -1
  4. package/dist/lib/converter/factories/comment.js +11 -2
  5. package/dist/lib/converter/factories/comment.js.map +1 -1
  6. package/dist/lib/converter/plugins/CommentPlugin.js +3 -0
  7. package/dist/lib/converter/plugins/CommentPlugin.js.map +1 -1
  8. package/dist/lib/converter/plugins/PackagePlugin.js +1 -1
  9. package/dist/lib/converter/plugins/PackagePlugin.js.map +1 -1
  10. package/dist/lib/converter/types/conditional.d.ts +10 -0
  11. package/dist/lib/converter/types/conditional.js +38 -0
  12. package/dist/lib/converter/types/conditional.js.map +1 -0
  13. package/dist/lib/converter/types/index.d.ts +3 -0
  14. package/dist/lib/converter/types/index.js +6 -0
  15. package/dist/lib/converter/types/index.js.map +1 -1
  16. package/dist/lib/converter/types/indexed-access.d.ts +8 -0
  17. package/dist/lib/converter/types/indexed-access.js +32 -0
  18. package/dist/lib/converter/types/indexed-access.js.map +1 -0
  19. package/dist/lib/converter/types/inferred.d.ts +8 -0
  20. package/dist/lib/converter/types/inferred.js +24 -0
  21. package/dist/lib/converter/types/inferred.js.map +1 -0
  22. package/dist/lib/converter/types/union-or-intersection.js.map +1 -1
  23. package/dist/lib/models/reflections/reference.d.ts +19 -0
  24. package/dist/lib/models/reflections/reference.js +74 -0
  25. package/dist/lib/models/reflections/reference.js.map +1 -0
  26. package/dist/lib/models/types/conditional.d.ts +13 -0
  27. package/dist/lib/models/types/conditional.js +38 -0
  28. package/dist/lib/models/types/conditional.js.map +1 -0
  29. package/dist/lib/models/types/index.d.ts +3 -0
  30. package/dist/lib/models/types/index.js +6 -0
  31. package/dist/lib/models/types/index.js.map +1 -1
  32. package/dist/lib/models/types/indexed-access.d.ts +11 -0
  33. package/dist/lib/models/types/indexed-access.js +28 -0
  34. package/dist/lib/models/types/indexed-access.js.map +1 -0
  35. package/dist/lib/models/types/inferred.d.ts +10 -0
  36. package/dist/lib/models/types/inferred.js +27 -0
  37. package/dist/lib/models/types/inferred.js.map +1 -0
  38. package/dist/lib/output/plugins/MarkedPlugin.js +1 -1
  39. package/dist/lib/output/plugins/MarkedPlugin.js.map +1 -1
  40. package/dist/lib/output/renderer.js +1 -1
  41. package/dist/lib/output/renderer.js.map +1 -1
  42. package/dist/lib/output/utils/resources/templates.d.ts +1 -1
  43. package/dist/lib/output/utils/resources/templates.js +1 -1
  44. package/dist/lib/output/utils/resources/templates.js.map +1 -1
  45. package/dist/lib/serialization/serializers/reflections/reference.d.ts +6 -0
  46. package/dist/lib/serialization/serializers/reflections/reference.js +25 -0
  47. package/dist/lib/serialization/serializers/reflections/reference.js.map +1 -0
  48. package/dist/lib/serialization/serializers/types/conditional.d.ts +6 -0
  49. package/dist/lib/serialization/serializers/types/conditional.js +29 -0
  50. package/dist/lib/serialization/serializers/types/conditional.js.map +1 -0
  51. package/dist/lib/serialization/serializers/types/index.d.ts +3 -0
  52. package/dist/lib/serialization/serializers/types/index.js +3 -0
  53. package/dist/lib/serialization/serializers/types/index.js.map +1 -1
  54. package/dist/lib/serialization/serializers/types/indexed-access.d.ts +6 -0
  55. package/dist/lib/serialization/serializers/types/indexed-access.js +24 -0
  56. package/dist/lib/serialization/serializers/types/indexed-access.js.map +1 -0
  57. package/dist/lib/serialization/serializers/types/inferred.d.ts +6 -0
  58. package/dist/lib/serialization/serializers/types/inferred.js +24 -0
  59. package/dist/lib/serialization/serializers/types/inferred.js.map +1 -0
  60. package/dist/lib/utils/array.d.ts +4 -0
  61. package/dist/lib/utils/array.js +26 -0
  62. package/dist/lib/utils/array.js.map +1 -0
  63. package/dist/lib/utils/options/sources/decorator.d.ts +11 -0
  64. package/dist/lib/utils/options/sources/decorator.js +26 -0
  65. package/dist/lib/utils/options/sources/decorator.js.map +1 -0
  66. package/dist/lib/utils/plugins.js +2 -2
  67. package/dist/lib/utils/plugins.js.map +1 -1
  68. package/dist/lib/utils/result.d.ts +18 -0
  69. package/dist/lib/utils/result.js +53 -0
  70. package/dist/lib/utils/result.js.map +1 -0
  71. package/package.json +9 -10
  72. package/tasks/typedoc.js +0 -56
@@ -138,7 +138,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
138
138
  ].join(typescript.sys.newLine);
139
139
  }
140
140
  };
141
- Application.VERSION = '0.15.4';
141
+ Application.VERSION = '0.15.8';
142
142
  __decorate([
143
143
  component_1.Option({
144
144
  name: 'logger',
@@ -146,6 +146,9 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
146
146
  includedSourceFiles.forEach((sourceFile) => {
147
147
  this.convertNode(context, sourceFile);
148
148
  });
149
+ if (this.application.ignoreCompilerErrors) {
150
+ return [];
151
+ }
149
152
  let diagnostics = program.getOptionsDiagnostics().filter(isRelevantError);
150
153
  if (diagnostics.length) {
151
154
  return diagnostics;
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../src/lib/converter/converter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iCAAiC;AAEjC,4BAA4B;AAG5B,8DAA6D;AAE7D,uCAAoC;AACpC,6CAAwI;AACxI,kDAA2F;AAC3F,oCAA4C;AAC5C,0CAAiD;AAqBjD,IAAa,SAAS,iBAAtB,MAAa,SAAU,SAAQ,8BAAmD;IAkK9E,UAAU;QACN,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,YAAY,CAA2C,IAAY,EAAE,cAAqC;QACtG,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC3D,IAAI,SAAS,YAAY,mCAAsB,EAAE;YAC7C,IAAI,CAAC,gBAAgB,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E,kBAAkB;QACxB,IAAI,EAAE,qEAAqE;QAC3E,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;mDACyB;AAO3B;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,8DAA8D;QACpE,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;qDAC2B;AAO7B;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,uCAAuC;QAC7C,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;iDACuB;AAOzB;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,yCAAyC;QAC/C,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;mDACyB;AAlDlB,SAAS;IADrB,qBAAS,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,+BAAkB,EAAC,CAAC;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 { ParameterType } from '../utils/options/declaration';\nimport { Reflection, Type, ProjectReflection } from '../models/index';\nimport { Context } from './context';\nimport { ConverterComponent, ConverterNodeComponent, ConverterTypeComponent, TypeTypeConverter, TypeNodeConverter } from './components';\nimport { Component, Option, ChildableComponent, ComponentClass } from '../utils/component';\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 @Option({\n name: 'name',\n help: 'Set the name of the project that will be used in the header of the template.'\n })\n name!: string;\n\n @Option({\n name: 'externalPattern',\n help: 'Define patterns for files that should be considered being external.',\n type: ParameterType.Array\n })\n externalPattern!: Array<string>;\n\n @Option({\n name: 'includeDeclarations',\n help: 'Turn on parsing of .d.ts declaration files.',\n type: ParameterType.Boolean\n })\n includeDeclarations!: boolean;\n\n @Option({\n name: 'excludeExternals',\n help: 'Prevent externally resolved TypeScript files from being documented.',\n type: ParameterType.Boolean\n })\n excludeExternals!: boolean;\n\n @Option({\n name: 'excludeNotExported',\n help: 'Prevent symbols that are not exported from being documented.',\n type: ParameterType.Boolean\n })\n excludeNotExported!: boolean;\n\n @Option({\n name: 'excludePrivate',\n help: 'Ignores private variables and methods',\n type: ParameterType.Boolean\n })\n excludePrivate!: boolean;\n\n @Option({\n name: 'excludeProtected',\n help: 'Ignores protected variables and methods',\n type: ParameterType.Boolean\n })\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 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\n const exclude = createMinimatch(this.application.exclude || []);\n const isExcluded = (file: ts.SourceFile) => exclude.some(mm => mm.match(file.fileName));\n\n const includedSourceFiles = program.getSourceFiles()\n .filter(file => !isExcluded(file));\n const isRelevantError = ({ file }: ts.Diagnostic) => !file || includedSourceFiles.includes(file);\n\n includedSourceFiles.forEach((sourceFile) => {\n this.convertNode(context, sourceFile);\n });\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 * 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 /**\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,4BAA4B;AAG5B,8DAA6D;AAE7D,uCAAoC;AACpC,6CAAwI;AACxI,kDAA2F;AAC3F,oCAA4C;AAC5C,0CAAiD;AAqBjD,IAAa,SAAS,iBAAtB,MAAa,SAAU,SAAQ,8BAAmD;IAkK9E,UAAU;QACN,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,kBAAkB,GAAG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IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,qEAAqE;QAC3E,IAAI,EAAE,2BAAa,CAAC,KAAK;KAC5B,CAAC;kDAC8B;AAOhC;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,6CAA6C;QACnD,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;sDAC4B;AAO9B;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,qEAAqE;QAC3E,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;mDACyB;AAO3B;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,8DAA8D;QACpE,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;qDAC2B;AAO7B;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,uCAAuC;QAC7C,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;iDACuB;AAOzB;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,yCAAyC;QAC/C,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;mDACyB;AAlDlB,SAAS;IADrB,qBAAS,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,+BAAkB,EAAC,CAAC;GAClE,SAAS,CA6ZrB;AA7ZY,8BAAS","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../ts-internal';\nimport * as _ from 'lodash';\n\nimport { Application } from '../application';\nimport { ParameterType } from '../utils/options/declaration';\nimport { Reflection, Type, ProjectReflection } from '../models/index';\nimport { Context } from './context';\nimport { ConverterComponent, ConverterNodeComponent, ConverterTypeComponent, TypeTypeConverter, TypeNodeConverter } from './components';\nimport { Component, Option, ChildableComponent, ComponentClass } from '../utils/component';\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 @Option({\n name: 'name',\n help: 'Set the name of the project that will be used in the header of the template.'\n })\n name!: string;\n\n @Option({\n name: 'externalPattern',\n help: 'Define patterns for files that should be considered being external.',\n type: ParameterType.Array\n })\n externalPattern!: Array<string>;\n\n @Option({\n name: 'includeDeclarations',\n help: 'Turn on parsing of .d.ts declaration files.',\n type: ParameterType.Boolean\n })\n includeDeclarations!: boolean;\n\n @Option({\n name: 'excludeExternals',\n help: 'Prevent externally resolved TypeScript files from being documented.',\n type: ParameterType.Boolean\n })\n excludeExternals!: boolean;\n\n @Option({\n name: 'excludeNotExported',\n help: 'Prevent symbols that are not exported from being documented.',\n type: ParameterType.Boolean\n })\n excludeNotExported!: boolean;\n\n @Option({\n name: 'excludePrivate',\n help: 'Ignores private variables and methods',\n type: ParameterType.Boolean\n })\n excludePrivate!: boolean;\n\n @Option({\n name: 'excludeProtected',\n help: 'Ignores protected variables and methods',\n type: ParameterType.Boolean\n })\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 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\n const exclude = createMinimatch(this.application.exclude || []);\n const isExcluded = (file: ts.SourceFile) => exclude.some(mm => mm.match(file.fileName));\n\n const includedSourceFiles = program.getSourceFiles()\n .filter(file => !isExcluded(file));\n const isRelevantError = ({ file }: ts.Diagnostic) => !file || includedSourceFiles.includes(file);\n\n includedSourceFiles.forEach((sourceFile) => {\n this.convertNode(context, sourceFile);\n });\n\n if (this.application.ignoreCompilerErrors) {\n return [];\n }\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 * 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 /**\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"]}
@@ -55,14 +55,23 @@ function getRawComment(node) {
55
55
  const comments = getJSDocCommentRanges(node, sourceFile.text);
56
56
  if (comments.length) {
57
57
  let comment;
58
+ const explicitPackageComment = comments.find(comment => sourceFile.text.substring(comment.pos, comment.end).includes('@packageDocumentation'));
58
59
  if (node.kind === ts.SyntaxKind.SourceFile) {
59
- if (comments.length === 1) {
60
+ if (explicitPackageComment) {
61
+ comment = explicitPackageComment;
62
+ }
63
+ else if (comments.length > 1) {
64
+ comment = comments[0];
65
+ }
66
+ else {
60
67
  return;
61
68
  }
62
- comment = comments[0];
63
69
  }
64
70
  else {
65
71
  comment = comments[comments.length - 1];
72
+ if (sourceFile.text.substring(comment.pos, comment.end).includes('@packageDocumentation')) {
73
+ return;
74
+ }
66
75
  }
67
76
  return sourceFile.text.substring(comment.pos, comment.end);
68
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/comment.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC,mCAAiC;AAEjC,uDAAkE;AAQlE,SAAgB,aAAa,CAAC,IAAa;IACvC,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE;QACV,OAAO;KACV;IAED,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAPD,sCAOC;AAeD,SAAS,0BAA0B,CAAC,IAA0B;IAC1D,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;AACrD,CAAC;AAYD,SAAS,wBAAwB,CAAC,IAA0B;IACxD,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,EAAE;QACxE,MAAM,MAAM,GAA0B,IAAI,CAAC,MAAM,CAAC;QAClD,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE;YACvC,IAAI,GAAG,MAAM,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import * as ts from 'typescript';\nimport { toArray } from 'lodash';\n\nimport { Comment, CommentTag } from '../../models/comments/index';\n\n/**\n * Return the parsed comment of the given TypeScript node.\n *\n * @param node The node whose comment should be returned.\n * @return The parsed comment as a [[Comment]] instance or undefined if no comment is present.\n */\nexport function createComment(node: ts.Node): Comment | undefined {\n const comment = getRawComment(node);\n if (!comment) {\n return;\n }\n\n return parseComment(comment);\n}\n\n/**\n * Check whether the given module declaration is the topmost.\n *\n * This function returns TRUE if there is no trailing module defined, in\n * the following example this would be the case only for module <code>C</code>.\n *\n * ```\n * module A.B.C { }\n * ```\n *\n * @param node The module definition that should be tested.\n * @return TRUE if the given node is the topmost module declaration, FALSE otherwise.\n */\nfunction isTopmostModuleDeclaration(node: ts.ModuleDeclaration): boolean {\n return node.getChildren().some(ts.isModuleBlock);\n}\n\n/**\n * Return the root module declaration of the given module declaration.\n *\n * In the following example this function would always return module\n * <code>A</code> no matter which of the modules was passed in.\n *\n * ```\n * module A.B.C { }\n * ```\n */\nfunction getRootModuleDeclaration(node: ts.ModuleDeclaration): ts.Node {\n while (node.parent && node.parent.kind === ts.SyntaxKind.ModuleDeclaration) {\n const parent = <ts.ModuleDeclaration> node.parent;\n if (node.name.pos === parent.name.end + 1) {\n node = parent;\n } else {\n break;\n }\n }\n\n return node;\n}\n\n/**\n * Derived from the internal ts utility\n * https://github.com/Microsoft/TypeScript/blob/v3.2.2/src/compiler/utilities.ts#L954\n * @param node\n * @param text\n */\nfunction getJSDocCommentRanges(node: ts.Node, text: string): ts.CommentRange[] {\n const hasTrailingCommentRanges = [\n ts.SyntaxKind.Parameter,\n ts.SyntaxKind.FunctionExpression,\n ts.SyntaxKind.ArrowFunction,\n ts.SyntaxKind.ParenthesizedExpression\n ].includes(node.kind);\n\n let commentRanges = toArray(ts.getLeadingCommentRanges(text, node.pos));\n if (hasTrailingCommentRanges) {\n commentRanges = toArray(ts.getTrailingCommentRanges(text, node.pos)).concat(commentRanges);\n }\n\n // True if the comment starts with '/**' but not if it is '/**/'\n return commentRanges.filter(({ pos }) => text.substr(pos, 3) === '/**' && text[pos + 4] !== '/');\n}\n\n/**\n * Return the raw comment string for the given node.\n *\n * @param node The node whose comment should be resolved.\n * @returns The raw comment string or undefined if no comment could be found.\n */\nexport function getRawComment(node: ts.Node): string | undefined {\n if (node.parent && node.parent.kind === ts.SyntaxKind.VariableDeclarationList) {\n node = node.parent.parent;\n } else if (node.kind === ts.SyntaxKind.ModuleDeclaration) {\n if (!isTopmostModuleDeclaration(<ts.ModuleDeclaration> node)) {\n return;\n } else {\n node = getRootModuleDeclaration(<ts.ModuleDeclaration> node);\n }\n }\n\n const sourceFile = node.getSourceFile();\n const comments = getJSDocCommentRanges(node, sourceFile.text);\n if (comments.length) {\n let comment: ts.CommentRange;\n if (node.kind === ts.SyntaxKind.SourceFile) {\n if (comments.length === 1) {\n return;\n }\n comment = comments[0];\n } else {\n comment = comments[comments.length - 1];\n }\n\n return sourceFile.text.substring(comment.pos, comment.end);\n } else {\n return;\n }\n}\n\n/**\n * Parse the given doc comment string.\n *\n * @param text The doc comment string that should be parsed.\n * @param comment The [[Models.Comment]] instance the parsed results should be stored into.\n * @returns A populated [[Models.Comment]] instance.\n */\nexport function parseComment(text: string, comment: Comment = new Comment()): Comment {\n let currentTag: CommentTag;\n let shortText = 0;\n\n function consumeTypeData(line: string): string {\n line = line.replace(/^\\{[^\\}]*\\}+/, '');\n line = line.replace(/^\\[[^\\[][^\\]]*\\]+/, '');\n return line.trim();\n }\n\n function readBareLine(line: string) {\n if (currentTag) {\n currentTag.text += '\\n' + line;\n } else if (line === '' && shortText === 0) {\n // Ignore\n } else if (line === '' && shortText === 1) {\n shortText = 2;\n } else {\n if (shortText === 2) {\n comment.text += (comment.text === '' ? '' : '\\n') + line;\n } else {\n comment.shortText += (comment.shortText === '' ? '' : '\\n') + line;\n shortText = 1;\n }\n }\n }\n\n function readTagLine(line: string, tag: RegExpExecArray) {\n let tagName = tag[1].toLowerCase();\n let paramName: string | undefined;\n line = line.substr(tagName.length + 1).trim();\n\n if (tagName === 'return') { tagName = 'returns'; }\n if (tagName === 'param' || tagName === 'typeparam') {\n line = consumeTypeData(line);\n const param = /[^\\s]+/.exec(line);\n if (param) {\n paramName = param[0];\n line = line.substr(paramName.length + 1).trim();\n }\n line = consumeTypeData(line);\n line = line.replace(/^\\-\\s+/, '');\n } else if (tagName === 'returns') {\n line = consumeTypeData(line);\n }\n\n currentTag = new CommentTag(tagName, paramName, line);\n if (!comment.tags) { comment.tags = []; }\n comment.tags.push(currentTag);\n }\n\n const CODE_FENCE = /^\\s*```(?!.*```)/;\n let inCode = false;\n function readLine(line: string) {\n line = line.replace(/^\\s*\\*? ?/, '');\n line = line.replace(/\\s*$/, '');\n\n if (CODE_FENCE.test(line) ) {\n inCode = !inCode;\n }\n\n if (!inCode) {\n const tag = /^@(\\S+)/.exec(line);\n if (tag) {\n return readTagLine(line, tag);\n }\n }\n readBareLine(line);\n }\n\n text = text.replace(/^\\s*\\/\\*+/, '');\n text = text.replace(/\\*+\\/\\s*$/, '');\n text.split(/\\r\\n?|\\n/).forEach(readLine);\n\n return comment;\n}\n"]}
1
+ {"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/comment.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC,mCAAiC;AAEjC,uDAAkE;AAQlE,SAAgB,aAAa,CAAC,IAAa;IACvC,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE;QACV,OAAO;KACV;IAED,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAPD,sCAOC;AAeD,SAAS,0BAA0B,CAAC,IAA0B;IAC1D,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;AACrD,CAAC;AAYD,SAAS,wBAAwB,CAAC,IAA0B;IACxD,OAAO,IAAI,CAAC,MAAM,IAAI,IAA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ACrC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEhC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAG;YAC1B,MAAM,GAAG,CAAC,MAAM,CAAC;SAClB;QAED,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,GAAG,EAAE;gBACP,OAAO,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;aAC/B;SACF;QACD,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEzC,OAAO,OAAO,CAAC;AACnB,CAAC;AA3ED,oCA2EC","sourcesContent":["import * as ts from 'typescript';\nimport { toArray } from 'lodash';\n\nimport { Comment, CommentTag } from '../../models/comments/index';\n\n/**\n * Return the parsed comment of the given TypeScript node.\n *\n * @param node The node whose comment should be returned.\n * @return The parsed comment as a [[Comment]] instance or undefined if no comment is present.\n */\nexport function createComment(node: ts.Node): Comment | undefined {\n const comment = getRawComment(node);\n if (!comment) {\n return;\n }\n\n return parseComment(comment);\n}\n\n/**\n * Check whether the given module declaration is the topmost.\n *\n * This function returns TRUE if there is no trailing module defined, in\n * the following example this would be the case only for module <code>C</code>.\n *\n * ```\n * module A.B.C { }\n * ```\n *\n * @param node The module definition that should be tested.\n * @return TRUE if the given node is the topmost module declaration, FALSE otherwise.\n */\nfunction isTopmostModuleDeclaration(node: ts.ModuleDeclaration): boolean {\n return node.getChildren().some(ts.isModuleBlock);\n}\n\n/**\n * Return the root module declaration of the given module declaration.\n *\n * In the following example this function would always return module\n * <code>A</code> no matter which of the modules was passed in.\n *\n * ```\n * module A.B.C { }\n * ```\n */\nfunction getRootModuleDeclaration(node: ts.ModuleDeclaration): ts.Node {\n while (node.parent && node.parent.kind === ts.SyntaxKind.ModuleDeclaration) {\n const parent = <ts.ModuleDeclaration> node.parent;\n if (node.name.pos === parent.name.end + 1) {\n node = parent;\n } else {\n break;\n }\n }\n\n return node;\n}\n\n/**\n * Derived from the internal ts utility\n * https://github.com/Microsoft/TypeScript/blob/v3.2.2/src/compiler/utilities.ts#L954\n * @param node\n * @param text\n */\nfunction getJSDocCommentRanges(node: ts.Node, text: string): ts.CommentRange[] {\n const hasTrailingCommentRanges = [\n ts.SyntaxKind.Parameter,\n ts.SyntaxKind.FunctionExpression,\n ts.SyntaxKind.ArrowFunction,\n ts.SyntaxKind.ParenthesizedExpression\n ].includes(node.kind);\n\n let commentRanges = toArray(ts.getLeadingCommentRanges(text, node.pos));\n if (hasTrailingCommentRanges) {\n commentRanges = toArray(ts.getTrailingCommentRanges(text, node.pos)).concat(commentRanges);\n }\n\n // True if the comment starts with '/**' but not if it is '/**/'\n return commentRanges.filter(({ pos }) => text.substr(pos, 3) === '/**' && text[pos + 4] !== '/');\n}\n\n/**\n * Return the raw comment string for the given node.\n *\n * @param node The node whose comment should be resolved.\n * @returns The raw comment string or undefined if no comment could be found.\n */\nexport function getRawComment(node: ts.Node): string | undefined {\n if (node.parent && node.parent.kind === ts.SyntaxKind.VariableDeclarationList) {\n node = node.parent.parent;\n } else if (node.kind === ts.SyntaxKind.ModuleDeclaration) {\n if (!isTopmostModuleDeclaration(<ts.ModuleDeclaration> node)) {\n return;\n } else {\n node = getRootModuleDeclaration(<ts.ModuleDeclaration> node);\n }\n }\n\n const sourceFile = node.getSourceFile();\n const comments = getJSDocCommentRanges(node, sourceFile.text);\n if (comments.length) {\n let comment: ts.CommentRange;\n const explicitPackageComment = comments.find(comment =>\n sourceFile.text.substring(comment.pos, comment.end).includes('@packageDocumentation'));\n if (node.kind === ts.SyntaxKind.SourceFile) {\n if (explicitPackageComment) {\n comment = explicitPackageComment;\n } else if (comments.length > 1) {\n // Legacy behavior, require more than one comment and use the first comment.\n // TODO: GH#1083, follow deprecation process to phase this out.\n comment = comments[0];\n } else {\n // Single comment that may be a license comment, bail.\n return;\n }\n } else {\n comment = comments[comments.length - 1];\n // If a non-SourceFile node comment has this tag, it should not be attached to the node\n // as it documents the whole file by convention.\n if (sourceFile.text.substring(comment.pos, comment.end).includes('@packageDocumentation')) {\n return;\n }\n }\n\n return sourceFile.text.substring(comment.pos, comment.end);\n } else {\n return;\n }\n}\n\n/**\n * Parse the given doc comment string.\n *\n * @param text The doc comment string that should be parsed.\n * @param comment The [[Models.Comment]] instance the parsed results should be stored into.\n * @returns A populated [[Models.Comment]] instance.\n */\nexport function parseComment(text: string, comment: Comment = new Comment()): Comment {\n let currentTag: CommentTag;\n let shortText = 0;\n\n function consumeTypeData(line: string): string {\n line = line.replace(/^\\{[^\\}]*\\}+/, '');\n line = line.replace(/^\\[[^\\[][^\\]]*\\]+/, '');\n return line.trim();\n }\n\n function readBareLine(line: string) {\n if (currentTag) {\n currentTag.text += '\\n' + line;\n } else if (line === '' && shortText === 0) {\n // Ignore\n } else if (line === '' && shortText === 1) {\n shortText = 2;\n } else {\n if (shortText === 2) {\n comment.text += (comment.text === '' ? '' : '\\n') + line;\n } else {\n comment.shortText += (comment.shortText === '' ? '' : '\\n') + line;\n shortText = 1;\n }\n }\n }\n\n function readTagLine(line: string, tag: RegExpExecArray) {\n let tagName = tag[1].toLowerCase();\n let paramName: string | undefined;\n line = line.substr(tagName.length + 1).trim();\n\n if (tagName === 'return') { tagName = 'returns'; }\n if (tagName === 'param' || tagName === 'typeparam') {\n line = consumeTypeData(line);\n const param = /[^\\s]+/.exec(line);\n if (param) {\n paramName = param[0];\n line = line.substr(paramName.length + 1).trim();\n }\n line = consumeTypeData(line);\n line = line.replace(/^\\-\\s+/, '');\n } else if (tagName === 'returns') {\n line = consumeTypeData(line);\n }\n\n currentTag = new CommentTag(tagName, paramName, line);\n if (!comment.tags) { comment.tags = []; }\n comment.tags.push(currentTag);\n }\n\n const CODE_FENCE = /^\\s*```(?!.*```)/;\n let inCode = false;\n function readLine(line: string) {\n line = line.replace(/^\\s*\\*? ?/, '');\n line = line.replace(/\\s*$/, '');\n\n if (CODE_FENCE.test(line) ) {\n inCode = !inCode;\n }\n\n if (!inCode) {\n const tag = /^@(\\S+)/.exec(line);\n if (tag) {\n return readTagLine(line, tag);\n }\n }\n readBareLine(line);\n }\n\n text = text.replace(/^\\s*\\/\\*+/, '');\n text = text.replace(/\\*+\\/\\s*$/, '');\n text.split(/\\r\\n?|\\n/).forEach(readLine);\n\n return comment;\n}\n"]}
@@ -68,6 +68,9 @@ let CommentPlugin = CommentPlugin_1 = class CommentPlugin extends components_1.C
68
68
  }
69
69
  this.hidden.push(reflection);
70
70
  }
71
+ if (reflection.kindOf(index_3.ReflectionKind.ExternalModule)) {
72
+ CommentPlugin_1.removeTags(comment, 'packagedocumentation');
73
+ }
71
74
  }
72
75
  onBegin(context) {
73
76
  this.hidden = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"CommentPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/CommentPlugin.ts"],"names":[],"mappings":";;;;;;;;;AAEA,uDAAkE;AAClE,oDAAyD;AACzD,0DAEqF;AACrF,8CAA8D;AAC9D,kDAAmE;AACnE,4CAAyC;AA4BzC,IAAa,aAAa,qBAA1B,MAAa,aAAc,SAAQ,+BAAkB;IAejD,UAAU;QACN,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;YACtB,CAAC,qBAAS,CAAC,WAAW,CAAC,EAAoB,IAAI,CAAC,OAAO;YACvD,CAAC,qBAAS,CAAC,wBAAwB,CAAC,EAAO,IAAI,CAAC,aAAa;YAC7D,CAAC,qBAAS,CAAC,sBAAsB,CAAC,EAAS,IAAI,CAAC,aAAa;YAC7D,CAAC,qBA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ACvB;aAAM;YACH,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,aAAa,EAAE;gBACrC,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE;oBAChF,OAAO,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;iBACrC;aACJ;SACJ;IAEL,CAAC;CACJ,CAAA;AAlXY,aAAa;IADzB,sBAAS,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;GAChB,aAAa,CAkXzB;AAlXY,sCAAa","sourcesContent":["import * as ts from 'typescript';\n\nimport { Comment, CommentTag } from '../../models/comments/index';\nimport { IntrinsicType } from '../../models/types/index';\nimport { Reflection, ReflectionFlag, ReflectionKind, TraverseProperty,\n TypeParameterReflection, DeclarationReflection, ProjectReflection,\n SignatureReflection, ParameterReflection } from '../../models/reflections/index';\nimport { Component, ConverterComponent } from '../components';\nimport { parseComment, getRawComment } from '../factories/comment';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * Structure used by [[ContainerCommentHandler]] to store discovered module comments.\n */\ninterface ModuleComment {\n /**\n * The module reflection this comment is targeting.\n */\n reflection: Reflection;\n\n /**\n * The full text of the best matched comment.\n */\n fullText: string;\n\n /**\n * Has the full text been marked as being preferred?\n */\n isPreferred: boolean;\n}\n\n/**\n * A handler that parses javadoc comments and attaches [[Models.Comment]] instances to\n * the generated reflections.\n */\n@Component({name: 'comment'})\nexport class CommentPlugin extends ConverterComponent {\n /**\n * List of discovered module comments.\n * Defined in this.onBegin\n */\n private comments!: {[id: number]: ModuleComment};\n\n /**\n * List of hidden reflections.\n */\n private hidden?: Reflection[];\n\n /**\n * Create a new CommentPlugin 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_CREATE_SIGNATURE]: this.onDeclaration,\n [Converter.EVENT_CREATE_TYPE_PARAMETER]: this.onCreateTypeParameter,\n [Converter.EVENT_FUNCTION_IMPLEMENTATION]: this.onFunctionImplementation,\n [Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,\n [Converter.EVENT_RESOLVE]: this.onResolve\n });\n }\n\n private storeModuleComment(comment: string, reflection: Reflection) {\n const isPreferred = (comment.toLowerCase().includes('@preferred'));\n\n if (this.comments[reflection.id]) {\n const info = this.comments[reflection.id];\n if (!isPreferred && (info.isPreferred || info.fullText.length > comment.length)) {\n return;\n }\n\n info.fullText = comment;\n info.isPreferred = isPreferred;\n } else {\n this.comments[reflection.id] = {\n reflection: reflection,\n fullText: comment,\n isPreferred: isPreferred\n };\n }\n }\n\n /**\n * Apply all comment tag modifiers to the given reflection.\n *\n * @param reflection The reflection the modifiers should be applied to.\n * @param comment The comment that should be searched for modifiers.\n */\n private applyModifiers(reflection: Reflection, comment: Comment) {\n if (comment.hasTag('private')) {\n reflection.setFlag(ReflectionFlag.Private);\n CommentPlugin.removeTags(comment, 'private');\n }\n\n if (comment.hasTag('protected')) {\n reflection.setFlag(ReflectionFlag.Protected);\n CommentPlugin.removeTags(comment, 'protected');\n }\n\n if (comment.hasTag('public')) {\n reflection.setFlag(ReflectionFlag.Public);\n CommentPlugin.removeTags(comment, 'public');\n }\n\n if (comment.hasTag('event')) {\n reflection.kind = ReflectionKind.Event;\n // reflection.setFlag(ReflectionFlag.Event);\n CommentPlugin.removeTags(comment, 'event');\n }\n\n if (comment.hasTag('hidden')\n || comment.hasTag('ignore')\n || (comment.hasTag('internal') && this.application.options.getCompilerOptions().stripInternal)\n ) {\n if (!this.hidden) {\n this.hidden = [];\n }\n this.hidden.push(reflection);\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.hidden = undefined;\n this.comments = {};\n }\n\n /**\n * Triggered when the converter has created a type parameter 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 onCreateTypeParameter(context: Context, reflection: TypeParameterReflection, node?: ts.Node) {\n const comment = reflection.parent && reflection.parent.comment;\n if (comment) {\n let tag = comment.getTag('typeparam', reflection.name);\n if (!tag) {\n tag = comment.getTag('param', `<${reflection.name}>`);\n }\n if (!tag) {\n tag = comment.getTag('param', reflection.name);\n }\n\n if (tag) {\n reflection.comment = new Comment(tag.text);\n // comment.tags must be set if we found a tag.\n comment.tags!.splice(comment.tags!.indexOf(tag), 1);\n }\n }\n }\n\n /**\n * Triggered when the converter has created a declaration or signature reflection.\n *\n * Invokes the comment parser.\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) {\n return;\n }\n const rawComment = getRawComment(node);\n if (!rawComment) {\n return;\n }\n\n if (reflection.kindOf(ReflectionKind.FunctionOrMethod) || (reflection.kindOf(ReflectionKind.Event) && reflection['signatures'])) {\n const comment = parseComment(rawComment, reflection.comment);\n this.applyModifiers(reflection, comment);\n } else if (reflection.kindOf(ReflectionKind.Module)) {\n this.storeModuleComment(rawComment, reflection);\n } else {\n const comment = parseComment(rawComment, reflection.comment);\n this.applyModifiers(reflection, comment);\n reflection.comment = comment;\n }\n }\n\n /**\n * Triggered when the converter has found a function implementation.\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 onFunctionImplementation(context: Context, reflection: Reflection, node?: ts.Node) {\n if (!node) {\n return;\n }\n\n const comment = getRawComment(node);\n if (comment) {\n reflection.comment = parseComment(comment, reflection.comment);\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 for (const id in this.comments) {\n if (!this.comments.hasOwnProperty(id)) {\n continue;\n }\n\n const info = this.comments[id];\n const comment = parseComment(info.fullText);\n CommentPlugin.removeTags(comment, 'preferred');\n\n this.applyModifiers(info.reflection, comment);\n info.reflection.comment = comment;\n }\n\n if (this.hidden) {\n const project = context.project;\n CommentPlugin.removeReflections(project, this.hidden);\n }\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * Cleans up comment tags related to signatures like @param or @return\n * and moves their data to the corresponding parameter reflections.\n *\n * This hook also copies over the comment of function implementations to their\n * signatures.\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: DeclarationReflection) {\n if (!(reflection instanceof DeclarationReflection)) {\n return;\n }\n\n const signatures = reflection.getAllSignatures();\n if (signatures.length) {\n const comment = reflection.comment;\n if (comment && comment.hasTag('returns')) {\n comment.returns = comment.getTag('returns')!.text;\n CommentPlugin.removeTags(comment, 'returns');\n }\n\n signatures.forEach((signature) => {\n let childComment = signature.comment;\n if (childComment && childComment.hasTag('returns')) {\n childComment.returns = childComment.getTag('returns')!.text;\n CommentPlugin.removeTags(childComment, 'returns');\n }\n\n if (comment) {\n if (!childComment) {\n childComment = signature.comment = new Comment();\n }\n\n childComment.shortText = childComment.shortText || comment.shortText;\n childComment.text = childComment.text || comment.text;\n childComment.returns = childComment.returns || comment.returns;\n }\n\n if (signature.parameters) {\n signature.parameters.forEach((parameter) => {\n let tag: CommentTag | undefined;\n if (childComment) {\n tag = childComment.getTag('param', parameter.name);\n }\n if (comment && !tag) {\n tag = comment.getTag('param', parameter.name);\n }\n if (tag) {\n parameter.comment = new Comment(tag.text);\n }\n });\n }\n\n CommentPlugin.removeTags(childComment, 'param');\n });\n\n CommentPlugin.removeTags(comment, 'param');\n }\n }\n\n /**\n * Remove all tags with the given name from the given comment instance.\n *\n * @param comment The comment that should be modified.\n * @param tagName The name of the that that should be removed.\n */\n static removeTags(comment: Comment | undefined, tagName: string) {\n if (!comment || !comment.tags) {\n return;\n }\n\n let i = 0, c = comment.tags.length;\n while (i < c) {\n if (comment.tags[i].tagName === tagName) {\n comment.tags.splice(i, 1);\n c--;\n } else {\n i++;\n }\n }\n }\n\n /**\n * Remove the specified reflections from the project.\n */\n static removeReflections(project: ProjectReflection, reflections: Reflection[]) {\n const deletedIds: number[] = [];\n reflections.forEach((reflection) => {\n CommentPlugin.removeReflection(project, reflection, deletedIds);\n });\n\n for (const key in project.symbolMapping) {\n if (project.symbolMapping.hasOwnProperty(key) && deletedIds.includes(project.symbolMapping[key])) {\n delete project.symbolMapping[key];\n }\n }\n }\n\n /**\n * Remove the given reflection from the project.\n */\n static removeReflection(project: ProjectReflection, reflection: Reflection, deletedIds?: number[]) {\n reflection.traverse((child) => CommentPlugin.removeReflection(project, child, deletedIds));\n\n const parent = <DeclarationReflection> reflection.parent;\n parent.traverse((child: Reflection, property: TraverseProperty) => {\n if (child === reflection) {\n switch (property) {\n case TraverseProperty.Children:\n if (parent.children) {\n const index = parent.children.indexOf(<DeclarationReflection> reflection);\n if (index !== -1) {\n parent.children.splice(index, 1);\n }\n }\n break;\n case TraverseProperty.GetSignature:\n delete parent.getSignature;\n break;\n case TraverseProperty.IndexSignature:\n delete parent.indexSignature;\n break;\n case TraverseProperty.Parameters:\n if ((<SignatureReflection> reflection.parent).parameters) {\n const index = (<SignatureReflection> reflection.parent).parameters!.indexOf(<ParameterReflection> reflection);\n if (index !== -1) {\n (<SignatureReflection> reflection.parent).parameters!.splice(index, 1);\n }\n }\n break;\n case TraverseProperty.SetSignature:\n delete parent.setSignature;\n break;\n case TraverseProperty.Signatures:\n if (parent.signatures) {\n const index = parent.signatures.indexOf(<SignatureReflection> reflection);\n if (index !== -1) {\n parent.signatures.splice(index, 1);\n }\n }\n break;\n case TraverseProperty.TypeLiteral:\n parent.type = new IntrinsicType('Object');\n break;\n case TraverseProperty.TypeParameter:\n if (parent.typeParameters) {\n const index = parent.typeParameters.indexOf(<TypeParameterReflection> reflection);\n if (index !== -1) {\n parent.typeParameters.splice(index, 1);\n }\n }\n break;\n }\n }\n });\n\n const id = reflection.id;\n delete project.reflections[id];\n\n // if an array was provided, keep track of the reflections that have been deleted, otherwise clean symbol mappings\n if (deletedIds) {\n deletedIds.push(id);\n } else {\n for (const key in project.symbolMapping) {\n if (project.symbolMapping.hasOwnProperty(key) && project.symbolMapping[key] === id) {\n delete project.symbolMapping[key];\n }\n }\n }\n\n }\n}\n"]}
1
+ {"version":3,"file":"CommentPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/CommentPlugin.ts"],"names":[],"mappings":";;;;;;;;;AAEA,uDAAkE;AAClE,oDAAyD;AACzD,0DAEqF;AACrF,8CAA8D;AAC9D,kDAAmE;AACnE,4CAAyC;AA4BzC,IAAa,aAAa,qBAA1B,MAAa,aAAc,SAAQ,+BAAkB;IAejD,UAAU;QACN,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;YACtB,CAAC,qBAAS,CAAC,WAAW,CAAC,EAAoB,IAAI,CAAC,OAAO;YACvD,CAAC,qBAAS,CAAC,wBAAwB,CAAC,EAAO,IAAI,CAAC,aAAa;YAC7D,CAAC,qBAAS,CAAC,sBAAsB,CAAC,EAAS,IAAI,CAAC,aAAa;YAC7D,CAAC,qBAAS,CAAC,2BAA2B,CAAC,EAAI,IAAI,CAAC,qBAAqB;YACrE,CAAC,qBAAS,CAAC,6BAA6B,CAAC,EAAE,IAAI,CAAC,wBAAwB;YACxE,CAAC,qBAAS,CAAC,mBAAmB,CAAC,EAAY,IAAI,CAAC,cAAc;YAC9D,CAAC,qBAAS,CAAC,aAAa,CAAC,EAAkB,IAAI,CAAC,SAAS;SAC5D,CAAC,CAAC;IACP,CAAC;IAEO,kBAAkB,CAAC,OAAe,EAAE,UAAsB;QAC9D,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;QAEnE,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE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E,SAAS,EAAC,CAAC;GAChB,aAAa,CAsXzB;AAtXY,sCAAa","sourcesContent":["import * as ts from 'typescript';\n\nimport { Comment, CommentTag } from '../../models/comments/index';\nimport { IntrinsicType } from '../../models/types/index';\nimport { Reflection, ReflectionFlag, ReflectionKind, TraverseProperty,\n TypeParameterReflection, DeclarationReflection, ProjectReflection,\n SignatureReflection, ParameterReflection } from '../../models/reflections/index';\nimport { Component, ConverterComponent } from '../components';\nimport { parseComment, getRawComment } from '../factories/comment';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * Structure used by [[ContainerCommentHandler]] to store discovered module comments.\n */\ninterface ModuleComment {\n /**\n * The module reflection this comment is targeting.\n */\n reflection: Reflection;\n\n /**\n * The full text of the best matched comment.\n */\n fullText: string;\n\n /**\n * Has the full text been marked as being preferred?\n */\n isPreferred: boolean;\n}\n\n/**\n * A handler that parses javadoc comments and attaches [[Models.Comment]] instances to\n * the generated reflections.\n */\n@Component({name: 'comment'})\nexport class CommentPlugin extends ConverterComponent {\n /**\n * List of discovered module comments.\n * Defined in this.onBegin\n */\n private comments!: {[id: number]: ModuleComment};\n\n /**\n * List of hidden reflections.\n */\n private hidden?: Reflection[];\n\n /**\n * Create a new CommentPlugin 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_CREATE_SIGNATURE]: this.onDeclaration,\n [Converter.EVENT_CREATE_TYPE_PARAMETER]: this.onCreateTypeParameter,\n [Converter.EVENT_FUNCTION_IMPLEMENTATION]: this.onFunctionImplementation,\n [Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,\n [Converter.EVENT_RESOLVE]: this.onResolve\n });\n }\n\n private storeModuleComment(comment: string, reflection: Reflection) {\n const isPreferred = (comment.toLowerCase().includes('@preferred'));\n\n if (this.comments[reflection.id]) {\n const info = this.comments[reflection.id];\n if (!isPreferred && (info.isPreferred || info.fullText.length > comment.length)) {\n return;\n }\n\n info.fullText = comment;\n info.isPreferred = isPreferred;\n } else {\n this.comments[reflection.id] = {\n reflection: reflection,\n fullText: comment,\n isPreferred: isPreferred\n };\n }\n }\n\n /**\n * Apply all comment tag modifiers to the given reflection.\n *\n * @param reflection The reflection the modifiers should be applied to.\n * @param comment The comment that should be searched for modifiers.\n */\n private applyModifiers(reflection: Reflection, comment: Comment) {\n if (comment.hasTag('private')) {\n reflection.setFlag(ReflectionFlag.Private);\n CommentPlugin.removeTags(comment, 'private');\n }\n\n if (comment.hasTag('protected')) {\n reflection.setFlag(ReflectionFlag.Protected);\n CommentPlugin.removeTags(comment, 'protected');\n }\n\n if (comment.hasTag('public')) {\n reflection.setFlag(ReflectionFlag.Public);\n CommentPlugin.removeTags(comment, 'public');\n }\n\n if (comment.hasTag('event')) {\n reflection.kind = ReflectionKind.Event;\n // reflection.setFlag(ReflectionFlag.Event);\n CommentPlugin.removeTags(comment, 'event');\n }\n\n if (comment.hasTag('hidden')\n || comment.hasTag('ignore')\n || (comment.hasTag('internal') && this.application.options.getCompilerOptions().stripInternal)\n ) {\n if (!this.hidden) {\n this.hidden = [];\n }\n this.hidden.push(reflection);\n }\n\n if (reflection.kindOf(ReflectionKind.ExternalModule)) {\n CommentPlugin.removeTags(comment, 'packagedocumentation');\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.hidden = undefined;\n this.comments = {};\n }\n\n /**\n * Triggered when the converter has created a type parameter 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 onCreateTypeParameter(context: Context, reflection: TypeParameterReflection, node?: ts.Node) {\n const comment = reflection.parent && reflection.parent.comment;\n if (comment) {\n let tag = comment.getTag('typeparam', reflection.name);\n if (!tag) {\n tag = comment.getTag('param', `<${reflection.name}>`);\n }\n if (!tag) {\n tag = comment.getTag('param', reflection.name);\n }\n\n if (tag) {\n reflection.comment = new Comment(tag.text);\n // comment.tags must be set if we found a tag.\n comment.tags!.splice(comment.tags!.indexOf(tag), 1);\n }\n }\n }\n\n /**\n * Triggered when the converter has created a declaration or signature reflection.\n *\n * Invokes the comment parser.\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) {\n return;\n }\n const rawComment = getRawComment(node);\n if (!rawComment) {\n return;\n }\n\n if (reflection.kindOf(ReflectionKind.FunctionOrMethod) || (reflection.kindOf(ReflectionKind.Event) && reflection['signatures'])) {\n const comment = parseComment(rawComment, reflection.comment);\n this.applyModifiers(reflection, comment);\n } else if (reflection.kindOf(ReflectionKind.Module)) {\n this.storeModuleComment(rawComment, reflection);\n } else {\n const comment = parseComment(rawComment, reflection.comment);\n this.applyModifiers(reflection, comment);\n reflection.comment = comment;\n }\n }\n\n /**\n * Triggered when the converter has found a function implementation.\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 onFunctionImplementation(context: Context, reflection: Reflection, node?: ts.Node) {\n if (!node) {\n return;\n }\n\n const comment = getRawComment(node);\n if (comment) {\n reflection.comment = parseComment(comment, reflection.comment);\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 for (const id in this.comments) {\n if (!this.comments.hasOwnProperty(id)) {\n continue;\n }\n\n const info = this.comments[id];\n const comment = parseComment(info.fullText);\n CommentPlugin.removeTags(comment, 'preferred');\n\n this.applyModifiers(info.reflection, comment);\n info.reflection.comment = comment;\n }\n\n if (this.hidden) {\n const project = context.project;\n CommentPlugin.removeReflections(project, this.hidden);\n }\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * Cleans up comment tags related to signatures like @param or @return\n * and moves their data to the corresponding parameter reflections.\n *\n * This hook also copies over the comment of function implementations to their\n * signatures.\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: DeclarationReflection) {\n if (!(reflection instanceof DeclarationReflection)) {\n return;\n }\n\n const signatures = reflection.getAllSignatures();\n if (signatures.length) {\n const comment = reflection.comment;\n if (comment && comment.hasTag('returns')) {\n comment.returns = comment.getTag('returns')!.text;\n CommentPlugin.removeTags(comment, 'returns');\n }\n\n signatures.forEach((signature) => {\n let childComment = signature.comment;\n if (childComment && childComment.hasTag('returns')) {\n childComment.returns = childComment.getTag('returns')!.text;\n CommentPlugin.removeTags(childComment, 'returns');\n }\n\n if (comment) {\n if (!childComment) {\n childComment = signature.comment = new Comment();\n }\n\n childComment.shortText = childComment.shortText || comment.shortText;\n childComment.text = childComment.text || comment.text;\n childComment.returns = childComment.returns || comment.returns;\n }\n\n if (signature.parameters) {\n signature.parameters.forEach((parameter) => {\n let tag: CommentTag | undefined;\n if (childComment) {\n tag = childComment.getTag('param', parameter.name);\n }\n if (comment && !tag) {\n tag = comment.getTag('param', parameter.name);\n }\n if (tag) {\n parameter.comment = new Comment(tag.text);\n }\n });\n }\n\n CommentPlugin.removeTags(childComment, 'param');\n });\n\n CommentPlugin.removeTags(comment, 'param');\n }\n }\n\n /**\n * Remove all tags with the given name from the given comment instance.\n *\n * @param comment The comment that should be modified.\n * @param tagName The name of the that that should be removed.\n */\n static removeTags(comment: Comment | undefined, tagName: string) {\n if (!comment || !comment.tags) {\n return;\n }\n\n let i = 0, c = comment.tags.length;\n while (i < c) {\n if (comment.tags[i].tagName === tagName) {\n comment.tags.splice(i, 1);\n c--;\n } else {\n i++;\n }\n }\n }\n\n /**\n * Remove the specified reflections from the project.\n */\n static removeReflections(project: ProjectReflection, reflections: Reflection[]) {\n const deletedIds: number[] = [];\n reflections.forEach((reflection) => {\n CommentPlugin.removeReflection(project, reflection, deletedIds);\n });\n\n for (const key in project.symbolMapping) {\n if (project.symbolMapping.hasOwnProperty(key) && deletedIds.includes(project.symbolMapping[key])) {\n delete project.symbolMapping[key];\n }\n }\n }\n\n /**\n * Remove the given reflection from the project.\n */\n static removeReflection(project: ProjectReflection, reflection: Reflection, deletedIds?: number[]) {\n reflection.traverse((child) => CommentPlugin.removeReflection(project, child, deletedIds));\n\n const parent = <DeclarationReflection> reflection.parent;\n parent.traverse((child: Reflection, property: TraverseProperty) => {\n if (child === reflection) {\n switch (property) {\n case TraverseProperty.Children:\n if (parent.children) {\n const index = parent.children.indexOf(<DeclarationReflection> reflection);\n if (index !== -1) {\n parent.children.splice(index, 1);\n }\n }\n break;\n case TraverseProperty.GetSignature:\n delete parent.getSignature;\n break;\n case TraverseProperty.IndexSignature:\n delete parent.indexSignature;\n break;\n case TraverseProperty.Parameters:\n if ((<SignatureReflection> reflection.parent).parameters) {\n const index = (<SignatureReflection> reflection.parent).parameters!.indexOf(<ParameterReflection> reflection);\n if (index !== -1) {\n (<SignatureReflection> reflection.parent).parameters!.splice(index, 1);\n }\n }\n break;\n case TraverseProperty.SetSignature:\n delete parent.setSignature;\n break;\n case TraverseProperty.Signatures:\n if (parent.signatures) {\n const index = parent.signatures.indexOf(<SignatureReflection> reflection);\n if (index !== -1) {\n parent.signatures.splice(index, 1);\n }\n }\n break;\n case TraverseProperty.TypeLiteral:\n parent.type = new IntrinsicType('Object');\n break;\n case TraverseProperty.TypeParameter:\n if (parent.typeParameters) {\n const index = parent.typeParameters.indexOf(<TypeParameterReflection> reflection);\n if (index !== -1) {\n parent.typeParameters.splice(index, 1);\n }\n }\n break;\n }\n }\n });\n\n const id = reflection.id;\n delete project.reflections[id];\n\n // if an array was provided, keep track of the reflections that have been deleted, otherwise clean symbol mappings\n if (deletedIds) {\n deletedIds.push(id);\n } else {\n for (const key in project.symbolMapping) {\n if (project.symbolMapping.hasOwnProperty(key) && project.symbolMapping[key] === id) {\n delete project.symbolMapping[key];\n }\n }\n }\n\n }\n}\n"]}
@@ -63,7 +63,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
63
63
  if (this.packageFile) {
64
64
  project.packageInfo = JSON.parse(FS.readFileSync(this.packageFile, 'utf-8'));
65
65
  if (!project.name) {
66
- project.name = project.packageInfo.name;
66
+ project.name = `${project.packageInfo.name} - v${project.packageInfo.version}`;
67
67
  }
68
68
  }
69
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PackagePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/PackagePlugin.ts"],"names":[],"mappings":";;;;;;;;AAAA,6BAA6B;AAC7B,yBAAyB;AAIzB,8CAA8D;AAC9D,4CAAyC;AAEzC,qDAA+C;AAW/C,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,+BAAkB;IA8BjD,UAAU;QACN,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;YACtB,CAAC,qBAAS,CAAC,WAAW,CAAC,EAAU,IAAI,CAAC,OAAO;YAC7C,CAAC,qBAAS,CAAC,gBAAgB,CAAC,EAAK,IAAI,CAAC,eAAe;YACrD,CAAC,qBAAS,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,cAAc;SACvD,CAAC,CAAC;IACP,CAAC;IAOO,OAAO,CAAC,OAAgB;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAElB,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,MAAM,EAAE;YAC9B,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC9B,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;gBACvB,IAAI,CAAC,UAAU,GAAG,MAA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AI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;iBAC/C;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3B,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;SACpD;IACL,CAAC;IAOO,cAAc,CAAC,OAAgB;QACnC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;SAC9D;QAED,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;YAC7E,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;gBACf,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;aAC3C;SACJ;IACL,CAAC;CACJ,CAAA;AA1GG;IAJC,kBAAM,CAAC;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,4JAA4J;KACrK,CAAC;6CACc;AALP,aAAa;IADzB,sBAAS,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;GAChB,aAAa,CA+GzB;AA/GY,sCAAa","sourcesContent":["import * as Path from 'path';\nimport * as FS from 'fs';\nimport * as ts from 'typescript';\n\nimport { Reflection } from '../../models/reflections/abstract';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { Option } from '../../utils/component';\n\n/**\n * A handler that tries to find the package.json and readme.md files of the\n * current project.\n *\n * The handler traverses the file tree upwards for each file processed by the processor\n * and records the nearest package info files it can find. Within the resolve files, the\n * contents of the found files will be read and appended to the ProjectReflection.\n */\n@Component({name: 'package'})\nexport class PackagePlugin extends ConverterComponent {\n @Option({\n name: 'readme',\n help: 'Path to the readme file that should be displayed on the index page. Pass `none` to disable the index page and start the documentation on the globals page.'\n })\n readme!: string;\n\n /**\n * The file name of the found readme.md file.\n */\n private readmeFile?: string;\n\n /**\n * The file name of the found package.json file.\n */\n private packageFile?: string;\n\n /**\n * List of directories the handler already inspected.\n */\n private visited!: string[];\n\n /**\n * Should the readme file be ignored?\n */\n private noReadmeFile?: boolean;\n\n /**\n * Create a new PackageHandler 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_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.readmeFile = undefined;\n this.packageFile = undefined;\n this.visited = [];\n\n let readme = this.readme;\n this.noReadmeFile = (readme === 'none');\n if (!this.noReadmeFile && readme) {\n readme = Path.resolve(readme);\n if (FS.existsSync(readme)) {\n this.readmeFile = readme;\n }\n }\n }\n\n /**\n * Triggered when the converter begins converting a source file.\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 const packageAndReadmeFound = () => (this.noReadmeFile || this.readmeFile) && this.packageFile;\n const reachedTopDirectory = dirName => dirName === Path.resolve(Path.join(dirName, '..'));\n const visitedDirBefore = dirName => this.visited.includes(dirName);\n\n if (!node) {\n return;\n }\n\n const fileName = node.fileName;\n let dirName = Path.resolve(Path.dirname(fileName));\n while (!packageAndReadmeFound() && !reachedTopDirectory(dirName) && !visitedDirBefore(dirName)) {\n FS.readdirSync(dirName).forEach((file) => {\n const lowercaseFileName = file.toLowerCase();\n if (!this.noReadmeFile && !this.readmeFile && lowercaseFileName === 'readme.md') {\n this.readmeFile = Path.join(dirName, file);\n }\n\n if (!this.packageFile && lowercaseFileName === 'package.json') {\n this.packageFile = Path.join(dirName, file);\n }\n });\n\n this.visited.push(dirName);\n dirName = Path.resolve(Path.join(dirName, '..'));\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 const project = context.project;\n if (this.readmeFile) {\n project.readme = FS.readFileSync(this.readmeFile, 'utf-8');\n }\n\n if (this.packageFile) {\n project.packageInfo = JSON.parse(FS.readFileSync(this.packageFile, 'utf-8'));\n if (!project.name) {\n project.name = project.packageInfo.name;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PackagePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/PackagePlugin.ts"],"names":[],"mappings":";;;;;;;;AAAA,6BAA6B;AAC7B,yBAAyB;AAIzB,8CAA8D;AAC9D,4CAAyC;AAEzC,qDAA+C;AAW/C,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,+BAAkB;IA8BjD,UAAU;QACN,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;YACtB,CAAC,qBAAS,CAAC,WAAW,CAAC,EAAU,IAAI,CAAC,OAAO;YAC7C,CAAC,qBAAS,CAAC,gBAAgB,CAAC,EAAK,IAAI,CAAC,eAAe;YACrD,CAAC,qBAAS,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,cAAc;SACvD,CAAC,CAAC;IACP,CAAC;IAOO,OAAO,CAAC,OAAgB;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAElB,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,CAAC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GzB;AA/GY,sCAAa","sourcesContent":["import * as Path from 'path';\nimport * as FS from 'fs';\nimport * as ts from 'typescript';\n\nimport { Reflection } from '../../models/reflections/abstract';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { Option } from '../../utils/component';\n\n/**\n * A handler that tries to find the package.json and readme.md files of the\n * current project.\n *\n * The handler traverses the file tree upwards for each file processed by the processor\n * and records the nearest package info files it can find. Within the resolve files, the\n * contents of the found files will be read and appended to the ProjectReflection.\n */\n@Component({name: 'package'})\nexport class PackagePlugin extends ConverterComponent {\n @Option({\n name: 'readme',\n help: 'Path to the readme file that should be displayed on the index page. Pass `none` to disable the index page and start the documentation on the globals page.'\n })\n readme!: string;\n\n /**\n * The file name of the found readme.md file.\n */\n private readmeFile?: string;\n\n /**\n * The file name of the found package.json file.\n */\n private packageFile?: string;\n\n /**\n * List of directories the handler already inspected.\n */\n private visited!: string[];\n\n /**\n * Should the readme file be ignored?\n */\n private noReadmeFile?: boolean;\n\n /**\n * Create a new PackageHandler 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_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.readmeFile = undefined;\n this.packageFile = undefined;\n this.visited = [];\n\n let readme = this.readme;\n this.noReadmeFile = (readme === 'none');\n if (!this.noReadmeFile && readme) {\n readme = Path.resolve(readme);\n if (FS.existsSync(readme)) {\n this.readmeFile = readme;\n }\n }\n }\n\n /**\n * Triggered when the converter begins converting a source file.\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 const packageAndReadmeFound = () => (this.noReadmeFile || this.readmeFile) && this.packageFile;\n const reachedTopDirectory = dirName => dirName === Path.resolve(Path.join(dirName, '..'));\n const visitedDirBefore = dirName => this.visited.includes(dirName);\n\n if (!node) {\n return;\n }\n\n const fileName = node.fileName;\n let dirName = Path.resolve(Path.dirname(fileName));\n while (!packageAndReadmeFound() && !reachedTopDirectory(dirName) && !visitedDirBefore(dirName)) {\n FS.readdirSync(dirName).forEach((file) => {\n const lowercaseFileName = file.toLowerCase();\n if (!this.noReadmeFile && !this.readmeFile && lowercaseFileName === 'readme.md') {\n this.readmeFile = Path.join(dirName, file);\n }\n\n if (!this.packageFile && lowercaseFileName === 'package.json') {\n this.packageFile = Path.join(dirName, file);\n }\n });\n\n this.visited.push(dirName);\n dirName = Path.resolve(Path.join(dirName, '..'));\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 const project = context.project;\n if (this.readmeFile) {\n project.readme = FS.readFileSync(this.readmeFile, 'utf-8');\n }\n\n if (this.packageFile) {\n project.packageInfo = JSON.parse(FS.readFileSync(this.packageFile, 'utf-8'));\n if (!project.name) {\n project.name = `${project.packageInfo.name} - v${project.packageInfo.version}`;\n }\n }\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import * as ts from 'typescript';
2
+ import { ConditionalType } from '../../models/types';
3
+ import { ConverterTypeComponent, TypeConverter } from '../components';
4
+ import { Context } from '../context';
5
+ export declare class ConditionalConverter extends ConverterTypeComponent implements TypeConverter<ts.ConditionalType, ts.ConditionalTypeNode> {
6
+ supportsNode(context: Context, node: ts.ConditionalTypeNode): boolean;
7
+ supportsType(context: Context, type: ts.ConditionalType): boolean;
8
+ convertNode(context: Context, node: ts.ConditionalTypeNode): ConditionalType | undefined;
9
+ convertType(context: Context, type: ts.ConditionalType): ConditionalType | undefined;
10
+ }
@@ -0,0 +1,38 @@
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 types_1 = require("../../models/types");
11
+ const components_1 = require("../components");
12
+ let ConditionalConverter = class ConditionalConverter extends components_1.ConverterTypeComponent {
13
+ supportsNode(context, node) {
14
+ return node.kind === ts.SyntaxKind.ConditionalType;
15
+ }
16
+ supportsType(context, type) {
17
+ return !!(type.flags & ts.TypeFlags.Conditional);
18
+ }
19
+ convertNode(context, node) {
20
+ const types = this.owner.convertTypes(context, [node.checkType, node.extendsType, node.trueType, node.falseType]);
21
+ if (types.length !== 4) {
22
+ return undefined;
23
+ }
24
+ return new types_1.ConditionalType(...types);
25
+ }
26
+ convertType(context, type) {
27
+ const types = this.owner.convertTypes(context, [], [type.checkType, type.extendsType, type.resolvedTrueType, type.resolvedFalseType]);
28
+ if (types.length !== 4) {
29
+ return undefined;
30
+ }
31
+ return new types_1.ConditionalType(...types);
32
+ }
33
+ };
34
+ ConditionalConverter = __decorate([
35
+ components_1.Component({ name: 'type:conditional' })
36
+ ], ConditionalConverter);
37
+ exports.ConditionalConverter = ConditionalConverter;
38
+ //# sourceMappingURL=conditional.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/conditional.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAAiC;AAEjC,8CAA2D;AAC3D,8CAAiF;AAIjF,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,mCAAsB;IAI5D,YAAY,CAAC,OAAgB,EAAE,IAA4B;QACvD,OAAO,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;IACvD,CAAC;IAKD,YAAY,CAAC,OAAgB,EAAE,IAAwB;QACnD,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAWD,WAAW,CAAC,OAAgB,EAAE,IAA4B;QACtD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QAClH,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,OAAO,SAAS,CAAC;SACpB;QACD,OAAO,IAAI,uBAAe,CAAC,GAAG,KAAiC,CAAC,CAAC;IACrE,CAAC;IAWD,WAAW,CAAC,OAAgB,EAAE,IAAwB;QAClD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACtI,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,OAAO,SAAS,CAAC;SACpB;QACD,OAAO,IAAI,uBAAe,CAAC,GAAG,KAAiC,CAAC,CAAC;IACrE,CAAC;CACJ,CAAA;AAhDY,oBAAoB;IADhC,sBAAS,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC;GACzB,oBAAoB,CAgDhC;AAhDY,oDAAoB","sourcesContent":["import * as ts from 'typescript';\n\nimport { ConditionalType, Type } from '../../models/types';\nimport { Component, ConverterTypeComponent, TypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:conditional'})\nexport class ConditionalConverter extends ConverterTypeComponent implements TypeConverter<ts.ConditionalType, ts.ConditionalTypeNode> {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.ConditionalTypeNode): boolean {\n return node.kind === ts.SyntaxKind.ConditionalType;\n }\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.ConditionalType): boolean {\n return !!(type.flags & ts.TypeFlags.Conditional);\n }\n\n /**\n * Convert the given conditional type node to its type reflection.\n *\n * This is a node based converter, see [[convertType]] for the type equivalent.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The conditional or intersection type node that should be converted.\n * @returns The type reflection representing the given conditional type node.\n */\n convertNode(context: Context, node: ts.ConditionalTypeNode): ConditionalType | undefined {\n const types = this.owner.convertTypes(context, [node.checkType, node.extendsType, node.trueType, node.falseType]);\n if (types.length !== 4) {\n return undefined;\n }\n return new ConditionalType(...types as [Type, Type, Type, Type]);\n }\n\n /**\n * Convert the given conditional type to its type reflection.\n *\n * This is a type based converter, see [[convertNode]] for the node equivalent.\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The conditional type that should be converted.\n * @returns The type reflection representing the given conditional type.\n */\n convertType(context: Context, type: ts.ConditionalType): ConditionalType | undefined {\n const types = this.owner.convertTypes(context, [], [type.checkType, type.extendsType, type.resolvedTrueType, type.resolvedFalseType]);\n if (types.length !== 4) {\n return undefined;\n }\n return new ConditionalType(...types as [Type, Type, Type, Type]);\n }\n}\n"]}
@@ -2,7 +2,10 @@ export { AliasConverter } from './alias';
2
2
  export { ArrayConverter } from './array';
3
3
  export { BindingArrayConverter } from './binding-array';
4
4
  export { BindingObjectConverter } from './binding-object';
5
+ export { ConditionalConverter } from './conditional';
5
6
  export { EnumConverter } from './enum';
7
+ export { InferredConverter } from './inferred';
8
+ export { IndexedAccessConverter } from './indexed-access';
6
9
  export { IntrinsicConverter } from './intrinsic';
7
10
  export { PredicateConverter } from './predicate';
8
11
  export { StringLiteralConverter } from './string-literal';
@@ -8,8 +8,14 @@ var binding_array_1 = require("./binding-array");
8
8
  exports.BindingArrayConverter = binding_array_1.BindingArrayConverter;
9
9
  var binding_object_1 = require("./binding-object");
10
10
  exports.BindingObjectConverter = binding_object_1.BindingObjectConverter;
11
+ var conditional_1 = require("./conditional");
12
+ exports.ConditionalConverter = conditional_1.ConditionalConverter;
11
13
  var enum_1 = require("./enum");
12
14
  exports.EnumConverter = enum_1.EnumConverter;
15
+ var inferred_1 = require("./inferred");
16
+ exports.InferredConverter = inferred_1.InferredConverter;
17
+ var indexed_access_1 = require("./indexed-access");
18
+ exports.IndexedAccessConverter = indexed_access_1.IndexedAccessConverter;
13
19
  var intrinsic_1 = require("./intrinsic");
14
20
  exports.IntrinsicConverter = intrinsic_1.IntrinsicConverter;
15
21
  var predicate_1 = require("./predicate");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/index.ts"],"names":[],"mappings":";;AAAA,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,iDAAwD;AAA/C,gDAAA,qBAAqB,CAAA;AAC9B,mDAA0D;AAAjD,kDAAA,sBAAsB,CAAA;AAC/B,+BAAuC;AAA9B,+BAAA,aAAa,CAAA;AACtB,yCAAiD;AAAxC,yCAAA,kBAAkB,CAAA;AAC3B,yCAAiD;AAAxC,yCAAA,kBAAkB,CAAA;AAC3B,mDAA0D;AAAjD,kDAAA,sBAAsB,CAAA;AAC/B,yCAAiD;AAAxC,yCAAA,kBAAkB,CAAA;AAC3B,+BAAuC;AAA9B,+BAAA,aAAa,CAAA;AACtB,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,mDAA0D;AAAjD,kDAAA,sBAAsB,CAAA;AAC/B,iDAAwD;AAA/C,gDAAA,qBAAqB,CAAA;AAC9B,iEAAuE;AAA9D,+DAAA,4BAA4B,CAAA;AACrC,qCAA6C;AAApC,qCAAA,gBAAgB,CAAA","sourcesContent":["export { AliasConverter } from './alias';\nexport { ArrayConverter } from './array';\nexport { BindingArrayConverter } from './binding-array';\nexport { BindingObjectConverter } from './binding-object';\nexport { EnumConverter } from './enum';\nexport { IntrinsicConverter } from './intrinsic';\nexport { PredicateConverter } from './predicate';\nexport { StringLiteralConverter } from './string-literal';\nexport { ReferenceConverter } from './reference';\nexport { ThisConverter } from './this';\nexport { TupleConverter } from './tuple';\nexport { TypeParameterConverter } from './type-parameter';\nexport { TypeOperatorConverter } from './type-operator';\nexport { UnionOrIntersectionConverter } from './union-or-intersection';\nexport { UnknownConverter } from './unknown';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/index.ts"],"names":[],"mappings":";;AAAA,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,iDAAwD;AAA/C,gDAAA,qBAAqB,CAAA;AAC9B,mDAA0D;AAAjD,kDAAA,sBAAsB,CAAA;AAC/B,6CAAqD;AAA5C,6CAAA,oBAAoB,CAAA;AAC7B,+BAAuC;AAA9B,+BAAA,aAAa,CAAA;AACtB,uCAA+C;AAAtC,uCAAA,iBAAiB,CAAA;AAC1B,mDAA0D;AAAjD,kDAAA,sBAAsB,CAAA;AAC/B,yCAAiD;AAAxC,yCAAA,kBAAkB,CAAA;AAC3B,yCAAiD;AAAxC,yCAAA,kBAAkB,CAAA;AAC3B,mDAA0D;AAAjD,kDAAA,sBAAsB,CAAA;AAC/B,yCAAiD;AAAxC,yCAAA,kBAAkB,CAAA;AAC3B,+BAAuC;AAA9B,+BAAA,aAAa,CAAA;AACtB,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,mDAA0D;AAAjD,kDAAA,sBAAsB,CAAA;AAC/B,iDAAwD;AAA/C,gDAAA,qBAAqB,CAAA;AAC9B,iEAAuE;AAA9D,+DAAA,4BAA4B,CAAA;AACrC,qCAA6C;AAApC,qCAAA,gBAAgB,CAAA","sourcesContent":["export { AliasConverter } from './alias';\nexport { ArrayConverter } from './array';\nexport { BindingArrayConverter } from './binding-array';\nexport { BindingObjectConverter } from './binding-object';\nexport { ConditionalConverter } from './conditional';\nexport { EnumConverter } from './enum';\nexport { InferredConverter } from './inferred';\nexport { IndexedAccessConverter } from './indexed-access';\nexport { IntrinsicConverter } from './intrinsic';\nexport { PredicateConverter } from './predicate';\nexport { StringLiteralConverter } from './string-literal';\nexport { ReferenceConverter } from './reference';\nexport { ThisConverter } from './this';\nexport { TupleConverter } from './tuple';\nexport { TypeParameterConverter } from './type-parameter';\nexport { TypeOperatorConverter } from './type-operator';\nexport { UnionOrIntersectionConverter } from './union-or-intersection';\nexport { UnknownConverter } from './unknown';\n"]}
@@ -0,0 +1,8 @@
1
+ import * as ts from 'typescript';
2
+ import { Type } from '../../models/index';
3
+ import { ConverterTypeComponent, TypeNodeConverter } from '../components';
4
+ import { Context } from '../context';
5
+ export declare class IndexedAccessConverter extends ConverterTypeComponent implements TypeNodeConverter<ts.Type, ts.IndexedAccessTypeNode> {
6
+ supportsNode(context: Context, node: ts.TypeNode): boolean;
7
+ convertNode(context: Context, node: ts.IndexedAccessTypeNode): Type | undefined;
8
+ }
@@ -0,0 +1,32 @@
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 index_1 = require("../../models/index");
11
+ const components_1 = require("../components");
12
+ let IndexedAccessConverter = class IndexedAccessConverter extends components_1.ConverterTypeComponent {
13
+ supportsNode(context, node) {
14
+ return ts.isIndexedAccessTypeNode(node);
15
+ }
16
+ convertNode(context, node) {
17
+ const objectType = this.owner.convertType(context, node.objectType);
18
+ if (!objectType) {
19
+ return;
20
+ }
21
+ const indexType = this.owner.convertType(context, node.indexType);
22
+ if (!indexType) {
23
+ return;
24
+ }
25
+ return new index_1.IndexedAccessType(objectType, indexType);
26
+ }
27
+ };
28
+ IndexedAccessConverter = __decorate([
29
+ components_1.Component({ name: 'type:indexed-access' })
30
+ ], IndexedAccessConverter);
31
+ exports.IndexedAccessConverter = IndexedAccessConverter;
32
+ //# sourceMappingURL=indexed-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexed-access.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/indexed-access.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAAiC;AAEjC,8CAA6D;AAC7D,8CAIuB;AAIvB,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,mCAAsB;IAK9D,YAAY,CAAC,OAAgB,EAAE,IAAiB;QAC5C,OAAO,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,WAAW,CAAC,OAAgB,EAAE,IAA8B;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACpE,IAAI,CAAC,UAAU,EAAE;YAAE,OAAO;SAAE;QAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAClE,IAAI,CAAC,SAAS,EAAE;YAAE,OAAO;SAAE;QAC3B,OAAO,IAAI,yBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AAhBY,sBAAsB;IADlC,sBAAS,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;GAC9B,sBAAsB,CAgBlC;AAhBY,wDAAsB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, IndexedAccessType } from '../../models/index';\nimport {\n Component,\n ConverterTypeComponent,\n TypeNodeConverter\n} from '../components';\nimport { Context } from '../context';\n\n@Component({ name: 'type:indexed-access' })\nexport class IndexedAccessConverter extends ConverterTypeComponent\n implements TypeNodeConverter<ts.Type, ts.IndexedAccessTypeNode> {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.TypeNode) {\n return ts.isIndexedAccessTypeNode(node);\n }\n\n convertNode(context: Context, node: ts.IndexedAccessTypeNode): Type | undefined {\n const objectType = this.owner.convertType(context, node.objectType);\n if (!objectType) { return; }\n const indexType = this.owner.convertType(context, node.indexType);\n if (!indexType) { return; }\n return new IndexedAccessType(objectType, indexType);\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import * as ts from 'typescript';
2
+ import { InferredType } from '../../models/types';
3
+ import { ConverterTypeComponent, TypeNodeConverter } from '../components';
4
+ import { Context } from '../context';
5
+ export declare class InferredConverter extends ConverterTypeComponent implements TypeNodeConverter<ts.Type, ts.InferTypeNode> {
6
+ supportsNode(_context: Context, node: ts.TypeNode): boolean;
7
+ convertNode(context: Context, node: ts.InferTypeNode): InferredType | undefined;
8
+ }
@@ -0,0 +1,24 @@
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 types_1 = require("../../models/types");
11
+ const components_1 = require("../components");
12
+ let InferredConverter = class InferredConverter extends components_1.ConverterTypeComponent {
13
+ supportsNode(_context, node) {
14
+ return ts.isInferTypeNode(node);
15
+ }
16
+ convertNode(context, node) {
17
+ return new types_1.InferredType(node.typeParameter.getText());
18
+ }
19
+ };
20
+ InferredConverter = __decorate([
21
+ components_1.Component({ name: 'type:inferred' })
22
+ ], InferredConverter);
23
+ exports.InferredConverter = InferredConverter;
24
+ //# sourceMappingURL=inferred.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inferred.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/inferred.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAAiC;AAEjC,8CAAkD;AAClD,8CAAqF;AAIrF,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,mCAAsB;IAIzD,YAAY,CAAC,QAAiB,EAAE,IAAiB;QAC7C,OAAO,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAWD,WAAW,CAAC,OAAgB,EAAE,IAAsB;QAChD,OAAO,IAAI,oBAAY,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1D,CAAC;CACJ,CAAA;AApBY,iBAAiB;IAD7B,sBAAS,CAAC,EAAC,IAAI,EAAE,eAAe,EAAC,CAAC;GACtB,iBAAiB,CAoB7B;AApBY,8CAAiB","sourcesContent":["import * as ts from 'typescript';\n\nimport { InferredType } from '../../models/types';\nimport { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:inferred'})\nexport class InferredConverter extends ConverterTypeComponent implements TypeNodeConverter<ts.Type, ts.InferTypeNode> {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(_context: Context, node: ts.TypeNode): boolean {\n return ts.isInferTypeNode(node);\n }\n\n /**\n * Convert the given conditional type node to its type reflection.\n *\n * This is a node based converter, see [[convertType]] for the type equivalent.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The conditional or intersection type node that should be converted.\n * @returns The type reflection representing the given conditional type node.\n */\n convertNode(context: Context, node: ts.InferTypeNode): InferredType | undefined {\n return new InferredType(node.typeParameter.getText());\n }\n}\n"]}