From 8588bc463e5ac60167925a59cf6e17f9198ff9c9 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sat, 3 Mar 2018 12:36:25 +0100 Subject: [PATCH 1/2] Fix bug disallowing user to defer to input files declared in tsconfig.json --- src/lib/utils/options/readers/arguments.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/utils/options/readers/arguments.ts b/src/lib/utils/options/readers/arguments.ts index d6c4c7c64..ff21a3e08 100644 --- a/src/lib/utils/options/readers/arguments.ts +++ b/src/lib/utils/options/readers/arguments.ts @@ -1,3 +1,4 @@ +import * as _ from 'lodash'; import * as ts from 'typescript'; import * as _ts from '../../../ts-internal'; @@ -58,7 +59,7 @@ export class ArgumentsReader extends OptionsComponent { files.push(arg); } } - if (files) { + if (!_.isEmpty(files)) { event.inputFiles = files; } } From a9970a52f0924fec2df608abe30ff81153b3def2 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sat, 3 Mar 2018 12:59:54 +0100 Subject: [PATCH 2/2] Remove dist from gitignore so we can use this repo as a dependency in our projects until the fix is included in TypeDoc --- .gitignore | 1 - dist/index.d.ts | 11 + dist/index.js | 27 + dist/index.js.map | 1 + dist/lib/application.d.ts | 32 + dist/lib/application.js | 192 ++ dist/lib/application.js.map | 1 + dist/lib/cli.d.ts | 17 + dist/lib/cli.js | 117 + dist/lib/cli.js.map | 1 + dist/lib/converter/components.d.ts | 26 + dist/lib/converter/components.js | 41 + dist/lib/converter/components.js.map | 1 + dist/lib/converter/context.d.ts | 36 + dist/lib/converter/context.js | 182 ++ dist/lib/converter/context.js.map | 1 + dist/lib/converter/convert-expression.d.ts | 3 + dist/lib/converter/convert-expression.js | 30 + dist/lib/converter/convert-expression.js.map | 1 + dist/lib/converter/converter.d.ts | 48 + dist/lib/converter/converter.js | 255 +++ dist/lib/converter/converter.js.map | 1 + dist/lib/converter/factories/comment.d.ts | 5 + dist/lib/converter/factories/comment.js | 143 ++ dist/lib/converter/factories/comment.js.map | 1 + dist/lib/converter/factories/declaration.d.ts | 4 + dist/lib/converter/factories/declaration.js | 133 ++ .../converter/factories/declaration.js.map | 1 + dist/lib/converter/factories/index.d.ts | 6 + dist/lib/converter/factories/index.js | 15 + dist/lib/converter/factories/index.js.map | 1 + dist/lib/converter/factories/parameter.d.ts | 4 + dist/lib/converter/factories/parameter.js | 35 + dist/lib/converter/factories/parameter.js.map | 1 + dist/lib/converter/factories/reference.d.ts | 4 + dist/lib/converter/factories/reference.js | 14 + dist/lib/converter/factories/reference.js.map | 1 + dist/lib/converter/factories/signature.d.ts | 4 + dist/lib/converter/factories/signature.js | 44 + dist/lib/converter/factories/signature.js.map | 1 + .../converter/factories/type-parameter.d.ts | 4 + .../lib/converter/factories/type-parameter.js | 22 + .../converter/factories/type-parameter.js.map | 1 + dist/lib/converter/index.d.ts | 6 + dist/lib/converter/index.js | 13 + dist/lib/converter/index.js.map | 1 + dist/lib/converter/nodes/accessor.d.ts | 8 + dist/lib/converter/nodes/accessor.js | 51 + dist/lib/converter/nodes/accessor.js.map | 1 + dist/lib/converter/nodes/alias.d.ts | 8 + dist/lib/converter/nodes/alias.js | 46 + dist/lib/converter/nodes/alias.js.map | 1 + dist/lib/converter/nodes/block.d.ts | 15 + dist/lib/converter/nodes/block.js | 107 + dist/lib/converter/nodes/block.js.map | 1 + dist/lib/converter/nodes/class.d.ts | 8 + dist/lib/converter/nodes/class.js | 92 + dist/lib/converter/nodes/class.js.map | 1 + dist/lib/converter/nodes/constructor.d.ts | 9 + dist/lib/converter/nodes/constructor.js | 95 + dist/lib/converter/nodes/constructor.js.map | 1 + dist/lib/converter/nodes/enum.d.ts | 9 + dist/lib/converter/nodes/enum.js | 59 + dist/lib/converter/nodes/enum.js.map | 1 + dist/lib/converter/nodes/export.d.ts | 8 + dist/lib/converter/nodes/export.js | 71 + dist/lib/converter/nodes/export.js.map | 1 + dist/lib/converter/nodes/function.d.ts | 8 + dist/lib/converter/nodes/function.js | 66 + dist/lib/converter/nodes/function.js.map | 1 + dist/lib/converter/nodes/index.d.ts | 16 + dist/lib/converter/nodes/index.js | 35 + dist/lib/converter/nodes/index.js.map | 1 + dist/lib/converter/nodes/interface.d.ts | 8 + dist/lib/converter/nodes/interface.js | 74 + dist/lib/converter/nodes/interface.js.map | 1 + dist/lib/converter/nodes/literal-object.d.ts | 8 + dist/lib/converter/nodes/literal-object.js | 45 + .../lib/converter/nodes/literal-object.js.map | 1 + dist/lib/converter/nodes/literal-type.d.ts | 8 + dist/lib/converter/nodes/literal-type.js | 45 + dist/lib/converter/nodes/literal-type.js.map | 1 + dist/lib/converter/nodes/module.d.ts | 8 + dist/lib/converter/nodes/module.js | 53 + dist/lib/converter/nodes/module.js.map | 1 + dist/lib/converter/nodes/signature-call.d.ts | 8 + dist/lib/converter/nodes/signature-call.js | 53 + .../lib/converter/nodes/signature-call.js.map | 1 + dist/lib/converter/nodes/signature-index.d.ts | 8 + dist/lib/converter/nodes/signature-index.js | 45 + .../converter/nodes/signature-index.js.map | 1 + .../converter/nodes/variable-statement.d.ts | 9 + .../lib/converter/nodes/variable-statement.js | 60 + .../converter/nodes/variable-statement.js.map | 1 + dist/lib/converter/nodes/variable.d.ts | 9 + dist/lib/converter/nodes/variable.js | 125 + dist/lib/converter/nodes/variable.js.map | 1 + .../lib/converter/plugins/CategoryPlugin.d.ts | 13 + dist/lib/converter/plugins/CategoryPlugin.js | 132 ++ .../converter/plugins/CategoryPlugin.js.map | 1 + dist/lib/converter/plugins/CommentPlugin.d.ts | 18 + dist/lib/converter/plugins/CommentPlugin.js | 279 +++ .../converter/plugins/CommentPlugin.js.map | 1 + .../converter/plugins/DecoratorPlugin.d.ts | 9 + dist/lib/converter/plugins/DecoratorPlugin.js | 121 + .../converter/plugins/DecoratorPlugin.js.map | 1 + .../converter/plugins/DeepCommentPlugin.d.ts | 5 + .../converter/plugins/DeepCommentPlugin.js | 82 + .../plugins/DeepCommentPlugin.js.map | 1 + .../plugins/DynamicModulePlugin.d.ts | 9 + .../converter/plugins/DynamicModulePlugin.js | 68 + .../plugins/DynamicModulePlugin.js.map | 1 + dist/lib/converter/plugins/GitHubPlugin.d.ts | 9 + dist/lib/converter/plugins/GitHubPlugin.js | 165 ++ .../lib/converter/plugins/GitHubPlugin.js.map | 1 + dist/lib/converter/plugins/GroupPlugin.d.ts | 16 + dist/lib/converter/plugins/GroupPlugin.js | 191 ++ dist/lib/converter/plugins/GroupPlugin.js.map | 1 + .../converter/plugins/ImplementsPlugin.d.ts | 7 + .../lib/converter/plugins/ImplementsPlugin.js | 107 + .../converter/plugins/ImplementsPlugin.js.map | 1 + dist/lib/converter/plugins/PackagePlugin.d.ts | 12 + dist/lib/converter/plugins/PackagePlugin.js | 102 + .../converter/plugins/PackagePlugin.js.map | 1 + dist/lib/converter/plugins/SourcePlugin.d.ts | 13 + dist/lib/converter/plugins/SourcePlugin.js | 139 ++ .../lib/converter/plugins/SourcePlugin.js.map | 1 + dist/lib/converter/plugins/TypePlugin.d.ts | 9 + dist/lib/converter/plugins/TypePlugin.js | 168 ++ dist/lib/converter/plugins/TypePlugin.js.map | 1 + dist/lib/converter/plugins/index.d.ts | 11 + dist/lib/converter/plugins/index.js | 25 + dist/lib/converter/plugins/index.js.map | 1 + dist/lib/converter/types/alias.d.ts | 9 + dist/lib/converter/types/alias.js | 68 + dist/lib/converter/types/alias.js.map | 1 + dist/lib/converter/types/array.d.ts | 10 + dist/lib/converter/types/array.js | 52 + dist/lib/converter/types/array.js.map | 1 + dist/lib/converter/types/binding-array.d.ts | 8 + dist/lib/converter/types/binding-array.js | 44 + dist/lib/converter/types/binding-array.js.map | 1 + dist/lib/converter/types/binding-object.d.ts | 8 + dist/lib/converter/types/binding-object.js | 52 + .../lib/converter/types/binding-object.js.map | 1 + dist/lib/converter/types/enum.d.ts | 8 + dist/lib/converter/types/enum.js | 39 + dist/lib/converter/types/enum.js.map | 1 + dist/lib/converter/types/index.d.ts | 14 + dist/lib/converter/types/index.js | 31 + dist/lib/converter/types/index.js.map | 1 + dist/lib/converter/types/intrinsic.d.ts | 8 + dist/lib/converter/types/intrinsic.js | 44 + dist/lib/converter/types/intrinsic.js.map | 1 + dist/lib/converter/types/reference.d.ts | 12 + dist/lib/converter/types/reference.js | 99 + dist/lib/converter/types/reference.js.map | 1 + dist/lib/converter/types/string-literal.d.ts | 10 + dist/lib/converter/types/string-literal.js | 45 + .../lib/converter/types/string-literal.js.map | 1 + dist/lib/converter/types/this.d.ts | 8 + dist/lib/converter/types/this.js | 39 + dist/lib/converter/types/this.js.map | 1 + dist/lib/converter/types/tuple.d.ts | 10 + dist/lib/converter/types/tuple.js | 61 + dist/lib/converter/types/tuple.js.map | 1 + dist/lib/converter/types/type-operator.d.ts | 9 + dist/lib/converter/types/type-operator.js | 42 + dist/lib/converter/types/type-operator.js.map | 1 + dist/lib/converter/types/type-parameter.d.ts | 9 + dist/lib/converter/types/type-parameter.js | 50 + .../lib/converter/types/type-parameter.js.map | 1 + .../types/union-or-intersection.d.ts | 10 + .../converter/types/union-or-intersection.js | 61 + .../types/union-or-intersection.js.map | 1 + dist/lib/converter/types/unknown.d.ts | 9 + dist/lib/converter/types/unknown.js | 41 + dist/lib/converter/types/unknown.js.map | 1 + dist/lib/converter/utils/base-path.d.ts | 7 + dist/lib/converter/utils/base-path.js | 54 + dist/lib/converter/utils/base-path.js.map | 1 + dist/lib/converter/utils/compiler-host.d.ts | 16 + dist/lib/converter/utils/compiler-host.js | 67 + dist/lib/converter/utils/compiler-host.js.map | 1 + dist/lib/models/ReflectionCategory.d.ts | 9 + dist/lib/models/ReflectionCategory.js | 33 + dist/lib/models/ReflectionCategory.js.map | 1 + dist/lib/models/ReflectionGroup.d.ts | 16 + dist/lib/models/ReflectionGroup.js | 35 + dist/lib/models/ReflectionGroup.js.map | 1 + dist/lib/models/comments/comment.d.ts | 13 + dist/lib/models/comments/comment.js | 61 + dist/lib/models/comments/comment.js.map | 1 + dist/lib/models/comments/index.d.ts | 2 + dist/lib/models/comments/index.js | 7 + dist/lib/models/comments/index.js.map | 1 + dist/lib/models/comments/tag.d.ts | 7 + dist/lib/models/comments/tag.js | 22 + dist/lib/models/comments/tag.js.map | 1 + dist/lib/models/index.d.ts | 4 + dist/lib/models/index.js | 10 + dist/lib/models/index.js.map | 1 + dist/lib/models/reflections/abstract.d.ts | 131 ++ dist/lib/models/reflections/abstract.js | 310 +++ dist/lib/models/reflections/abstract.js.map | 1 + dist/lib/models/reflections/container.d.ts | 12 + dist/lib/models/reflections/container.js | 70 + dist/lib/models/reflections/container.js.map | 1 + dist/lib/models/reflections/declaration.d.ts | 32 + dist/lib/models/reflections/declaration.js | 109 + .../lib/models/reflections/declaration.js.map | 1 + dist/lib/models/reflections/index.d.ts | 7 + dist/lib/models/reflections/index.js | 20 + dist/lib/models/reflections/index.js.map | 1 + dist/lib/models/reflections/parameter.d.ts | 11 + dist/lib/models/reflections/parameter.js | 42 + dist/lib/models/reflections/parameter.js.map | 1 + dist/lib/models/reflections/project.d.ts | 24 + dist/lib/models/reflections/project.js | 76 + dist/lib/models/reflections/project.js.map | 1 + dist/lib/models/reflections/signature.d.ts | 18 + dist/lib/models/reflections/signature.js | 69 + dist/lib/models/reflections/signature.js.map | 1 + .../models/reflections/type-parameter.d.ts | 9 + dist/lib/models/reflections/type-parameter.js | 31 + .../models/reflections/type-parameter.js.map | 1 + dist/lib/models/sources/directory.d.ts | 19 + dist/lib/models/sources/directory.js | 40 + dist/lib/models/sources/directory.js.map | 1 + dist/lib/models/sources/file.d.ts | 22 + dist/lib/models/sources/file.js | 14 + dist/lib/models/sources/file.js.map | 1 + dist/lib/models/sources/index.d.ts | 2 + dist/lib/models/sources/index.js | 7 + dist/lib/models/sources/index.js.map | 1 + dist/lib/models/types/abstract.d.ts | 9 + dist/lib/models/types/abstract.js | 47 + dist/lib/models/types/abstract.js.map | 1 + dist/lib/models/types/array.d.ts | 10 + dist/lib/models/types/array.js | 48 + dist/lib/models/types/array.js.map | 1 + dist/lib/models/types/index.d.ts | 12 + dist/lib/models/types/index.js | 27 + dist/lib/models/types/index.js.map | 1 + dist/lib/models/types/intersection.d.ts | 10 + dist/lib/models/types/intersection.js | 48 + dist/lib/models/types/intersection.js.map | 1 + dist/lib/models/types/intrinsic.d.ts | 10 + dist/lib/models/types/intrinsic.js | 40 + dist/lib/models/types/intrinsic.js.map | 1 + dist/lib/models/types/reference.d.ts | 16 + dist/lib/models/types/reference.js | 59 + dist/lib/models/types/reference.js.map | 1 + dist/lib/models/types/reflection.d.ts | 11 + dist/lib/models/types/reflection.js | 46 + dist/lib/models/types/reflection.js.map | 1 + dist/lib/models/types/string-literal.d.ts | 10 + dist/lib/models/types/string-literal.js | 40 + dist/lib/models/types/string-literal.js.map | 1 + dist/lib/models/types/tuple.d.ts | 10 + dist/lib/models/types/tuple.js | 48 + dist/lib/models/types/tuple.js.map | 1 + dist/lib/models/types/type-operator.d.ts | 11 + dist/lib/models/types/type-operator.js | 44 + dist/lib/models/types/type-operator.js.map | 1 + dist/lib/models/types/type-parameter.d.ts | 10 + dist/lib/models/types/type-parameter.js | 55 + dist/lib/models/types/type-parameter.js.map | 1 + dist/lib/models/types/union.d.ts | 10 + dist/lib/models/types/union.js | 48 + dist/lib/models/types/union.js.map | 1 + dist/lib/models/types/unknown.d.ts | 10 + dist/lib/models/types/unknown.js | 40 + dist/lib/models/types/unknown.js.map | 1 + dist/lib/output/components.d.ts | 17 + dist/lib/output/components.js | 59 + dist/lib/output/components.js.map | 1 + dist/lib/output/events.d.ts | 33 + dist/lib/output/events.js | 54 + dist/lib/output/events.js.map | 1 + dist/lib/output/helpers/compact.d.ts | 1 + dist/lib/output/helpers/compact.js | 11 + dist/lib/output/helpers/compact.js.map | 1 + dist/lib/output/helpers/if-cond.d.ts | 1 + dist/lib/output/helpers/if-cond.js | 26 + dist/lib/output/helpers/if-cond.js.map | 1 + dist/lib/output/helpers/if-signature.d.ts | 1 + dist/lib/output/helpers/if-signature.js | 13 + dist/lib/output/helpers/if-signature.js.map | 1 + dist/lib/output/helpers/wbr.d.ts | 1 + dist/lib/output/helpers/wbr.js | 10 + dist/lib/output/helpers/wbr.js.map | 1 + dist/lib/output/models/NavigationItem.d.ts | 17 + dist/lib/output/models/NavigationItem.js | 37 + dist/lib/output/models/NavigationItem.js.map | 1 + dist/lib/output/models/UrlMapping.d.ts | 6 + dist/lib/output/models/UrlMapping.js | 12 + dist/lib/output/models/UrlMapping.js.map | 1 + dist/lib/output/plugins/AssetsPlugin.d.ts | 6 + dist/lib/output/plugins/AssetsPlugin.js | 57 + dist/lib/output/plugins/AssetsPlugin.js.map | 1 + .../output/plugins/JavascriptIndexPlugin.d.ts | 5 + .../output/plugins/JavascriptIndexPlugin.js | 76 + .../plugins/JavascriptIndexPlugin.js.map | 1 + dist/lib/output/plugins/LayoutPlugin.d.ts | 5 + dist/lib/output/plugins/LayoutPlugin.js | 39 + dist/lib/output/plugins/LayoutPlugin.js.map | 1 + .../lib/output/plugins/MarkedLinksPlugin.d.ts | 18 + dist/lib/output/plugins/MarkedLinksPlugin.js | 144 ++ .../output/plugins/MarkedLinksPlugin.js.map | 1 + dist/lib/output/plugins/MarkedPlugin.d.ts | 15 + dist/lib/output/plugins/MarkedPlugin.js | 144 ++ dist/lib/output/plugins/MarkedPlugin.js.map | 1 + dist/lib/output/plugins/NavigationPlugin.d.ts | 8 + dist/lib/output/plugins/NavigationPlugin.js | 77 + .../output/plugins/NavigationPlugin.js.map | 1 + .../lib/output/plugins/PrettyPrintPlugin.d.ts | 8 + dist/lib/output/plugins/PrettyPrintPlugin.js | 149 ++ .../output/plugins/PrettyPrintPlugin.js.map | 1 + dist/lib/output/plugins/TocPlugin.d.ts | 8 + dist/lib/output/plugins/TocPlugin.js | 83 + dist/lib/output/plugins/TocPlugin.js.map | 1 + dist/lib/output/plugins/index.d.ts | 8 + dist/lib/output/plugins/index.js | 19 + dist/lib/output/plugins/index.js.map | 1 + dist/lib/output/renderer.d.ts | 23 + dist/lib/output/renderer.js | 206 ++ dist/lib/output/renderer.js.map | 1 + dist/lib/output/theme.d.ts | 14 + dist/lib/output/theme.js | 45 + dist/lib/output/theme.js.map | 1 + dist/lib/output/themes/DefaultTheme.d.ts | 29 + dist/lib/output/themes/DefaultTheme.js | 351 +++ dist/lib/output/themes/DefaultTheme.js.map | 1 + dist/lib/output/themes/MinimalTheme.d.ts | 12 + dist/lib/output/themes/MinimalTheme.js | 66 + dist/lib/output/themes/MinimalTheme.js.map | 1 + dist/lib/output/utils/resources.d.ts | 18 + dist/lib/output/utils/resources.js | 77 + dist/lib/output/utils/resources.js.map | 1 + dist/lib/output/utils/resources/helpers.d.ts | 13 + dist/lib/output/utils/resources/helpers.js | 85 + .../lib/output/utils/resources/helpers.js.map | 1 + dist/lib/output/utils/resources/stack.d.ts | 43 + dist/lib/output/utils/resources/stack.js | 178 ++ dist/lib/output/utils/resources/stack.js.map | 1 + .../lib/output/utils/resources/templates.d.ts | 15 + dist/lib/output/utils/resources/templates.js | 82 + .../output/utils/resources/templates.js.map | 1 + dist/lib/serialization/browser.d.ts | 113 + dist/lib/serialization/browser.js | 3 + dist/lib/serialization/browser.js.map | 1 + dist/lib/serialization/components.d.ts | 25 + dist/lib/serialization/components.js | 59 + dist/lib/serialization/components.js.map | 1 + dist/lib/serialization/events.d.ts | 8 + dist/lib/serialization/events.js | 22 + dist/lib/serialization/events.js.map | 1 + dist/lib/serialization/index.d.ts | 5 + dist/lib/serialization/index.js | 37 + dist/lib/serialization/index.js.map | 1 + dist/lib/serialization/serializer.d.ts | 21 + dist/lib/serialization/serializer.js | 114 + dist/lib/serialization/serializer.js.map | 1 + .../serializers/comments/comment-tag.d.ts | 10 + .../serializers/comments/comment-tag.js | 55 + .../serializers/comments/comment-tag.js.map | 1 + .../serializers/comments/comment.d.ts | 10 + .../serializers/comments/comment.js | 64 + .../serializers/comments/comment.js.map | 1 + .../serializers/comments/index.d.ts | 2 + .../serializers/comments/index.js | 7 + .../serializers/comments/index.js.map | 1 + .../serialization/serializers/decorator.d.ts | 10 + .../serialization/serializers/decorator.js | 58 + .../serializers/decorator.js.map | 1 + dist/lib/serialization/serializers/index.d.ts | 7 + dist/lib/serialization/serializers/index.js | 13 + .../serialization/serializers/index.js.map | 1 + .../serializers/models/decorator-wrapper.d.ts | 5 + .../serializers/models/decorator-wrapper.js | 10 + .../models/decorator-wrapper.js.map | 1 + .../serializers/models/index.d.ts | 2 + .../serialization/serializers/models/index.js | 7 + .../serializers/models/index.js.map | 1 + .../models/source-reference-wrapper.d.ts | 5 + .../models/source-reference-wrapper.js | 10 + .../models/source-reference-wrapper.js.map | 1 + .../serializers/reflection-group.d.ts | 10 + .../serializers/reflection-group.js | 57 + .../serializers/reflection-group.js.map | 1 + .../serializers/reflections/abstract.d.ts | 7 + .../serializers/reflections/abstract.js | 91 + .../serializers/reflections/abstract.js.map | 1 + .../serializers/reflections/container.d.ts | 6 + .../serializers/reflections/container.js | 55 + .../serializers/reflections/container.js.map | 1 + .../serializers/reflections/declaration.d.ts | 7 + .../serializers/reflections/declaration.js | 71 + .../reflections/declaration.js.map | 1 + .../serializers/reflections/index.d.ts | 7 + .../serializers/reflections/index.js | 13 + .../serializers/reflections/index.js.map | 1 + .../serializers/reflections/parameter.d.ts | 6 + .../serializers/reflections/parameter.js | 47 + .../serializers/reflections/parameter.js.map | 1 + .../serializers/reflections/project.d.ts | 7 + .../serializers/reflections/project.js | 42 + .../serializers/reflections/project.js.map | 1 + .../serializers/reflections/signature.d.ts | 6 + .../serializers/reflections/signature.js | 53 + .../serializers/reflections/signature.js.map | 1 + .../reflections/type-parameter.d.ts | 6 + .../serializers/reflections/type-parameter.js | 44 + .../reflections/type-parameter.js.map | 1 + .../serializers/sources/index.d.ts | 1 + .../serializers/sources/index.js | 5 + .../serializers/sources/index.js.map | 1 + .../serializers/sources/source-reference.d.ts | 9 + .../serializers/sources/source-reference.js | 49 + .../sources/source-reference.js.map | 1 + .../serializers/types/abstract.d.ts | 7 + .../serializers/types/abstract.js | 42 + .../serializers/types/abstract.js.map | 1 + .../serializers/types/array.d.ts | 6 + .../serialization/serializers/types/array.js | 42 + .../serializers/types/array.js.map | 1 + .../serializers/types/index.d.ts | 11 + .../serialization/serializers/types/index.js | 17 + .../serializers/types/index.js.map | 1 + .../serializers/types/intersection-union.d.ts | 7 + .../serializers/types/intersection-union.js | 45 + .../types/intersection-union.js.map | 1 + .../serializers/types/intrinsic.d.ts | 6 + .../serializers/types/intrinsic.js | 42 + .../serializers/types/intrinsic.js.map | 1 + .../serializers/types/reference.d.ts | 6 + .../serializers/types/reference.js | 49 + .../serializers/types/reference.js.map | 1 + .../serializers/types/reflection.d.ts | 7 + .../serializers/types/reflection.js | 51 + .../serializers/types/reflection.js.map | 1 + .../serializers/types/string-literal.d.ts | 6 + .../serializers/types/string-literal.js | 42 + .../serializers/types/string-literal.js.map | 1 + .../serializers/types/tuple.d.ts | 6 + .../serialization/serializers/types/tuple.js | 45 + .../serializers/types/tuple.js.map | 1 + .../serializers/types/type-operator.d.ts | 6 + .../serializers/types/type-operator.js | 43 + .../serializers/types/type-operator.js.map | 1 + .../serializers/types/type-parameter.d.ts | 6 + .../serializers/types/type-parameter.js | 45 + .../serializers/types/type-parameter.js.map | 1 + .../serializers/types/unknown.d.ts | 6 + .../serializers/types/unknown.js | 42 + .../serializers/types/unknown.js.map | 1 + dist/lib/ts-internal.d.ts | 55 + dist/lib/ts-internal.js | 69 + dist/lib/ts-internal.js.map | 1 + dist/lib/utils/component.d.ts | 47 + dist/lib/utils/component.js | 194 ++ dist/lib/utils/component.js.map | 1 + dist/lib/utils/events.d.ts | 37 + dist/lib/utils/events.js | 287 +++ dist/lib/utils/events.js.map | 1 + dist/lib/utils/fs.d.ts | 5 + dist/lib/utils/fs.js | 70 + dist/lib/utils/fs.js.map | 1 + dist/lib/utils/index.d.ts | 5 + dist/lib/utils/index.js | 23 + dist/lib/utils/index.js.map | 1 + dist/lib/utils/loggers.d.ts | 30 + dist/lib/utils/loggers.js | 157 ++ dist/lib/utils/loggers.js.map | 1 + dist/lib/utils/options/declaration.d.ts | 45 + dist/lib/utils/options/declaration.js | 83 + dist/lib/utils/options/declaration.js.map | 1 + dist/lib/utils/options/help.d.ts | 7 + dist/lib/utils/options/help.js | 60 + dist/lib/utils/options/help.js.map | 1 + dist/lib/utils/options/index.d.ts | 3 + dist/lib/utils/options/index.js | 8 + dist/lib/utils/options/index.js.map | 1 + dist/lib/utils/options/options.d.ts | 42 + dist/lib/utils/options/options.js | 206 ++ dist/lib/utils/options/options.js.map | 1 + dist/lib/utils/options/readers/arguments.d.ts | 7 + dist/lib/utils/options/readers/arguments.js | 121 + .../utils/options/readers/arguments.js.map | 1 + dist/lib/utils/options/readers/index.d.ts | 3 + dist/lib/utils/options/readers/index.js | 9 + dist/lib/utils/options/readers/index.js.map | 1 + dist/lib/utils/options/readers/tsconfig.d.ts | 9 + dist/lib/utils/options/readers/tsconfig.js | 93 + .../lib/utils/options/readers/tsconfig.js.map | 1 + dist/lib/utils/options/readers/typedoc.d.ts | 8 + dist/lib/utils/options/readers/typedoc.js | 89 + dist/lib/utils/options/readers/typedoc.js.map | 1 + dist/lib/utils/options/sources/component.d.ts | 9 + dist/lib/utils/options/sources/component.js | 80 + .../utils/options/sources/component.js.map | 1 + dist/lib/utils/options/sources/index.d.ts | 2 + dist/lib/utils/options/sources/index.js | 7 + dist/lib/utils/options/sources/index.js.map | 1 + .../lib/utils/options/sources/typescript.d.ts | 9 + dist/lib/utils/options/sources/typescript.js | 94 + .../utils/options/sources/typescript.js.map | 1 + dist/lib/utils/plugins.d.ts | 7 + dist/lib/utils/plugins.js | 129 ++ dist/lib/utils/plugins.js.map | 1 + dist/test/converter.d.ts | 1 + dist/test/converter.js | 116 + dist/test/converter.js.map | 1 + dist/test/converter/access/access.ts | 54 + dist/test/converter/access/specs.json | 341 +++ dist/test/converter/alias/alias.ts | 9 + dist/test/converter/alias/specs.json | 156 ++ dist/test/converter/array/array.ts | 16 + dist/test/converter/array/specs.json | 177 ++ dist/test/converter/class/class.ts | 89 + dist/test/converter/class/specs.json | 976 ++++++++ dist/test/converter/comment/comment.ts | 29 + dist/test/converter/comment/specs.json | 109 + .../constructor-properties.ts | 32 + .../constructor-properties/specs.json | 488 ++++ dist/test/converter/decorators/decorators.ts | 48 + dist/test/converter/decorators/specs.json | 384 ++++ .../converter/destructuring/destructuring.ts | 25 + dist/test/converter/destructuring/specs.json | 412 ++++ dist/test/converter/enum/enum.ts | 60 + dist/test/converter/enum/specs.json | 305 +++ .../events-overloads/events-overloads.ts | 43 + .../converter/events-overloads/specs.json | 442 ++++ dist/test/converter/events/events.ts | 9 + dist/test/converter/events/specs.json | 94 + .../export-assignment/export-assignment.ts | 5 + .../converter/export-assignment/specs.json | 99 + .../export-default/export-default.ts | 2 + dist/test/converter/export-default/specs.json | 67 + .../export-with-local/export-with-local.ts | 13 + .../specs-without-exported.json | 127 ++ .../converter/export-with-local/specs.json | 201 ++ dist/test/converter/export/export.ts | 5 + dist/test/converter/export/specs.json | 127 ++ dist/test/converter/function/function.ts | 153 ++ dist/test/converter/function/specs.json | 775 +++++++ .../converter/generic-class/generic-class.ts | 37 + dist/test/converter/generic-class/specs.json | 454 ++++ .../generic-function/generic-function.ts | 21 + .../converter/generic-function/specs.json | 193 ++ .../converter/getter-setter/getter-setter.ts | 12 + dist/test/converter/getter-setter/specs.json | 224 ++ .../implicit-types/implicit-types.ts | 29 + dist/test/converter/implicit-types/specs.json | 415 ++++ .../interface-empty/interface-empty.ts | 14 + .../test/converter/interface-empty/specs.json | 167 ++ .../interface-implementation.ts | 75 + .../interface-implementation/specs.json | 1241 ++++++++++ .../literal-object-callbacks.ts | 18 + .../literal-object-callbacks/specs.json | 375 +++ .../literal-object/literal-object.ts | 14 + dist/test/converter/literal-object/specs.json | 353 +++ .../converter/literal-type/literal-type.ts | 11 + dist/test/converter/literal-type/specs.json | 396 ++++ dist/test/converter/react/react.d.ts | 2018 +++++++++++++++++ dist/test/converter/react/react.tsx | 28 + dist/test/converter/react/specs.json | 705 ++++++ dist/test/converter/this/specs.json | 109 + dist/test/converter/this/this.ts | 15 + dist/test/converter/type-operator/specs.json | 196 ++ .../converter/type-operator/type-operator.ts | 15 + .../union-or-intersection/specs.json | 302 +++ .../union-or-intersection.ts | 42 + dist/test/converter/variable/specs.json | 112 + dist/test/converter/variable/variable.ts | 3 + dist/test/events.d.ts | 1 + dist/test/events.js | 731 ++++++ dist/test/events.js.map | 1 + dist/test/plugin-host.d.ts | 1 + dist/test/plugin-host.js | 16 + dist/test/plugin-host.js.map | 1 + dist/test/renderer.d.ts | 1 + dist/test/renderer.js | 77 + dist/test/renderer.js.map | 1 + .../specs/classes/_access_.privateclass.html | 347 +++ .../specs/classes/_classes_.baseclass.html | 679 ++++++ .../specs/classes/_classes_.genericclass.html | 502 ++++ .../classes/_classes_.internalclass.html | 296 +++ .../classes/_classes_.nongenericclass.html | 477 ++++ .../specs/classes/_classes_.subclassa.html | 827 +++++++ .../specs/classes/_classes_.subclassb.html | 650 ++++++ ..._default_export_.defaultexportedclass.html | 324 +++ ..._default_export_.notexportedclassname.html | 325 +++ .../classes/_flattened_.flattenedclass.html | 518 +++++ .../_single_export_.notexportedclass.html | 322 +++ .../_single_export_.singleexportedclass.html | 324 +++ ...script_1_3_.classwithprotectedmembers.html | 386 ++++ ...ipt_1_3_.subclasswithprotectedmembers.html | 345 +++ .../classes/_typescript_1_4_.simpleclass.html | 314 +++ .../enums/_enumerations_.directions.html | 341 +++ .../specs/enums/_enumerations_.size.html | 357 +++ dist/test/renderer/specs/globals.html | 212 ++ dist/test/renderer/specs/index.html | 320 +++ .../interfaces/_classes_.inameinterface.html | 324 +++ .../interfaces/_classes_.iprintinterface.html | 294 +++ .../_classes_.iprintnameinterface.html | 387 ++++ .../specs/interfaces/_generics_.a.html | 295 +++ .../specs/interfaces/_generics_.ab.html | 372 +++ .../specs/interfaces/_generics_.abnumber.html | 347 +++ .../specs/interfaces/_generics_.abstring.html | 347 +++ .../specs/interfaces/_generics_.b.html | 338 +++ .../_typescript_1_4_.runoptions.html | 290 +++ .../test/renderer/specs/modules/_access_.html | 323 +++ .../specs/modules/_access_.privatemodule.html | 241 ++ .../renderer/specs/modules/_classes_.html | 243 ++ .../specs/modules/_default_export_.html | 210 ++ .../specs/modules/_enumerations_.html | 210 ++ .../renderer/specs/modules/_flattened_.html | 396 ++++ .../renderer/specs/modules/_functions_.html | 706 ++++++ .../modules/_functions_.modulefunction.html | 329 +++ .../renderer/specs/modules/_generics_.html | 302 +++ .../renderer/specs/modules/_modules_.html | 489 ++++ .../specs/modules/_modules_.mymodule.html | 343 +++ .../_modules_.mymodule.mysubmodule.html | 256 +++ .../specs/modules/_single_export_.html | 210 ++ .../specs/modules/_typescript_1_3_.html | 237 ++ .../specs/modules/_typescript_1_4_.html | 544 +++++ .../specs/modules/_typescript_1_5_.html | 419 ++++ .../renderer/specs/modules/_variables_.html | 262 +++ dist/test/typedoc.d.ts | 1 + dist/test/typedoc.js | 54 + dist/test/typedoc.js.map | 1 + 633 files changed, 45157 insertions(+), 1 deletion(-) create mode 100644 dist/index.d.ts create mode 100644 dist/index.js create mode 100644 dist/index.js.map create mode 100644 dist/lib/application.d.ts create mode 100644 dist/lib/application.js create mode 100644 dist/lib/application.js.map create mode 100644 dist/lib/cli.d.ts create mode 100644 dist/lib/cli.js create mode 100644 dist/lib/cli.js.map create mode 100644 dist/lib/converter/components.d.ts create mode 100644 dist/lib/converter/components.js create mode 100644 dist/lib/converter/components.js.map create mode 100644 dist/lib/converter/context.d.ts create mode 100644 dist/lib/converter/context.js create mode 100644 dist/lib/converter/context.js.map create mode 100644 dist/lib/converter/convert-expression.d.ts create mode 100644 dist/lib/converter/convert-expression.js create mode 100644 dist/lib/converter/convert-expression.js.map create mode 100644 dist/lib/converter/converter.d.ts create mode 100644 dist/lib/converter/converter.js create mode 100644 dist/lib/converter/converter.js.map create mode 100644 dist/lib/converter/factories/comment.d.ts create mode 100644 dist/lib/converter/factories/comment.js create mode 100644 dist/lib/converter/factories/comment.js.map create mode 100644 dist/lib/converter/factories/declaration.d.ts create mode 100644 dist/lib/converter/factories/declaration.js create mode 100644 dist/lib/converter/factories/declaration.js.map create mode 100644 dist/lib/converter/factories/index.d.ts create mode 100644 dist/lib/converter/factories/index.js create mode 100644 dist/lib/converter/factories/index.js.map create mode 100644 dist/lib/converter/factories/parameter.d.ts create mode 100644 dist/lib/converter/factories/parameter.js create mode 100644 dist/lib/converter/factories/parameter.js.map create mode 100644 dist/lib/converter/factories/reference.d.ts create mode 100644 dist/lib/converter/factories/reference.js create mode 100644 dist/lib/converter/factories/reference.js.map create mode 100644 dist/lib/converter/factories/signature.d.ts create mode 100644 dist/lib/converter/factories/signature.js create mode 100644 dist/lib/converter/factories/signature.js.map create mode 100644 dist/lib/converter/factories/type-parameter.d.ts create mode 100644 dist/lib/converter/factories/type-parameter.js create mode 100644 dist/lib/converter/factories/type-parameter.js.map create mode 100644 dist/lib/converter/index.d.ts create mode 100644 dist/lib/converter/index.js create mode 100644 dist/lib/converter/index.js.map create mode 100644 dist/lib/converter/nodes/accessor.d.ts create mode 100644 dist/lib/converter/nodes/accessor.js create mode 100644 dist/lib/converter/nodes/accessor.js.map create mode 100644 dist/lib/converter/nodes/alias.d.ts create mode 100644 dist/lib/converter/nodes/alias.js create mode 100644 dist/lib/converter/nodes/alias.js.map create mode 100644 dist/lib/converter/nodes/block.d.ts create mode 100644 dist/lib/converter/nodes/block.js create mode 100644 dist/lib/converter/nodes/block.js.map create mode 100644 dist/lib/converter/nodes/class.d.ts create mode 100644 dist/lib/converter/nodes/class.js create mode 100644 dist/lib/converter/nodes/class.js.map create mode 100644 dist/lib/converter/nodes/constructor.d.ts create mode 100644 dist/lib/converter/nodes/constructor.js create mode 100644 dist/lib/converter/nodes/constructor.js.map create mode 100644 dist/lib/converter/nodes/enum.d.ts create mode 100644 dist/lib/converter/nodes/enum.js create mode 100644 dist/lib/converter/nodes/enum.js.map create mode 100644 dist/lib/converter/nodes/export.d.ts create mode 100644 dist/lib/converter/nodes/export.js create mode 100644 dist/lib/converter/nodes/export.js.map create mode 100644 dist/lib/converter/nodes/function.d.ts create mode 100644 dist/lib/converter/nodes/function.js create mode 100644 dist/lib/converter/nodes/function.js.map create mode 100644 dist/lib/converter/nodes/index.d.ts create mode 100644 dist/lib/converter/nodes/index.js create mode 100644 dist/lib/converter/nodes/index.js.map create mode 100644 dist/lib/converter/nodes/interface.d.ts create mode 100644 dist/lib/converter/nodes/interface.js create mode 100644 dist/lib/converter/nodes/interface.js.map create mode 100644 dist/lib/converter/nodes/literal-object.d.ts create mode 100644 dist/lib/converter/nodes/literal-object.js create mode 100644 dist/lib/converter/nodes/literal-object.js.map create mode 100644 dist/lib/converter/nodes/literal-type.d.ts create mode 100644 dist/lib/converter/nodes/literal-type.js create mode 100644 dist/lib/converter/nodes/literal-type.js.map create mode 100644 dist/lib/converter/nodes/module.d.ts create mode 100644 dist/lib/converter/nodes/module.js create mode 100644 dist/lib/converter/nodes/module.js.map create mode 100644 dist/lib/converter/nodes/signature-call.d.ts create mode 100644 dist/lib/converter/nodes/signature-call.js create mode 100644 dist/lib/converter/nodes/signature-call.js.map create mode 100644 dist/lib/converter/nodes/signature-index.d.ts create mode 100644 dist/lib/converter/nodes/signature-index.js create mode 100644 dist/lib/converter/nodes/signature-index.js.map create mode 100644 dist/lib/converter/nodes/variable-statement.d.ts create mode 100644 dist/lib/converter/nodes/variable-statement.js create mode 100644 dist/lib/converter/nodes/variable-statement.js.map create mode 100644 dist/lib/converter/nodes/variable.d.ts create mode 100644 dist/lib/converter/nodes/variable.js create mode 100644 dist/lib/converter/nodes/variable.js.map create mode 100644 dist/lib/converter/plugins/CategoryPlugin.d.ts create mode 100644 dist/lib/converter/plugins/CategoryPlugin.js create mode 100644 dist/lib/converter/plugins/CategoryPlugin.js.map create mode 100644 dist/lib/converter/plugins/CommentPlugin.d.ts create mode 100644 dist/lib/converter/plugins/CommentPlugin.js create mode 100644 dist/lib/converter/plugins/CommentPlugin.js.map create mode 100644 dist/lib/converter/plugins/DecoratorPlugin.d.ts create mode 100644 dist/lib/converter/plugins/DecoratorPlugin.js create mode 100644 dist/lib/converter/plugins/DecoratorPlugin.js.map create mode 100644 dist/lib/converter/plugins/DeepCommentPlugin.d.ts create mode 100644 dist/lib/converter/plugins/DeepCommentPlugin.js create mode 100644 dist/lib/converter/plugins/DeepCommentPlugin.js.map create mode 100644 dist/lib/converter/plugins/DynamicModulePlugin.d.ts create mode 100644 dist/lib/converter/plugins/DynamicModulePlugin.js create mode 100644 dist/lib/converter/plugins/DynamicModulePlugin.js.map create mode 100644 dist/lib/converter/plugins/GitHubPlugin.d.ts create mode 100644 dist/lib/converter/plugins/GitHubPlugin.js create mode 100644 dist/lib/converter/plugins/GitHubPlugin.js.map create mode 100644 dist/lib/converter/plugins/GroupPlugin.d.ts create mode 100644 dist/lib/converter/plugins/GroupPlugin.js create mode 100644 dist/lib/converter/plugins/GroupPlugin.js.map create mode 100644 dist/lib/converter/plugins/ImplementsPlugin.d.ts create mode 100644 dist/lib/converter/plugins/ImplementsPlugin.js create mode 100644 dist/lib/converter/plugins/ImplementsPlugin.js.map create mode 100644 dist/lib/converter/plugins/PackagePlugin.d.ts create mode 100644 dist/lib/converter/plugins/PackagePlugin.js create mode 100644 dist/lib/converter/plugins/PackagePlugin.js.map create mode 100644 dist/lib/converter/plugins/SourcePlugin.d.ts create mode 100644 dist/lib/converter/plugins/SourcePlugin.js create mode 100644 dist/lib/converter/plugins/SourcePlugin.js.map create mode 100644 dist/lib/converter/plugins/TypePlugin.d.ts create mode 100644 dist/lib/converter/plugins/TypePlugin.js create mode 100644 dist/lib/converter/plugins/TypePlugin.js.map create mode 100644 dist/lib/converter/plugins/index.d.ts create mode 100644 dist/lib/converter/plugins/index.js create mode 100644 dist/lib/converter/plugins/index.js.map create mode 100644 dist/lib/converter/types/alias.d.ts create mode 100644 dist/lib/converter/types/alias.js create mode 100644 dist/lib/converter/types/alias.js.map create mode 100644 dist/lib/converter/types/array.d.ts create mode 100644 dist/lib/converter/types/array.js create mode 100644 dist/lib/converter/types/array.js.map create mode 100644 dist/lib/converter/types/binding-array.d.ts create mode 100644 dist/lib/converter/types/binding-array.js create mode 100644 dist/lib/converter/types/binding-array.js.map create mode 100644 dist/lib/converter/types/binding-object.d.ts create mode 100644 dist/lib/converter/types/binding-object.js create mode 100644 dist/lib/converter/types/binding-object.js.map create mode 100644 dist/lib/converter/types/enum.d.ts create mode 100644 dist/lib/converter/types/enum.js create mode 100644 dist/lib/converter/types/enum.js.map create mode 100644 dist/lib/converter/types/index.d.ts create mode 100644 dist/lib/converter/types/index.js create mode 100644 dist/lib/converter/types/index.js.map create mode 100644 dist/lib/converter/types/intrinsic.d.ts create mode 100644 dist/lib/converter/types/intrinsic.js create mode 100644 dist/lib/converter/types/intrinsic.js.map create mode 100644 dist/lib/converter/types/reference.d.ts create mode 100644 dist/lib/converter/types/reference.js create mode 100644 dist/lib/converter/types/reference.js.map create mode 100644 dist/lib/converter/types/string-literal.d.ts create mode 100644 dist/lib/converter/types/string-literal.js create mode 100644 dist/lib/converter/types/string-literal.js.map create mode 100644 dist/lib/converter/types/this.d.ts create mode 100644 dist/lib/converter/types/this.js create mode 100644 dist/lib/converter/types/this.js.map create mode 100644 dist/lib/converter/types/tuple.d.ts create mode 100644 dist/lib/converter/types/tuple.js create mode 100644 dist/lib/converter/types/tuple.js.map create mode 100644 dist/lib/converter/types/type-operator.d.ts create mode 100644 dist/lib/converter/types/type-operator.js create mode 100644 dist/lib/converter/types/type-operator.js.map create mode 100644 dist/lib/converter/types/type-parameter.d.ts create mode 100644 dist/lib/converter/types/type-parameter.js create mode 100644 dist/lib/converter/types/type-parameter.js.map create mode 100644 dist/lib/converter/types/union-or-intersection.d.ts create mode 100644 dist/lib/converter/types/union-or-intersection.js create mode 100644 dist/lib/converter/types/union-or-intersection.js.map create mode 100644 dist/lib/converter/types/unknown.d.ts create mode 100644 dist/lib/converter/types/unknown.js create mode 100644 dist/lib/converter/types/unknown.js.map create mode 100644 dist/lib/converter/utils/base-path.d.ts create mode 100644 dist/lib/converter/utils/base-path.js create mode 100644 dist/lib/converter/utils/base-path.js.map create mode 100644 dist/lib/converter/utils/compiler-host.d.ts create mode 100644 dist/lib/converter/utils/compiler-host.js create mode 100644 dist/lib/converter/utils/compiler-host.js.map create mode 100644 dist/lib/models/ReflectionCategory.d.ts create mode 100644 dist/lib/models/ReflectionCategory.js create mode 100644 dist/lib/models/ReflectionCategory.js.map create mode 100644 dist/lib/models/ReflectionGroup.d.ts create mode 100644 dist/lib/models/ReflectionGroup.js create mode 100644 dist/lib/models/ReflectionGroup.js.map create mode 100644 dist/lib/models/comments/comment.d.ts create mode 100644 dist/lib/models/comments/comment.js create mode 100644 dist/lib/models/comments/comment.js.map create mode 100644 dist/lib/models/comments/index.d.ts create mode 100644 dist/lib/models/comments/index.js create mode 100644 dist/lib/models/comments/index.js.map create mode 100644 dist/lib/models/comments/tag.d.ts create mode 100644 dist/lib/models/comments/tag.js create mode 100644 dist/lib/models/comments/tag.js.map create mode 100644 dist/lib/models/index.d.ts create mode 100644 dist/lib/models/index.js create mode 100644 dist/lib/models/index.js.map create mode 100644 dist/lib/models/reflections/abstract.d.ts create mode 100644 dist/lib/models/reflections/abstract.js create mode 100644 dist/lib/models/reflections/abstract.js.map create mode 100644 dist/lib/models/reflections/container.d.ts create mode 100644 dist/lib/models/reflections/container.js create mode 100644 dist/lib/models/reflections/container.js.map create mode 100644 dist/lib/models/reflections/declaration.d.ts create mode 100644 dist/lib/models/reflections/declaration.js create mode 100644 dist/lib/models/reflections/declaration.js.map create mode 100644 dist/lib/models/reflections/index.d.ts create mode 100644 dist/lib/models/reflections/index.js create mode 100644 dist/lib/models/reflections/index.js.map create mode 100644 dist/lib/models/reflections/parameter.d.ts create mode 100644 dist/lib/models/reflections/parameter.js create mode 100644 dist/lib/models/reflections/parameter.js.map create mode 100644 dist/lib/models/reflections/project.d.ts create mode 100644 dist/lib/models/reflections/project.js create mode 100644 dist/lib/models/reflections/project.js.map create mode 100644 dist/lib/models/reflections/signature.d.ts create mode 100644 dist/lib/models/reflections/signature.js create mode 100644 dist/lib/models/reflections/signature.js.map create mode 100644 dist/lib/models/reflections/type-parameter.d.ts create mode 100644 dist/lib/models/reflections/type-parameter.js create mode 100644 dist/lib/models/reflections/type-parameter.js.map create mode 100644 dist/lib/models/sources/directory.d.ts create mode 100644 dist/lib/models/sources/directory.js create mode 100644 dist/lib/models/sources/directory.js.map create mode 100644 dist/lib/models/sources/file.d.ts create mode 100644 dist/lib/models/sources/file.js create mode 100644 dist/lib/models/sources/file.js.map create mode 100644 dist/lib/models/sources/index.d.ts create mode 100644 dist/lib/models/sources/index.js create mode 100644 dist/lib/models/sources/index.js.map create mode 100644 dist/lib/models/types/abstract.d.ts create mode 100644 dist/lib/models/types/abstract.js create mode 100644 dist/lib/models/types/abstract.js.map create mode 100644 dist/lib/models/types/array.d.ts create mode 100644 dist/lib/models/types/array.js create mode 100644 dist/lib/models/types/array.js.map create mode 100644 dist/lib/models/types/index.d.ts create mode 100644 dist/lib/models/types/index.js create mode 100644 dist/lib/models/types/index.js.map create mode 100644 dist/lib/models/types/intersection.d.ts create mode 100644 dist/lib/models/types/intersection.js create mode 100644 dist/lib/models/types/intersection.js.map create mode 100644 dist/lib/models/types/intrinsic.d.ts create mode 100644 dist/lib/models/types/intrinsic.js create mode 100644 dist/lib/models/types/intrinsic.js.map create mode 100644 dist/lib/models/types/reference.d.ts create mode 100644 dist/lib/models/types/reference.js create mode 100644 dist/lib/models/types/reference.js.map create mode 100644 dist/lib/models/types/reflection.d.ts create mode 100644 dist/lib/models/types/reflection.js create mode 100644 dist/lib/models/types/reflection.js.map create mode 100644 dist/lib/models/types/string-literal.d.ts create mode 100644 dist/lib/models/types/string-literal.js create mode 100644 dist/lib/models/types/string-literal.js.map create mode 100644 dist/lib/models/types/tuple.d.ts create mode 100644 dist/lib/models/types/tuple.js create mode 100644 dist/lib/models/types/tuple.js.map create mode 100644 dist/lib/models/types/type-operator.d.ts create mode 100644 dist/lib/models/types/type-operator.js create mode 100644 dist/lib/models/types/type-operator.js.map create mode 100644 dist/lib/models/types/type-parameter.d.ts create mode 100644 dist/lib/models/types/type-parameter.js create mode 100644 dist/lib/models/types/type-parameter.js.map create mode 100644 dist/lib/models/types/union.d.ts create mode 100644 dist/lib/models/types/union.js create mode 100644 dist/lib/models/types/union.js.map create mode 100644 dist/lib/models/types/unknown.d.ts create mode 100644 dist/lib/models/types/unknown.js create mode 100644 dist/lib/models/types/unknown.js.map create mode 100644 dist/lib/output/components.d.ts create mode 100644 dist/lib/output/components.js create mode 100644 dist/lib/output/components.js.map create mode 100644 dist/lib/output/events.d.ts create mode 100644 dist/lib/output/events.js create mode 100644 dist/lib/output/events.js.map create mode 100644 dist/lib/output/helpers/compact.d.ts create mode 100644 dist/lib/output/helpers/compact.js create mode 100644 dist/lib/output/helpers/compact.js.map create mode 100644 dist/lib/output/helpers/if-cond.d.ts create mode 100644 dist/lib/output/helpers/if-cond.js create mode 100644 dist/lib/output/helpers/if-cond.js.map create mode 100644 dist/lib/output/helpers/if-signature.d.ts create mode 100644 dist/lib/output/helpers/if-signature.js create mode 100644 dist/lib/output/helpers/if-signature.js.map create mode 100644 dist/lib/output/helpers/wbr.d.ts create mode 100644 dist/lib/output/helpers/wbr.js create mode 100644 dist/lib/output/helpers/wbr.js.map create mode 100644 dist/lib/output/models/NavigationItem.d.ts create mode 100644 dist/lib/output/models/NavigationItem.js create mode 100644 dist/lib/output/models/NavigationItem.js.map create mode 100644 dist/lib/output/models/UrlMapping.d.ts create mode 100644 dist/lib/output/models/UrlMapping.js create mode 100644 dist/lib/output/models/UrlMapping.js.map create mode 100644 dist/lib/output/plugins/AssetsPlugin.d.ts create mode 100644 dist/lib/output/plugins/AssetsPlugin.js create mode 100644 dist/lib/output/plugins/AssetsPlugin.js.map create mode 100644 dist/lib/output/plugins/JavascriptIndexPlugin.d.ts create mode 100644 dist/lib/output/plugins/JavascriptIndexPlugin.js create mode 100644 dist/lib/output/plugins/JavascriptIndexPlugin.js.map create mode 100644 dist/lib/output/plugins/LayoutPlugin.d.ts create mode 100644 dist/lib/output/plugins/LayoutPlugin.js create mode 100644 dist/lib/output/plugins/LayoutPlugin.js.map create mode 100644 dist/lib/output/plugins/MarkedLinksPlugin.d.ts create mode 100644 dist/lib/output/plugins/MarkedLinksPlugin.js create mode 100644 dist/lib/output/plugins/MarkedLinksPlugin.js.map create mode 100644 dist/lib/output/plugins/MarkedPlugin.d.ts create mode 100644 dist/lib/output/plugins/MarkedPlugin.js create mode 100644 dist/lib/output/plugins/MarkedPlugin.js.map create mode 100644 dist/lib/output/plugins/NavigationPlugin.d.ts create mode 100644 dist/lib/output/plugins/NavigationPlugin.js create mode 100644 dist/lib/output/plugins/NavigationPlugin.js.map create mode 100644 dist/lib/output/plugins/PrettyPrintPlugin.d.ts create mode 100644 dist/lib/output/plugins/PrettyPrintPlugin.js create mode 100644 dist/lib/output/plugins/PrettyPrintPlugin.js.map create mode 100644 dist/lib/output/plugins/TocPlugin.d.ts create mode 100644 dist/lib/output/plugins/TocPlugin.js create mode 100644 dist/lib/output/plugins/TocPlugin.js.map create mode 100644 dist/lib/output/plugins/index.d.ts create mode 100644 dist/lib/output/plugins/index.js create mode 100644 dist/lib/output/plugins/index.js.map create mode 100644 dist/lib/output/renderer.d.ts create mode 100644 dist/lib/output/renderer.js create mode 100644 dist/lib/output/renderer.js.map create mode 100644 dist/lib/output/theme.d.ts create mode 100644 dist/lib/output/theme.js create mode 100644 dist/lib/output/theme.js.map create mode 100644 dist/lib/output/themes/DefaultTheme.d.ts create mode 100644 dist/lib/output/themes/DefaultTheme.js create mode 100644 dist/lib/output/themes/DefaultTheme.js.map create mode 100644 dist/lib/output/themes/MinimalTheme.d.ts create mode 100644 dist/lib/output/themes/MinimalTheme.js create mode 100644 dist/lib/output/themes/MinimalTheme.js.map create mode 100644 dist/lib/output/utils/resources.d.ts create mode 100644 dist/lib/output/utils/resources.js create mode 100644 dist/lib/output/utils/resources.js.map create mode 100644 dist/lib/output/utils/resources/helpers.d.ts create mode 100644 dist/lib/output/utils/resources/helpers.js create mode 100644 dist/lib/output/utils/resources/helpers.js.map create mode 100644 dist/lib/output/utils/resources/stack.d.ts create mode 100644 dist/lib/output/utils/resources/stack.js create mode 100644 dist/lib/output/utils/resources/stack.js.map create mode 100644 dist/lib/output/utils/resources/templates.d.ts create mode 100644 dist/lib/output/utils/resources/templates.js create mode 100644 dist/lib/output/utils/resources/templates.js.map create mode 100644 dist/lib/serialization/browser.d.ts create mode 100644 dist/lib/serialization/browser.js create mode 100644 dist/lib/serialization/browser.js.map create mode 100644 dist/lib/serialization/components.d.ts create mode 100644 dist/lib/serialization/components.js create mode 100644 dist/lib/serialization/components.js.map create mode 100644 dist/lib/serialization/events.d.ts create mode 100644 dist/lib/serialization/events.js create mode 100644 dist/lib/serialization/events.js.map create mode 100644 dist/lib/serialization/index.d.ts create mode 100644 dist/lib/serialization/index.js create mode 100644 dist/lib/serialization/index.js.map create mode 100644 dist/lib/serialization/serializer.d.ts create mode 100644 dist/lib/serialization/serializer.js create mode 100644 dist/lib/serialization/serializer.js.map create mode 100644 dist/lib/serialization/serializers/comments/comment-tag.d.ts create mode 100644 dist/lib/serialization/serializers/comments/comment-tag.js create mode 100644 dist/lib/serialization/serializers/comments/comment-tag.js.map create mode 100644 dist/lib/serialization/serializers/comments/comment.d.ts create mode 100644 dist/lib/serialization/serializers/comments/comment.js create mode 100644 dist/lib/serialization/serializers/comments/comment.js.map create mode 100644 dist/lib/serialization/serializers/comments/index.d.ts create mode 100644 dist/lib/serialization/serializers/comments/index.js create mode 100644 dist/lib/serialization/serializers/comments/index.js.map create mode 100644 dist/lib/serialization/serializers/decorator.d.ts create mode 100644 dist/lib/serialization/serializers/decorator.js create mode 100644 dist/lib/serialization/serializers/decorator.js.map create mode 100644 dist/lib/serialization/serializers/index.d.ts create mode 100644 dist/lib/serialization/serializers/index.js create mode 100644 dist/lib/serialization/serializers/index.js.map create mode 100644 dist/lib/serialization/serializers/models/decorator-wrapper.d.ts create mode 100644 dist/lib/serialization/serializers/models/decorator-wrapper.js create mode 100644 dist/lib/serialization/serializers/models/decorator-wrapper.js.map create mode 100644 dist/lib/serialization/serializers/models/index.d.ts create mode 100644 dist/lib/serialization/serializers/models/index.js create mode 100644 dist/lib/serialization/serializers/models/index.js.map create mode 100644 dist/lib/serialization/serializers/models/source-reference-wrapper.d.ts create mode 100644 dist/lib/serialization/serializers/models/source-reference-wrapper.js create mode 100644 dist/lib/serialization/serializers/models/source-reference-wrapper.js.map create mode 100644 dist/lib/serialization/serializers/reflection-group.d.ts create mode 100644 dist/lib/serialization/serializers/reflection-group.js create mode 100644 dist/lib/serialization/serializers/reflection-group.js.map create mode 100644 dist/lib/serialization/serializers/reflections/abstract.d.ts create mode 100644 dist/lib/serialization/serializers/reflections/abstract.js create mode 100644 dist/lib/serialization/serializers/reflections/abstract.js.map create mode 100644 dist/lib/serialization/serializers/reflections/container.d.ts create mode 100644 dist/lib/serialization/serializers/reflections/container.js create mode 100644 dist/lib/serialization/serializers/reflections/container.js.map create mode 100644 dist/lib/serialization/serializers/reflections/declaration.d.ts create mode 100644 dist/lib/serialization/serializers/reflections/declaration.js create mode 100644 dist/lib/serialization/serializers/reflections/declaration.js.map create mode 100644 dist/lib/serialization/serializers/reflections/index.d.ts create mode 100644 dist/lib/serialization/serializers/reflections/index.js create mode 100644 dist/lib/serialization/serializers/reflections/index.js.map create mode 100644 dist/lib/serialization/serializers/reflections/parameter.d.ts create mode 100644 dist/lib/serialization/serializers/reflections/parameter.js create mode 100644 dist/lib/serialization/serializers/reflections/parameter.js.map create mode 100644 dist/lib/serialization/serializers/reflections/project.d.ts create mode 100644 dist/lib/serialization/serializers/reflections/project.js create mode 100644 dist/lib/serialization/serializers/reflections/project.js.map create mode 100644 dist/lib/serialization/serializers/reflections/signature.d.ts create mode 100644 dist/lib/serialization/serializers/reflections/signature.js create mode 100644 dist/lib/serialization/serializers/reflections/signature.js.map create mode 100644 dist/lib/serialization/serializers/reflections/type-parameter.d.ts create mode 100644 dist/lib/serialization/serializers/reflections/type-parameter.js create mode 100644 dist/lib/serialization/serializers/reflections/type-parameter.js.map create mode 100644 dist/lib/serialization/serializers/sources/index.d.ts create mode 100644 dist/lib/serialization/serializers/sources/index.js create mode 100644 dist/lib/serialization/serializers/sources/index.js.map create mode 100644 dist/lib/serialization/serializers/sources/source-reference.d.ts create mode 100644 dist/lib/serialization/serializers/sources/source-reference.js create mode 100644 dist/lib/serialization/serializers/sources/source-reference.js.map create mode 100644 dist/lib/serialization/serializers/types/abstract.d.ts create mode 100644 dist/lib/serialization/serializers/types/abstract.js create mode 100644 dist/lib/serialization/serializers/types/abstract.js.map create mode 100644 dist/lib/serialization/serializers/types/array.d.ts create mode 100644 dist/lib/serialization/serializers/types/array.js create mode 100644 dist/lib/serialization/serializers/types/array.js.map create mode 100644 dist/lib/serialization/serializers/types/index.d.ts create mode 100644 dist/lib/serialization/serializers/types/index.js create mode 100644 dist/lib/serialization/serializers/types/index.js.map create mode 100644 dist/lib/serialization/serializers/types/intersection-union.d.ts create mode 100644 dist/lib/serialization/serializers/types/intersection-union.js create mode 100644 dist/lib/serialization/serializers/types/intersection-union.js.map create mode 100644 dist/lib/serialization/serializers/types/intrinsic.d.ts create mode 100644 dist/lib/serialization/serializers/types/intrinsic.js create mode 100644 dist/lib/serialization/serializers/types/intrinsic.js.map create mode 100644 dist/lib/serialization/serializers/types/reference.d.ts create mode 100644 dist/lib/serialization/serializers/types/reference.js create mode 100644 dist/lib/serialization/serializers/types/reference.js.map create mode 100644 dist/lib/serialization/serializers/types/reflection.d.ts create mode 100644 dist/lib/serialization/serializers/types/reflection.js create mode 100644 dist/lib/serialization/serializers/types/reflection.js.map create mode 100644 dist/lib/serialization/serializers/types/string-literal.d.ts create mode 100644 dist/lib/serialization/serializers/types/string-literal.js create mode 100644 dist/lib/serialization/serializers/types/string-literal.js.map create mode 100644 dist/lib/serialization/serializers/types/tuple.d.ts create mode 100644 dist/lib/serialization/serializers/types/tuple.js create mode 100644 dist/lib/serialization/serializers/types/tuple.js.map create mode 100644 dist/lib/serialization/serializers/types/type-operator.d.ts create mode 100644 dist/lib/serialization/serializers/types/type-operator.js create mode 100644 dist/lib/serialization/serializers/types/type-operator.js.map create mode 100644 dist/lib/serialization/serializers/types/type-parameter.d.ts create mode 100644 dist/lib/serialization/serializers/types/type-parameter.js create mode 100644 dist/lib/serialization/serializers/types/type-parameter.js.map create mode 100644 dist/lib/serialization/serializers/types/unknown.d.ts create mode 100644 dist/lib/serialization/serializers/types/unknown.js create mode 100644 dist/lib/serialization/serializers/types/unknown.js.map create mode 100644 dist/lib/ts-internal.d.ts create mode 100644 dist/lib/ts-internal.js create mode 100644 dist/lib/ts-internal.js.map create mode 100644 dist/lib/utils/component.d.ts create mode 100644 dist/lib/utils/component.js create mode 100644 dist/lib/utils/component.js.map create mode 100644 dist/lib/utils/events.d.ts create mode 100644 dist/lib/utils/events.js create mode 100644 dist/lib/utils/events.js.map create mode 100644 dist/lib/utils/fs.d.ts create mode 100644 dist/lib/utils/fs.js create mode 100644 dist/lib/utils/fs.js.map create mode 100644 dist/lib/utils/index.d.ts create mode 100644 dist/lib/utils/index.js create mode 100644 dist/lib/utils/index.js.map create mode 100644 dist/lib/utils/loggers.d.ts create mode 100644 dist/lib/utils/loggers.js create mode 100644 dist/lib/utils/loggers.js.map create mode 100644 dist/lib/utils/options/declaration.d.ts create mode 100644 dist/lib/utils/options/declaration.js create mode 100644 dist/lib/utils/options/declaration.js.map create mode 100644 dist/lib/utils/options/help.d.ts create mode 100644 dist/lib/utils/options/help.js create mode 100644 dist/lib/utils/options/help.js.map create mode 100644 dist/lib/utils/options/index.d.ts create mode 100644 dist/lib/utils/options/index.js create mode 100644 dist/lib/utils/options/index.js.map create mode 100644 dist/lib/utils/options/options.d.ts create mode 100644 dist/lib/utils/options/options.js create mode 100644 dist/lib/utils/options/options.js.map create mode 100644 dist/lib/utils/options/readers/arguments.d.ts create mode 100644 dist/lib/utils/options/readers/arguments.js create mode 100644 dist/lib/utils/options/readers/arguments.js.map create mode 100644 dist/lib/utils/options/readers/index.d.ts create mode 100644 dist/lib/utils/options/readers/index.js create mode 100644 dist/lib/utils/options/readers/index.js.map create mode 100644 dist/lib/utils/options/readers/tsconfig.d.ts create mode 100644 dist/lib/utils/options/readers/tsconfig.js create mode 100644 dist/lib/utils/options/readers/tsconfig.js.map create mode 100644 dist/lib/utils/options/readers/typedoc.d.ts create mode 100644 dist/lib/utils/options/readers/typedoc.js create mode 100644 dist/lib/utils/options/readers/typedoc.js.map create mode 100644 dist/lib/utils/options/sources/component.d.ts create mode 100644 dist/lib/utils/options/sources/component.js create mode 100644 dist/lib/utils/options/sources/component.js.map create mode 100644 dist/lib/utils/options/sources/index.d.ts create mode 100644 dist/lib/utils/options/sources/index.js create mode 100644 dist/lib/utils/options/sources/index.js.map create mode 100644 dist/lib/utils/options/sources/typescript.d.ts create mode 100644 dist/lib/utils/options/sources/typescript.js create mode 100644 dist/lib/utils/options/sources/typescript.js.map create mode 100644 dist/lib/utils/plugins.d.ts create mode 100644 dist/lib/utils/plugins.js create mode 100644 dist/lib/utils/plugins.js.map create mode 100644 dist/test/converter.d.ts create mode 100644 dist/test/converter.js create mode 100644 dist/test/converter.js.map create mode 100644 dist/test/converter/access/access.ts create mode 100644 dist/test/converter/access/specs.json create mode 100644 dist/test/converter/alias/alias.ts create mode 100644 dist/test/converter/alias/specs.json create mode 100644 dist/test/converter/array/array.ts create mode 100644 dist/test/converter/array/specs.json create mode 100644 dist/test/converter/class/class.ts create mode 100644 dist/test/converter/class/specs.json create mode 100644 dist/test/converter/comment/comment.ts create mode 100644 dist/test/converter/comment/specs.json create mode 100644 dist/test/converter/constructor-properties/constructor-properties.ts create mode 100644 dist/test/converter/constructor-properties/specs.json create mode 100644 dist/test/converter/decorators/decorators.ts create mode 100644 dist/test/converter/decorators/specs.json create mode 100644 dist/test/converter/destructuring/destructuring.ts create mode 100644 dist/test/converter/destructuring/specs.json create mode 100644 dist/test/converter/enum/enum.ts create mode 100644 dist/test/converter/enum/specs.json create mode 100644 dist/test/converter/events-overloads/events-overloads.ts create mode 100644 dist/test/converter/events-overloads/specs.json create mode 100644 dist/test/converter/events/events.ts create mode 100644 dist/test/converter/events/specs.json create mode 100644 dist/test/converter/export-assignment/export-assignment.ts create mode 100644 dist/test/converter/export-assignment/specs.json create mode 100644 dist/test/converter/export-default/export-default.ts create mode 100644 dist/test/converter/export-default/specs.json create mode 100644 dist/test/converter/export-with-local/export-with-local.ts create mode 100644 dist/test/converter/export-with-local/specs-without-exported.json create mode 100644 dist/test/converter/export-with-local/specs.json create mode 100644 dist/test/converter/export/export.ts create mode 100644 dist/test/converter/export/specs.json create mode 100644 dist/test/converter/function/function.ts create mode 100644 dist/test/converter/function/specs.json create mode 100644 dist/test/converter/generic-class/generic-class.ts create mode 100644 dist/test/converter/generic-class/specs.json create mode 100644 dist/test/converter/generic-function/generic-function.ts create mode 100644 dist/test/converter/generic-function/specs.json create mode 100644 dist/test/converter/getter-setter/getter-setter.ts create mode 100644 dist/test/converter/getter-setter/specs.json create mode 100644 dist/test/converter/implicit-types/implicit-types.ts create mode 100644 dist/test/converter/implicit-types/specs.json create mode 100644 dist/test/converter/interface-empty/interface-empty.ts create mode 100644 dist/test/converter/interface-empty/specs.json create mode 100644 dist/test/converter/interface-implementation/interface-implementation.ts create mode 100644 dist/test/converter/interface-implementation/specs.json create mode 100644 dist/test/converter/literal-object-callbacks/literal-object-callbacks.ts create mode 100644 dist/test/converter/literal-object-callbacks/specs.json create mode 100644 dist/test/converter/literal-object/literal-object.ts create mode 100644 dist/test/converter/literal-object/specs.json create mode 100644 dist/test/converter/literal-type/literal-type.ts create mode 100644 dist/test/converter/literal-type/specs.json create mode 100644 dist/test/converter/react/react.d.ts create mode 100644 dist/test/converter/react/react.tsx create mode 100644 dist/test/converter/react/specs.json create mode 100644 dist/test/converter/this/specs.json create mode 100644 dist/test/converter/this/this.ts create mode 100644 dist/test/converter/type-operator/specs.json create mode 100644 dist/test/converter/type-operator/type-operator.ts create mode 100644 dist/test/converter/union-or-intersection/specs.json create mode 100644 dist/test/converter/union-or-intersection/union-or-intersection.ts create mode 100644 dist/test/converter/variable/specs.json create mode 100644 dist/test/converter/variable/variable.ts create mode 100644 dist/test/events.d.ts create mode 100644 dist/test/events.js create mode 100644 dist/test/events.js.map create mode 100644 dist/test/plugin-host.d.ts create mode 100644 dist/test/plugin-host.js create mode 100644 dist/test/plugin-host.js.map create mode 100644 dist/test/renderer.d.ts create mode 100644 dist/test/renderer.js create mode 100644 dist/test/renderer.js.map create mode 100644 dist/test/renderer/specs/classes/_access_.privateclass.html create mode 100644 dist/test/renderer/specs/classes/_classes_.baseclass.html create mode 100644 dist/test/renderer/specs/classes/_classes_.genericclass.html create mode 100644 dist/test/renderer/specs/classes/_classes_.internalclass.html create mode 100644 dist/test/renderer/specs/classes/_classes_.nongenericclass.html create mode 100644 dist/test/renderer/specs/classes/_classes_.subclassa.html create mode 100644 dist/test/renderer/specs/classes/_classes_.subclassb.html create mode 100644 dist/test/renderer/specs/classes/_default_export_.defaultexportedclass.html create mode 100644 dist/test/renderer/specs/classes/_default_export_.notexportedclassname.html create mode 100644 dist/test/renderer/specs/classes/_flattened_.flattenedclass.html create mode 100644 dist/test/renderer/specs/classes/_single_export_.notexportedclass.html create mode 100644 dist/test/renderer/specs/classes/_single_export_.singleexportedclass.html create mode 100644 dist/test/renderer/specs/classes/_typescript_1_3_.classwithprotectedmembers.html create mode 100644 dist/test/renderer/specs/classes/_typescript_1_3_.subclasswithprotectedmembers.html create mode 100644 dist/test/renderer/specs/classes/_typescript_1_4_.simpleclass.html create mode 100644 dist/test/renderer/specs/enums/_enumerations_.directions.html create mode 100644 dist/test/renderer/specs/enums/_enumerations_.size.html create mode 100644 dist/test/renderer/specs/globals.html create mode 100644 dist/test/renderer/specs/index.html create mode 100644 dist/test/renderer/specs/interfaces/_classes_.inameinterface.html create mode 100644 dist/test/renderer/specs/interfaces/_classes_.iprintinterface.html create mode 100644 dist/test/renderer/specs/interfaces/_classes_.iprintnameinterface.html create mode 100644 dist/test/renderer/specs/interfaces/_generics_.a.html create mode 100644 dist/test/renderer/specs/interfaces/_generics_.ab.html create mode 100644 dist/test/renderer/specs/interfaces/_generics_.abnumber.html create mode 100644 dist/test/renderer/specs/interfaces/_generics_.abstring.html create mode 100644 dist/test/renderer/specs/interfaces/_generics_.b.html create mode 100644 dist/test/renderer/specs/interfaces/_typescript_1_4_.runoptions.html create mode 100644 dist/test/renderer/specs/modules/_access_.html create mode 100644 dist/test/renderer/specs/modules/_access_.privatemodule.html create mode 100644 dist/test/renderer/specs/modules/_classes_.html create mode 100644 dist/test/renderer/specs/modules/_default_export_.html create mode 100644 dist/test/renderer/specs/modules/_enumerations_.html create mode 100644 dist/test/renderer/specs/modules/_flattened_.html create mode 100644 dist/test/renderer/specs/modules/_functions_.html create mode 100644 dist/test/renderer/specs/modules/_functions_.modulefunction.html create mode 100644 dist/test/renderer/specs/modules/_generics_.html create mode 100644 dist/test/renderer/specs/modules/_modules_.html create mode 100644 dist/test/renderer/specs/modules/_modules_.mymodule.html create mode 100644 dist/test/renderer/specs/modules/_modules_.mymodule.mysubmodule.html create mode 100644 dist/test/renderer/specs/modules/_single_export_.html create mode 100644 dist/test/renderer/specs/modules/_typescript_1_3_.html create mode 100644 dist/test/renderer/specs/modules/_typescript_1_4_.html create mode 100644 dist/test/renderer/specs/modules/_typescript_1_5_.html create mode 100644 dist/test/renderer/specs/modules/_variables_.html create mode 100644 dist/test/typedoc.d.ts create mode 100644 dist/test/typedoc.js create mode 100644 dist/test/typedoc.js.map diff --git a/.gitignore b/.gitignore index 111a198ac..ee5387a1f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,3 @@ yarn.lock /node_modules/ /typescript/ /coverage/ -/dist/ diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 000000000..cea611877 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,11 @@ +export { Application } from './lib/application'; +export { CliApplication } from './lib/cli'; +export { EventDispatcher, Event } from './lib/utils/events'; +export { resetReflectionID } from './lib/models/reflections/abstract'; +export { normalizePath } from './lib/utils/fs'; +export * from './lib/models/reflections'; +export * from './lib/output/plugins'; +export { Renderer } from './lib/output/renderer'; +export { DefaultTheme } from './lib/output/themes/DefaultTheme'; +export { NavigationItem } from './lib/output/models/NavigationItem'; +export { UrlMapping } from './lib/output/models/UrlMapping'; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 000000000..f56668137 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,27 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +var application_1 = require("./lib/application"); +exports.Application = application_1.Application; +var cli_1 = require("./lib/cli"); +exports.CliApplication = cli_1.CliApplication; +var events_1 = require("./lib/utils/events"); +exports.EventDispatcher = events_1.EventDispatcher; +exports.Event = events_1.Event; +var abstract_1 = require("./lib/models/reflections/abstract"); +exports.resetReflectionID = abstract_1.resetReflectionID; +var fs_1 = require("./lib/utils/fs"); +exports.normalizePath = fs_1.normalizePath; +__export(require("./lib/models/reflections")); +__export(require("./lib/output/plugins")); +var renderer_1 = require("./lib/output/renderer"); +exports.Renderer = renderer_1.Renderer; +var DefaultTheme_1 = require("./lib/output/themes/DefaultTheme"); +exports.DefaultTheme = DefaultTheme_1.DefaultTheme; +var NavigationItem_1 = require("./lib/output/models/NavigationItem"); +exports.NavigationItem = NavigationItem_1.NavigationItem; +var UrlMapping_1 = require("./lib/output/models/UrlMapping"); +exports.UrlMapping = UrlMapping_1.UrlMapping; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 000000000..096fcc1e3 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,iDAAgD;AAAvC,oCAAA,WAAW,CAAA;AACpB,iCAA2C;AAAlC,+BAAA,cAAc,CAAA;AAEvB,6CAA4D;AAAnD,mCAAA,eAAe,CAAA;AAAE,yBAAA,KAAK,CAAA;AAC/B,8DAAsE;AAA7D,uCAAA,iBAAiB,CAAA;AAC1B,qCAA+C;AAAtC,6BAAA,aAAa,CAAA;AACtB,8CAAyC;AACzC,0CAAqC;AACrC,kDAAiD;AAAxC,8BAAA,QAAQ,CAAA;AACjB,iEAAgE;AAAvD,sCAAA,YAAY,CAAA;AACrB,qEAAoE;AAA3D,0CAAA,cAAc,CAAA;AACvB,6DAA4D;AAAnD,kCAAA,UAAU,CAAA","sourcesContent":["export { Application } from './lib/application';\nexport { CliApplication } from './lib/cli';\n\nexport { EventDispatcher, Event } from './lib/utils/events';\nexport { resetReflectionID } from './lib/models/reflections/abstract';\nexport { normalizePath } from './lib/utils/fs';\nexport * from './lib/models/reflections';\nexport * from './lib/output/plugins';\nexport { Renderer } from './lib/output/renderer';\nexport { DefaultTheme } from './lib/output/themes/DefaultTheme';\nexport { NavigationItem } from './lib/output/models/NavigationItem';\nexport { UrlMapping } from './lib/output/models/UrlMapping';\n"]} \ No newline at end of file diff --git a/dist/lib/application.d.ts b/dist/lib/application.d.ts new file mode 100644 index 000000000..b5155b2cd --- /dev/null +++ b/dist/lib/application.d.ts @@ -0,0 +1,32 @@ +import { Converter } from './converter/index'; +import { Renderer } from './output/renderer'; +import { Serializer } from './serialization'; +import { ProjectReflection } from './models/index'; +import { Logger, PluginHost } from './utils/index'; +import { AbstractComponent, ChildableComponent } from './utils/component'; +import { Options, OptionsReadResult } from './utils/options/index'; +export declare class Application extends ChildableComponent> { + options: Options; + converter: Converter; + renderer: Renderer; + serializer: Serializer; + logger: Logger; + plugins: PluginHost; + loggerType: string | Function; + ignoreCompilerErrors: boolean; + exclude: Array; + static VERSION: string; + constructor(options?: Object); + protected bootstrap(options?: Object): OptionsReadResult; + readonly application: Application; + readonly isCLI: boolean; + getTypeScriptPath(): string; + getTypeScriptVersion(): string; + convert(src: string[]): ProjectReflection; + generateDocs(src: string[], out: string): boolean; + generateDocs(project: ProjectReflection, out: string): boolean; + generateJson(src: string[], out: string): boolean; + generateJson(project: ProjectReflection, out: string): boolean; + expandInputFiles(inputFiles?: string[]): string[]; + toString(): string; +} diff --git a/dist/lib/application.js b/dist/lib/application.js new file mode 100644 index 000000000..771e560c7 --- /dev/null +++ b/dist/lib/application.js @@ -0,0 +1,192 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var FS = require("fs"); +var typescript = require("typescript"); +var minimatch_1 = require("minimatch"); +var index_1 = require("./converter/index"); +var renderer_1 = require("./output/renderer"); +var serialization_1 = require("./serialization"); +var index_2 = require("./models/index"); +var index_3 = require("./utils/index"); +var component_1 = require("./utils/component"); +var index_4 = require("./utils/options/index"); +var declaration_1 = require("./utils/options/declaration"); +var Application = (function (_super) { + __extends(Application, _super); + function Application(options) { + var _this = _super.call(this, null) || this; + _this.logger = new index_3.ConsoleLogger(); + _this.converter = _this.addComponent('converter', index_1.Converter); + _this.serializer = _this.addComponent('serializer', serialization_1.Serializer); + _this.renderer = _this.addComponent('renderer', renderer_1.Renderer); + _this.plugins = _this.addComponent('plugins', index_3.PluginHost); + _this.options = _this.addComponent('options', index_4.Options); + _this.bootstrap(options); + return _this; + } + Application_1 = Application; + Application.prototype.bootstrap = function (options) { + this.options.read(options, index_4.OptionsReadMode.Prefetch); + var logger = this.loggerType; + if (typeof logger === 'function') { + this.logger = new index_3.CallbackLogger(logger); + } + else if (logger === 'none') { + this.logger = new index_3.Logger(); + } + this.plugins.load(); + return this.options.read(options, index_4.OptionsReadMode.Fetch); + }; + Object.defineProperty(Application.prototype, "application", { + get: function () { + return this; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Application.prototype, "isCLI", { + get: function () { + return false; + }, + enumerable: true, + configurable: true + }); + Application.prototype.getTypeScriptPath = function () { + return Path.dirname(require.resolve('typescript')); + }; + Application.prototype.getTypeScriptVersion = function () { + var tsPath = this.getTypeScriptPath(); + var json = JSON.parse(FS.readFileSync(Path.join(tsPath, '..', 'package.json'), 'utf8')); + return json.version; + }; + Application.prototype.convert = function (src) { + this.logger.writeln('Using TypeScript %s from %s', this.getTypeScriptVersion(), this.getTypeScriptPath()); + var result = this.converter.convert(src); + if (result.errors && result.errors.length) { + this.logger.diagnostics(result.errors); + if (this.ignoreCompilerErrors) { + this.logger.resetErrors(); + return result.project; + } + else { + return null; + } + } + else { + return result.project; + } + }; + Application.prototype.generateDocs = function (input, out) { + var project = input instanceof index_2.ProjectReflection ? input : this.convert(input); + if (!project) { + return false; + } + out = Path.resolve(out); + this.renderer.render(project, out); + if (this.logger.hasErrors()) { + this.logger.error('Documentation could not be generated due to the errors above.'); + } + else { + this.logger.success('Documentation generated at %s', out); + } + return true; + }; + Application.prototype.generateJson = function (input, out) { + var project = input instanceof index_2.ProjectReflection ? input : this.convert(input); + if (!project) { + return false; + } + out = Path.resolve(out); + var eventData = { outputDirectory: Path.dirname(out), outputFile: Path.basename(out) }; + var ser = this.serializer.projectToObject(project, { begin: eventData, end: eventData }); + index_3.writeFile(out, JSON.stringify(ser, null, '\t'), false); + this.logger.success('JSON written to %s', out); + return true; + }; + Application.prototype.expandInputFiles = function (inputFiles) { + var files = []; + var exclude = this.exclude ? this.exclude.map(function (pattern) { return new minimatch_1.Minimatch(pattern); }) : []; + function isExcluded(fileName) { + return exclude.some(function (mm) { return mm.match(fileName); }); + } + function add(dirname) { + FS.readdirSync(dirname).forEach(function (file) { + var realpath = Path.join(dirname, file); + if (FS.statSync(realpath).isDirectory()) { + add(realpath); + } + else if (/\.tsx?$/.test(realpath)) { + if (isExcluded(realpath.replace(/\\/g, '/'))) { + return; + } + files.push(realpath); + } + }); + } + inputFiles.forEach(function (file) { + file = Path.resolve(file); + if (FS.statSync(file).isDirectory()) { + add(file); + } + else if (!isExcluded(file)) { + files.push(file); + } + }); + return files; + }; + Application.prototype.toString = function () { + return [ + '', + 'TypeDoc ' + Application_1.VERSION, + 'Using TypeScript ' + this.getTypeScriptVersion() + ' from ' + this.getTypeScriptPath(), + '' + ].join(typescript.sys.newLine); + }; + Application.VERSION = '0.10.0'; + __decorate([ + component_1.Option({ + name: 'logger', + help: 'Specify the logger that should be used, \'none\' or \'console\'', + defaultValue: 'console', + type: declaration_1.ParameterType.Mixed + }) + ], Application.prototype, "loggerType", void 0); + __decorate([ + component_1.Option({ + name: 'ignoreCompilerErrors', + help: 'Should TypeDoc generate documentation pages even after the compiler has returned errors?', + type: declaration_1.ParameterType.Boolean + }) + ], Application.prototype, "ignoreCompilerErrors", void 0); + __decorate([ + component_1.Option({ + name: 'exclude', + help: 'Define patterns for excluded files when specifying paths.', + type: declaration_1.ParameterType.Array + }) + ], Application.prototype, "exclude", void 0); + Application = Application_1 = __decorate([ + component_1.Component({ name: 'application', internal: true }) + ], Application); + return Application; + var Application_1; +}(component_1.ChildableComponent)); +exports.Application = Application; +//# sourceMappingURL=application.js.map \ No newline at end of file diff --git a/dist/lib/application.js.map b/dist/lib/application.js.map new file mode 100644 index 000000000..3d6958ef6 --- /dev/null +++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AE;YACvF,EAAE;SACL,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IA7MM,mBAAO,GAAG,eAAe,CAAC;IAnBjC;QANC,kBAAM,CAAC;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,iEAAiE;YACvE,YAAY,EAAE,SAAS;YACvB,IAAI,EAAE,2BAAa,CAAC,KAAK;SAC5B,CAAC;mDAC0B;IAO5B;QALC,kBAAM,CAAC;YACJ,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,0FAA0F;YAChG,IAAI,EAAE,2BAAa,CAAC,OAAO;SAC9B,CAAC;6DAC4B;IAO9B;QALC,kBAAM,CAAC;YACJ,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,2DAA2D;YACjE,IAAI,EAAE,2BAAa,CAAC,KAAK;SAC5B,CAAC;gDACqB;IA7Cd,WAAW;QADvB,qBAAS,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;OACpC,WAAW,CAgQvB;IAAD,kBAAC;;CAAA,AAhQD,CAAiC,8BAAkB,GAgQlD;AAhQY,kCAAW","sourcesContent":["/**\n * The TypeDoc main module and namespace.\n *\n * The [[Application]] class holds the core logic of the cli application. All code related\n * to resolving reflections is stored in [[TypeDoc.Factories]], the actual data models can be found\n * in [[TypeDoc.Models]] and the final rendering is defined in [[TypeDoc.Output]].\n */\n\nimport * as Path from 'path';\nimport * as FS from 'fs';\nimport * as typescript from 'typescript';\nimport { Minimatch, IMinimatch } from 'minimatch';\n\nimport { Converter } from './converter/index';\nimport { Renderer } from './output/renderer';\nimport { Serializer } from './serialization';\nimport { ProjectReflection } from './models/index';\nimport { Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile } from './utils/index';\n\nimport { AbstractComponent, ChildableComponent, Component, Option } from './utils/component';\nimport { Options, OptionsReadMode, OptionsReadResult } from './utils/options/index';\nimport { ParameterType } from './utils/options/declaration';\n\n/**\n * The default TypeDoc main application class.\n *\n * This class holds the two main components of TypeDoc, the [[Dispatcher]] and\n * the [[Renderer]]. When running TypeDoc, first the [[Dispatcher]] is invoked which\n * generates a [[ProjectReflection]] from the passed in source files. The\n * [[ProjectReflection]] is a hierarchical model representation of the TypeScript\n * project. Afterwards the model is passed to the [[Renderer]] which uses an instance\n * of [[BaseTheme]] to generate the final documentation.\n *\n * Both the [[Dispatcher]] and the [[Renderer]] are subclasses of the [[EventDispatcher]]\n * and emit a series of events while processing the project. Subscribe to these Events\n * to control the application flow or alter the output.\n */\n@Component({name: 'application', internal: true})\nexport class Application extends ChildableComponent> {\n options: Options;\n\n /**\n * The converter used to create the declaration reflections.\n */\n converter: Converter;\n\n /**\n * The renderer used to generate the documentation output.\n */\n renderer: Renderer;\n\n /**\n * The serializer used to generate JSON output.\n */\n serializer: Serializer;\n\n /**\n * The logger that should be used to output messages.\n */\n logger: Logger;\n\n plugins: PluginHost;\n\n @Option({\n name: 'logger',\n help: 'Specify the logger that should be used, \\'none\\' or \\'console\\'',\n defaultValue: 'console',\n type: ParameterType.Mixed\n })\n loggerType: string|Function;\n\n @Option({\n name: 'ignoreCompilerErrors',\n help: 'Should TypeDoc generate documentation pages even after the compiler has returned errors?',\n type: ParameterType.Boolean\n })\n ignoreCompilerErrors: boolean;\n\n @Option({\n name: 'exclude',\n help: 'Define patterns for excluded files when specifying paths.',\n type: ParameterType.Array\n })\n exclude: Array;\n\n /**\n * The version number of TypeDoc.\n */\n static VERSION = '{{ VERSION }}';\n\n /**\n * Create a new TypeDoc application instance.\n *\n * @param options An object containing the options that should be used.\n */\n constructor(options?: Object) {\n super(null);\n\n this.logger = new ConsoleLogger();\n this.converter = this.addComponent('converter', Converter);\n this.serializer = this.addComponent('serializer', Serializer);\n this.renderer = this.addComponent('renderer', Renderer);\n this.plugins = this.addComponent('plugins', PluginHost);\n this.options = this.addComponent('options', Options);\n\n this.bootstrap(options);\n }\n\n /**\n * Initialize TypeDoc with the given options object.\n *\n * @param options The desired options to set.\n */\n protected bootstrap(options?: Object): OptionsReadResult {\n this.options.read(options, OptionsReadMode.Prefetch);\n\n const logger = this.loggerType;\n if (typeof logger === 'function') {\n this.logger = new CallbackLogger( logger);\n } else if (logger === 'none') {\n this.logger = new Logger();\n }\n\n this.plugins.load();\n return this.options.read(options, OptionsReadMode.Fetch);\n }\n\n /**\n * Return the application / root component instance.\n */\n get application(): Application {\n return this;\n }\n\n get isCLI(): boolean {\n return false;\n }\n\n /**\n * Return the path to the TypeScript compiler.\n */\n public getTypeScriptPath(): string {\n return Path.dirname(require.resolve('typescript'));\n }\n\n public getTypeScriptVersion(): string {\n const tsPath = this.getTypeScriptPath();\n const json = JSON.parse(FS.readFileSync(Path.join(tsPath, '..', 'package.json'), 'utf8'));\n return json.version;\n }\n\n /**\n * Run the converter for the given set of files and return the generated reflections.\n *\n * @param src A list of source that should be compiled and converted.\n * @returns An instance of ProjectReflection on success, NULL otherwise.\n */\n public convert(src: string[]): ProjectReflection {\n this.logger.writeln('Using TypeScript %s from %s', this.getTypeScriptVersion(), this.getTypeScriptPath());\n\n const result = this.converter.convert(src);\n if (result.errors && result.errors.length) {\n this.logger.diagnostics(result.errors);\n if (this.ignoreCompilerErrors) {\n this.logger.resetErrors();\n return result.project;\n } else {\n return null;\n }\n } else {\n return result.project;\n }\n }\n\n /**\n * @param src A list of source files whose documentation should be generated.\n */\n public generateDocs(src: string[], out: string): boolean;\n\n /**\n * @param project The project the documentation should be generated for.\n */\n public generateDocs(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the documentation generator for the given set of files.\n *\n * @param out The path the documentation should be written to.\n * @returns TRUE if the documentation could be generated successfully, otherwise FALSE.\n */\n public generateDocs(input: any, out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n this.renderer.render(project, out);\n if (this.logger.hasErrors()) {\n this.logger.error('Documentation could not be generated due to the errors above.');\n } else {\n this.logger.success('Documentation generated at %s', out);\n }\n\n return true;\n }\n\n /**\n * @param src A list of source that should be compiled and converted.\n */\n public generateJson(src: string[], out: string): boolean;\n\n /**\n * @param project The project that should be converted.\n */\n public generateJson(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the converter for the given set of files and write the reflections to a json file.\n *\n * @param out The path and file name of the target file.\n * @returns TRUE if the json file could be written successfully, otherwise FALSE.\n */\n public generateJson(input: any, out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n const eventData = { outputDirectory: Path.dirname(out), outputFile: Path.basename(out) };\n const ser = this.serializer.projectToObject(project, { begin: eventData, end: eventData });\n writeFile(out, JSON.stringify(ser, null, '\\t'), false);\n this.logger.success('JSON written to %s', out);\n\n return true;\n }\n\n /**\n * Expand a list of input files.\n *\n * Searches for directories in the input files list and replaces them with a\n * listing of all TypeScript files within them. One may use the ```--exclude``` option\n * to filter out files with a pattern.\n *\n * @param inputFiles The list of files that should be expanded.\n * @returns The list of input files with expanded directories.\n */\n public expandInputFiles(inputFiles?: string[]): string[] {\n let files: string[] = [];\n const exclude: Array = this.exclude ? this.exclude.map(pattern => new Minimatch(pattern)) : [];\n\n function isExcluded(fileName: string): boolean {\n return exclude.some(mm => mm.match(fileName));\n }\n\n function add(dirname: string) {\n FS.readdirSync(dirname).forEach((file) => {\n const realpath = Path.join(dirname, file);\n if (FS.statSync(realpath).isDirectory()) {\n add(realpath);\n } else if (/\\.tsx?$/.test(realpath)) {\n if (isExcluded(realpath.replace(/\\\\/g, '/'))) {\n return;\n }\n\n files.push(realpath);\n }\n });\n }\n\n inputFiles.forEach((file) => {\n file = Path.resolve(file);\n if (FS.statSync(file).isDirectory()) {\n add(file);\n } else if (!isExcluded(file)) {\n files.push(file);\n }\n });\n\n return files;\n }\n\n /**\n * Print the version number.\n */\n public toString() {\n return [\n '',\n 'TypeDoc ' + Application.VERSION,\n 'Using TypeScript ' + this.getTypeScriptVersion() + ' from ' + this.getTypeScriptPath(),\n ''\n ].join(typescript.sys.newLine);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/cli.d.ts b/dist/lib/cli.d.ts new file mode 100644 index 000000000..ea9aec265 --- /dev/null +++ b/dist/lib/cli.d.ts @@ -0,0 +1,17 @@ +import { Application } from './application'; +import { OptionsReadResult } from './utils/options/options'; +export declare const enum ExitCode { + OptionError = 1, + NoInputFiles = 2, + NoOutput = 3, + CompileError = 4, + OutputError = 5, +} +export declare class CliApplication extends Application { + out: string; + json: string; + version: boolean; + help: boolean; + protected bootstrap(options?: Object): OptionsReadResult; + readonly isCLI: boolean; +} diff --git a/dist/lib/cli.js b/dist/lib/cli.js new file mode 100644 index 000000000..f9a1cb3a4 --- /dev/null +++ b/dist/lib/cli.js @@ -0,0 +1,117 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var typescript = require("typescript"); +var application_1 = require("./application"); +var component_1 = require("./utils/component"); +var declaration_1 = require("./utils/options/declaration"); +var help_1 = require("./utils/options/help"); +var ExitCode; +(function (ExitCode) { + ExitCode[ExitCode["OptionError"] = 1] = "OptionError"; + ExitCode[ExitCode["NoInputFiles"] = 2] = "NoInputFiles"; + ExitCode[ExitCode["NoOutput"] = 3] = "NoOutput"; + ExitCode[ExitCode["CompileError"] = 4] = "CompileError"; + ExitCode[ExitCode["OutputError"] = 5] = "OutputError"; +})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); +var CliApplication = (function (_super) { + __extends(CliApplication, _super); + function CliApplication() { + return _super !== null && _super.apply(this, arguments) || this; + } + CliApplication.prototype.bootstrap = function (options) { + var result = _super.prototype.bootstrap.call(this, options); + if (result.hasErrors) { + process.exit(1); + return; + } + if (this.version) { + typescript.sys.write(this.toString()); + } + else if (this.help) { + typescript.sys.write(help_1.getOptionsHelp(this.options)); + } + else if (result.inputFiles.length === 0) { + typescript.sys.write(help_1.getOptionsHelp(this.options)); + process.exit(2); + } + else if (!this.out && !this.json) { + this.logger.error("You must either specify the 'out' or 'json' option."); + process.exit(3); + } + else { + var src = this.expandInputFiles(result.inputFiles); + var project = this.convert(src); + if (project) { + if (this.out) { + this.generateDocs(project, this.out); + } + if (this.json) { + this.generateJson(project, this.json); + } + if (this.logger.hasErrors()) { + process.exit(5); + } + } + else { + process.exit(4); + } + } + return result; + }; + Object.defineProperty(CliApplication.prototype, "isCLI", { + get: function () { + return true; + }, + enumerable: true, + configurable: true + }); + __decorate([ + component_1.Option({ + name: 'out', + help: 'Specifies the location the documentation should be written to.', + hint: declaration_1.ParameterHint.Directory + }) + ], CliApplication.prototype, "out", void 0); + __decorate([ + component_1.Option({ + name: 'json', + help: 'Specifies the location and file name a json file describing the project is written to.', + hint: declaration_1.ParameterHint.File + }) + ], CliApplication.prototype, "json", void 0); + __decorate([ + component_1.Option({ + name: 'version', + short: 'v', + help: 'Print the TypeDoc\'s version.', + type: declaration_1.ParameterType.Boolean + }) + ], CliApplication.prototype, "version", void 0); + __decorate([ + component_1.Option({ + name: 'help', + short: 'h', + help: 'Print this message.', + type: declaration_1.ParameterType.Boolean + }) + ], CliApplication.prototype, "help", void 0); + return CliApplication; +}(application_1.Application)); +exports.CliApplication = CliApplication; +//# sourceMappingURL=cli.js.map \ No newline at end of file diff --git a/dist/lib/cli.js.map b/dist/lib/cli.js.map new file mode 100644 index 000000000..7c55cb6da --- /dev/null +++ b/dist/lib/cli.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/lib/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAyC;AAEzC,6CAA4C;AAC5C,+CAA2C;AAE3C,2DAA2E;AAC3E,6CAAsD;AAEtD,IAAkB,QAMjB;AAND,WAAkB,QAAQ;IACtB,qDAAgB,CAAA;IAChB,uDAAgB,CAAA;IAChB,+CAAgB,CAAA;IAChB,uDAAgB,CAAA;IAChB,qDAAgB,CAAA;AACpB,CAAC,EANiB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAMzB;AAED;IAAoC,kCAAW;IAA/C;;IA2EA,CAAC;IAzCa,kCAAS,GAAnB,UAAoB,OAAgB;QAChC,IAAM,MAAM,GAAG,iBAAM,SAAS,YAAC,OAAO,CAAC,CAAC;QACxC,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;YACnB,OAAO,CAAC,IAAI,GAAsB,CAAC;YACnC,MAAM,CAAC;QACX,CAAC;QAED,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACf,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1C,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACnB,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,qBAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACvD,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC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ED;QALC,kBAAM,CAAC;YACJ,IAAI,EAAG,KAAK;YACZ,IAAI,EAAG,gEAAgE;YACvE,IAAI,EAAG,2BAAa,CAAC,SAAS;SACjC,CAAC;+CACU;IAOZ;QALC,kBAAM,CAAC;YACJ,IAAI,EAAG,MAAM;YACb,IAAI,EAAG,wFAAwF;YAC/F,IAAI,EAAG,2BAAa,CAAC,IAAI;SAC5B,CAAC;gDACW;IAQb;QANC,kBAAM,CAAC;YACJ,IAAI,EAAG,SAAS;YAChB,KAAK,EAAE,GAAG;YACV,IAAI,EAAG,+BAA+B;YACtC,IAAI,EAAG,2BAAa,CAAC,OAAO;SAC/B,CAAC;mDACe;IAQjB;QANC,kBAAM,CAAC;YACJ,IAAI,EAAG,MAAM;YACb,KAAK,EAAE,GAAG;YACV,IAAI,EAAG,qBAAqB;YAC5B,IAAI,EAAG,2BAAa,CAAC,OAAO;SAC/B,CAAC;gDACY;IA8ClB,qBAAC;CAAA,AA3ED,CAAoC,yBAAW,GA2E9C;AA3EY,wCAAc","sourcesContent":["import * as typescript from 'typescript';\n\nimport { Application } from './application';\nimport { Option } from './utils/component';\nimport { OptionsReadResult } from './utils/options/options';\nimport { ParameterHint, ParameterType } from './utils/options/declaration';\nimport { getOptionsHelp } from './utils/options/help';\n\nexport const enum ExitCode {\n OptionError = 1,\n NoInputFiles = 2,\n NoOutput = 3,\n CompileError = 4,\n OutputError = 5\n}\n\nexport class CliApplication extends Application {\n @Option({\n name: 'out',\n help: 'Specifies the location the documentation should be written to.',\n hint: ParameterHint.Directory\n })\n out: string;\n\n @Option({\n name: 'json',\n help: 'Specifies the location and file name a json file describing the project is written to.',\n hint: ParameterHint.File\n })\n json: string;\n\n @Option({\n name: 'version',\n short: 'v',\n help: 'Print the TypeDoc\\'s version.',\n type: ParameterType.Boolean\n })\n version: boolean;\n\n @Option({\n name: 'help',\n short: 'h',\n help: 'Print this message.',\n type: ParameterType.Boolean\n })\n help: boolean;\n\n /**\n * Run TypeDoc from the command line.\n */\n protected bootstrap(options?: Object): OptionsReadResult {\n const result = super.bootstrap(options);\n if (result.hasErrors) {\n process.exit(ExitCode.OptionError);\n return;\n }\n\n if (this.version) {\n typescript.sys.write(this.toString());\n } else if (this.help) {\n typescript.sys.write(getOptionsHelp(this.options));\n } else if (result.inputFiles.length === 0) {\n typescript.sys.write(getOptionsHelp(this.options));\n process.exit(ExitCode.NoInputFiles);\n } else if (!this.out && !this.json) {\n this.logger.error(\"You must either specify the 'out' or 'json' option.\");\n process.exit(ExitCode.NoOutput);\n } else {\n const src = this.expandInputFiles(result.inputFiles);\n const project = this.convert(src);\n if (project) {\n if (this.out) {\n this.generateDocs(project, this.out);\n }\n if (this.json) {\n this.generateJson(project, this.json);\n }\n if (this.logger.hasErrors()) {\n process.exit(ExitCode.OutputError);\n }\n } else {\n process.exit(ExitCode.CompileError);\n }\n }\n\n return result;\n }\n\n get isCLI(): boolean {\n return true;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/components.d.ts b/dist/lib/converter/components.d.ts new file mode 100644 index 000000000..b8fa13aff --- /dev/null +++ b/dist/lib/converter/components.d.ts @@ -0,0 +1,26 @@ +import * as ts from 'typescript'; +import { Component, AbstractComponent } from '../utils/component'; +import { Reflection } from '../models/reflections/abstract'; +import { Type } from '../models/types/abstract'; +import { Context } from './context'; +import { Converter } from './converter'; +export { Component }; +export declare abstract class ConverterComponent extends AbstractComponent { +} +export declare abstract class ConverterNodeComponent extends ConverterComponent { + supports: ts.SyntaxKind[]; + abstract convert(context: Context, node: T): Reflection; +} +export declare abstract class ConverterTypeComponent extends ConverterComponent { + priority: number; +} +export interface TypeConverter extends ConverterTypeComponent, TypeTypeConverter, TypeNodeConverter { +} +export interface TypeTypeConverter extends ConverterTypeComponent { + supportsType(context: Context, type: T): boolean; + convertType(context: Context, type: T): Type; +} +export interface TypeNodeConverter extends ConverterTypeComponent { + supportsNode(context: Context, node: N, type: T): boolean; + convertNode(context: Context, node: N, type: T): Type; +} diff --git a/dist/lib/converter/components.js b/dist/lib/converter/components.js new file mode 100644 index 000000000..fb03478dc --- /dev/null +++ b/dist/lib/converter/components.js @@ -0,0 +1,41 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var component_1 = require("../utils/component"); +exports.Component = component_1.Component; +var ConverterComponent = (function (_super) { + __extends(ConverterComponent, _super); + function ConverterComponent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return ConverterComponent; +}(component_1.AbstractComponent)); +exports.ConverterComponent = ConverterComponent; +var ConverterNodeComponent = (function (_super) { + __extends(ConverterNodeComponent, _super); + function ConverterNodeComponent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return ConverterNodeComponent; +}(ConverterComponent)); +exports.ConverterNodeComponent = ConverterNodeComponent; +var ConverterTypeComponent = (function (_super) { + __extends(ConverterTypeComponent, _super); + function ConverterTypeComponent() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.priority = 0; + return _this; + } + return ConverterTypeComponent; +}(ConverterComponent)); +exports.ConverterTypeComponent = ConverterTypeComponent; +//# sourceMappingURL=components.js.map \ No newline at end of file diff --git a/dist/lib/converter/components.js.map b/dist/lib/converter/components.js.map new file mode 100644 index 000000000..4fc8222b8 --- /dev/null +++ b/dist/lib/converter/components.js.map @@ -0,0 +1 @@ +{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/lib/converter/components.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,gDAAkE;AAM1D,oBANC,qBAAS,CAMD;AAEjB;IAAiD,sCAA4B;IAA7E;;IAAgF,CAAC;IAAD,yBAAC;AAAD,CAAC,AAAjF,CAAiD,6BAAiB,GAAe;AAA3D,gDAAkB;AAExC;IAAwE,0CAAkB;IAA1F;;IAOA,CAAC;IAAD,6BAAC;AAAD,CAAC,AAPD,CAAwE,kBAAkB,GAOzF;AAPqB,wDAAsB;AAS5C;IAAqD,0CAAkB;IAAvE;QAAA,qEAMC;QADG,cAAQ,GAAG,CAAC,CAAC;;IACjB,CAAC;IAAD,6BAAC;AAAD,CAAC,AAND,CAAqD,kBAAkB,GAMtE;AANqB,wDAAsB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Component, AbstractComponent } from '../utils/component';\nimport { Reflection } from '../models/reflections/abstract';\nimport { Type } from '../models/types/abstract';\nimport { Context } from './context';\nimport { Converter } from './converter';\n\nexport {Component};\n\nexport abstract class ConverterComponent extends AbstractComponent { }\n\nexport abstract class ConverterNodeComponent extends ConverterComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[];\n\n abstract convert(context: Context, node: T): Reflection;\n}\n\nexport abstract class ConverterTypeComponent extends ConverterComponent {\n /**\n * The priority this converter should be executed with.\n * A higher priority means the converter will be applied earlier.\n */\n priority = 0;\n}\n\nexport interface TypeConverter\n extends ConverterTypeComponent, TypeTypeConverter, TypeNodeConverter {}\n\nexport interface TypeTypeConverter extends ConverterTypeComponent {\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: T): boolean;\n\n /**\n * Convert the given type to its type reflection.\n */\n convertType(context: Context, type: T): Type;\n}\n\nexport interface TypeNodeConverter extends ConverterTypeComponent {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: N, type: T): boolean;\n\n /**\n * Convert the given type node to its type reflection.\n */\n convertNode(context: Context, node: N, type: T): Type;\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/context.d.ts b/dist/lib/converter/context.d.ts new file mode 100644 index 000000000..836ba1b96 --- /dev/null +++ b/dist/lib/converter/context.d.ts @@ -0,0 +1,36 @@ +import * as ts from 'typescript'; +import { Logger } from '../utils/loggers'; +import { Reflection, ProjectReflection, Type } from '../models/index'; +import { Converter } from './converter'; +export declare class Context { + converter: Converter; + fileNames: string[]; + checker: ts.TypeChecker; + program: ts.Program; + project: ProjectReflection; + scope: Reflection; + isExternal: boolean; + isDeclaration: boolean; + typeParameters: ts.MapLike; + typeArguments: Type[]; + isInherit: boolean; + inheritParent: ts.Node; + inheritedChildren: number[]; + inherited: string[]; + visitStack: ts.Node[]; + private symbolID; + private externalPattern; + constructor(converter: Converter, fileNames: string[], checker: ts.TypeChecker, program: ts.Program); + getCompilerOptions(): ts.CompilerOptions; + getTypeAtLocation(node: ts.Node): ts.Type; + getLogger(): Logger; + getSymbolID(symbol: ts.Symbol): number; + registerReflection(reflection: Reflection, node: ts.Node, symbol?: ts.Symbol): void; + trigger(name: string, reflection: Reflection, node?: ts.Node): void; + withSourceFile(node: ts.SourceFile, callback: Function): void; + withScope(scope: Reflection, callback: Function): void; + withScope(scope: Reflection, parameters: ts.NodeArray, callback: Function): void; + withScope(scope: Reflection, parameters: ts.NodeArray, preserve: boolean, callback: Function): void; + inherit(baseNode: ts.Node, typeArguments?: ts.NodeArray): Reflection; + private extractTypeParameters(parameters, preserve?); +} diff --git a/dist/lib/converter/context.js b/dist/lib/converter/context.js new file mode 100644 index 000000000..d5a848072 --- /dev/null +++ b/dist/lib/converter/context.js @@ -0,0 +1,182 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var minimatch_1 = require("minimatch"); +var index_1 = require("../models/index"); +var type_parameter_1 = require("./factories/type-parameter"); +var converter_1 = require("./converter"); +var Context = (function () { + function Context(converter, fileNames, checker, program) { + this.symbolID = -1024; + this.converter = converter; + this.fileNames = fileNames; + this.checker = checker; + this.program = program; + this.visitStack = []; + var project = new index_1.ProjectReflection(converter.name); + this.project = project; + this.scope = project; + if (converter.externalPattern) { + this.externalPattern = new minimatch_1.Minimatch(converter.externalPattern); + } + } + Context.prototype.getCompilerOptions = function () { + return this.converter.application.options.getCompilerOptions(); + }; + Context.prototype.getTypeAtLocation = function (node) { + var nodeType; + try { + nodeType = this.checker.getTypeAtLocation(node); + } + catch (error) { + } + if (!nodeType) { + if (node.symbol) { + nodeType = this.checker.getDeclaredTypeOfSymbol(node.symbol); + } + else if (node.parent && node.parent.symbol) { + nodeType = this.checker.getDeclaredTypeOfSymbol(node.parent.symbol); + } + else if (node.parent && node.parent.parent && node.parent.parent.symbol) { + nodeType = this.checker.getDeclaredTypeOfSymbol(node.parent.parent.symbol); + } + } + return nodeType; + }; + Context.prototype.getLogger = function () { + return this.converter.application.logger; + }; + Context.prototype.getSymbolID = function (symbol) { + if (!symbol) { + return null; + } + if (!symbol.id) { + symbol.id = this.symbolID--; + } + return symbol.id; + }; + Context.prototype.registerReflection = function (reflection, node, symbol) { + this.project.reflections[reflection.id] = reflection; + var id = this.getSymbolID(symbol ? symbol : (node ? node.symbol : null)); + if (!this.isInherit && id && !this.project.symbolMapping[id]) { + this.project.symbolMapping[id] = reflection.id; + } + }; + Context.prototype.trigger = function (name, reflection, node) { + this.converter.trigger(name, this, reflection, node); + }; + Context.prototype.withSourceFile = function (node, callback) { + var externalPattern = this.externalPattern; + var isExternal = this.fileNames.indexOf(node.fileName) === -1; + if (externalPattern) { + isExternal = isExternal || externalPattern.match(node.fileName); + } + if (isExternal && this.converter.excludeExternals) { + return; + } + var isDeclaration = node.isDeclarationFile; + if (isDeclaration) { + var lib = this.converter.getDefaultLib(); + var isLib = node.fileName.substr(-lib.length) === lib; + if (!this.converter.includeDeclarations || isLib) { + return; + } + } + this.isExternal = isExternal; + this.isDeclaration = isDeclaration; + this.trigger(converter_1.Converter.EVENT_FILE_BEGIN, this.project, node); + callback(); + this.isExternal = false; + this.isDeclaration = false; + }; + Context.prototype.withScope = function (scope) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + if (!scope || !args.length) { + return; + } + var callback = args.pop(); + var parameters = args.shift(); + var oldScope = this.scope; + var oldTypeArguments = this.typeArguments; + var oldTypeParameters = this.typeParameters; + this.scope = scope; + this.typeParameters = parameters ? this.extractTypeParameters(parameters, args.length > 0) : this.typeParameters; + this.typeArguments = null; + callback(); + this.scope = oldScope; + this.typeParameters = oldTypeParameters; + this.typeArguments = oldTypeArguments; + }; + Context.prototype.inherit = function (baseNode, typeArguments) { + var _this = this; + var wasInherit = this.isInherit; + var oldInherited = this.inherited; + var oldInheritParent = this.inheritParent; + var oldTypeArguments = this.typeArguments; + this.isInherit = true; + this.inheritParent = baseNode; + this.inherited = []; + var target = this.scope; + if (!(target instanceof index_1.ContainerReflection)) { + throw new Error('Expected container reflection'); + } + if (baseNode.symbol) { + var id = this.getSymbolID(baseNode.symbol); + if (this.inheritedChildren && this.inheritedChildren.indexOf(id) !== -1) { + return target; + } + else { + this.inheritedChildren = this.inheritedChildren || []; + this.inheritedChildren.push(id); + } + } + if (target.children) { + this.inherited = target.children.map(function (c) { return c.name; }); + } + else { + this.inherited = []; + } + if (typeArguments) { + this.typeArguments = typeArguments.map(function (t) { return _this.converter.convertType(_this, t); }); + } + else { + this.typeArguments = null; + } + this.converter.convertNode(this, baseNode); + this.isInherit = wasInherit; + this.inherited = oldInherited; + this.inheritParent = oldInheritParent; + this.typeArguments = oldTypeArguments; + if (!this.isInherit) { + delete this.inheritedChildren; + } + return target; + }; + Context.prototype.extractTypeParameters = function (parameters, preserve) { + var _this = this; + var typeParameters = {}; + if (preserve) { + for (var key in this.typeParameters) { + if (!this.typeParameters.hasOwnProperty(key)) { + continue; + } + typeParameters[key] = this.typeParameters[key]; + } + } + parameters.forEach(function (declaration, index) { + var name = declaration.symbol.name; + if (_this.typeArguments && _this.typeArguments[index]) { + typeParameters[name] = _this.typeArguments[index]; + } + else { + typeParameters[name] = type_parameter_1.createTypeParameter(_this, declaration); + } + }); + return typeParameters; + }; + return Context; +}()); +exports.Context = Context; +//# sourceMappingURL=context.js.map \ No newline at end of file diff --git a/dist/lib/converter/context.js.map b/dist/lib/converter/context.js.map new file mode 100644 index 000000000..0de551288 --- /dev/null +++ b/dist/lib/converter/context.js.map @@ -0,0 +1 @@ +{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/lib/converter/context.ts"],"names":[],"mappings":";;AACA,uCAAkD;AAGlD,yCAA2F;AAC3F,6DAAiE;AACjE,yCAAwC;AAKxC;IA6FI,iBAAY,SAAoB,EAAE,SAAmB,EAAE,OAAuB,EAAE,OAAmB;QAd3F,aAAQ,GAAG,CAAC,IAAI,CAAC;QAerB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAErB,IAAM,OAAO,GAAG,IAAI,yBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QAErB,EAAE,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;YAC5B,IAAI,CAAC,eAAe,GAAG,IAAI,qBAAS,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QACpE,CAAC;IACL,CAAC;IAKD,oCAAkB,GAAlB;QACI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;IACnE,CAAC;IAQD,mCAAiB,GAAjB,UAAkB,IAAa;QAC3B,IAAI,QAAiB,CAAC;QACtB,IAAI,CAAC;YACD,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;QAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACjB,CAAC;QACD,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC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E,CAAC;QAE5C,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACX,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;gBAClC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAC3C,QAAQ,CAAC;gBACb,CAAC;gBACD,cAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YACnD,CAAC;QACL,CAAC;QAED,UAAU,CAAC,OAAO,CAAC,UAAC,WAAwC,EAAE,KAAa;YACvE,IAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;YACrC,EAAE,CAAC,CAAC,KAAI,CAAC,aAAa,IAAI,KAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAClD,cAAc,CAAC,IAAI,CAAC,GAAG,KAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACrD,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,cAAc,CAAC,IAAI,CAAC,GAAG,oCAAmB,CAAC,KAAI,EAAE,WAAW,CAAC,CAAC;YAClE,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,cAAc,CAAC;IAC1B,CAAC;IACL,cAAC;AAAD,CAAC,AAjXD,IAiXC;AAjXY,0BAAO","sourcesContent":["import * as ts from 'typescript';\nimport { Minimatch, IMinimatch } from 'minimatch';\n\nimport { Logger } from '../utils/loggers';\nimport { Reflection, ProjectReflection, ContainerReflection, Type } from '../models/index';\nimport { createTypeParameter } from './factories/type-parameter';\nimport { Converter } from './converter';\n\n/**\n * The context describes the current state the converter is in.\n */\nexport class Context {\n /**\n * The converter instance that has created the context.\n */\n converter: Converter;\n\n /**\n * A list of all files that have been passed to the TypeScript compiler.\n */\n fileNames: string[];\n\n /**\n * The TypeChecker instance returned by the TypeScript compiler.\n */\n checker: ts.TypeChecker;\n\n /**\n * The program that is currently processed.\n */\n program: ts.Program;\n\n /**\n * The project that is currently processed.\n */\n project: ProjectReflection;\n\n /**\n * The scope or parent reflection that is currently processed.\n */\n scope: Reflection;\n\n /**\n * Is the current source file marked as being external?\n */\n isExternal: boolean;\n\n /**\n * Is the current source file a declaration file?\n */\n isDeclaration: boolean;\n\n /**\n * The currently set type parameters.\n */\n typeParameters: ts.MapLike;\n\n /**\n * The currently set type arguments.\n */\n typeArguments: Type[];\n\n /**\n * Is the converter in inheritance mode?\n */\n isInherit: boolean;\n\n /**\n * The node that has started the inheritance mode.\n */\n inheritParent: ts.Node;\n\n /**\n * List symbol ids of inherited children already visited while inheriting.\n */\n inheritedChildren: number[];\n\n /**\n * The names of the children of the scope before inheritance has been started.\n */\n inherited: string[];\n\n /**\n * A list of parent nodes that have been passed to the visit function.\n */\n visitStack: ts.Node[];\n\n /**\n * Next free symbol id used by [[getSymbolID]].\n */\n private symbolID = -1024;\n\n /**\n * The pattern that should be used to flag external source files.\n */\n private externalPattern: IMinimatch;\n\n /**\n * Create a new Context instance.\n *\n * @param converter The converter instance that has created the context.\n * @param fileNames A list of all files that have been passed to the TypeScript compiler.\n * @param checker The TypeChecker instance returned by the TypeScript compiler.\n */\n constructor(converter: Converter, fileNames: string[], checker: ts.TypeChecker, program: ts.Program) {\n this.converter = converter;\n this.fileNames = fileNames;\n this.checker = checker;\n this.program = program;\n this.visitStack = [];\n\n const project = new ProjectReflection(converter.name);\n this.project = project;\n this.scope = project;\n\n if (converter.externalPattern) {\n this.externalPattern = new Minimatch(converter.externalPattern);\n }\n }\n\n /**\n * Return the compiler options.\n */\n getCompilerOptions(): ts.CompilerOptions {\n return this.converter.application.options.getCompilerOptions();\n }\n\n /**\n * Return the type declaration of the given node.\n *\n * @param node The TypeScript node whose type should be resolved.\n * @returns The type declaration of the given node.\n */\n getTypeAtLocation(node: ts.Node): ts.Type {\n let nodeType: ts.Type;\n try {\n nodeType = this.checker.getTypeAtLocation(node);\n } catch (error) {\n }\n if (!nodeType) {\n if (node.symbol) {\n nodeType = this.checker.getDeclaredTypeOfSymbol(node.symbol);\n } else if (node.parent && node.parent.symbol) {\n nodeType = this.checker.getDeclaredTypeOfSymbol(node.parent.symbol);\n } else if (node.parent && node.parent.parent && node.parent.parent.symbol) {\n nodeType = this.checker.getDeclaredTypeOfSymbol(node.parent.parent.symbol);\n }\n }\n return nodeType;\n }\n\n /**\n * Return the current logger instance.\n *\n * @returns The current logger instance.\n */\n getLogger(): Logger {\n return this.converter.application.logger;\n }\n\n /**\n * Return the symbol id of the given symbol.\n *\n * The compiler sometimes does not assign an id to symbols, this method makes sure that we have one.\n * It will assign negative ids if they are not set.\n *\n * @param symbol The symbol whose id should be returned.\n * @returns The id of the given symbol.\n */\n getSymbolID(symbol: ts.Symbol): number {\n if (!symbol) {\n return null;\n }\n if (!symbol.id) {\n symbol.id = this.symbolID--;\n }\n return symbol.id;\n }\n\n /**\n * Register a newly generated reflection.\n *\n * Ensures that the reflection is both listed in [[Project.reflections]] and\n * [[Project.symbolMapping]] if applicable.\n *\n * @param reflection The reflection that should be registered.\n * @param node The node the given reflection was resolved from.\n * @param symbol The symbol the given reflection was resolved from.\n */\n registerReflection(reflection: Reflection, node: ts.Node, symbol?: ts.Symbol) {\n this.project.reflections[reflection.id] = reflection;\n\n const id = this.getSymbolID(symbol ? symbol : (node ? node.symbol : null));\n if (!this.isInherit && id && !this.project.symbolMapping[id]) {\n this.project.symbolMapping[id] = reflection.id;\n }\n }\n\n /**\n * Trigger a node reflection event.\n *\n * All events are dispatched on the current converter instance.\n *\n * @param name The name of the event that should be triggered.\n * @param reflection The triggering reflection.\n * @param node The triggering TypeScript node if available.\n */\n trigger(name: string, reflection: Reflection, node?: ts.Node) {\n this.converter.trigger(name, this, reflection, node);\n }\n\n /**\n * Run the given callback with the context configured for the given source file.\n *\n * @param node The TypeScript node containing the source file declaration.\n * @param callback The callback that should be executed.\n */\n withSourceFile(node: ts.SourceFile, callback: Function) {\n const externalPattern = this.externalPattern;\n let isExternal = this.fileNames.indexOf(node.fileName) === -1;\n if (externalPattern) {\n isExternal = isExternal || externalPattern.match(node.fileName);\n }\n\n if (isExternal && this.converter.excludeExternals) {\n return;\n }\n\n let isDeclaration = node.isDeclarationFile;\n if (isDeclaration) {\n const lib = this.converter.getDefaultLib();\n const isLib = node.fileName.substr(-lib.length) === lib;\n if (!this.converter.includeDeclarations || isLib) {\n return;\n }\n }\n\n this.isExternal = isExternal;\n this.isDeclaration = isDeclaration;\n\n this.trigger(Converter.EVENT_FILE_BEGIN, this.project, node);\n callback();\n\n this.isExternal = false;\n this.isDeclaration = false;\n }\n\n /**\n * @param callback The callback function that should be executed with the changed context.\n */\n public withScope(scope: Reflection, callback: Function): void;\n\n /**\n * @param parameters An array of type parameters that should be set on the context while the callback is invoked.\n * @param callback The callback function that should be executed with the changed context.\n */\n public withScope(scope: Reflection, parameters: ts.NodeArray, callback: Function): void;\n\n /**\n * @param parameters An array of type parameters that should be set on the context while the callback is invoked.\n * @param preserve Should the currently set type parameters of the context be preserved?\n * @param callback The callback function that should be executed with the changed context.\n */\n public withScope(scope: Reflection, parameters: ts.NodeArray, preserve: boolean, callback: Function): void;\n\n /**\n * Run the given callback with the scope of the context set to the given reflection.\n *\n * @param scope The reflection that should be set as the scope of the context while the callback is invoked.\n */\n public withScope(scope: Reflection, ...args: any[]): void {\n if (!scope || !args.length) {\n return;\n }\n const callback = args.pop();\n const parameters = args.shift();\n\n const oldScope = this.scope;\n const oldTypeArguments = this.typeArguments;\n const oldTypeParameters = this.typeParameters;\n\n this.scope = scope;\n this.typeParameters = parameters ? this.extractTypeParameters(parameters, args.length > 0) : this.typeParameters;\n this.typeArguments = null;\n\n callback();\n\n this.scope = oldScope;\n this.typeParameters = oldTypeParameters;\n this.typeArguments = oldTypeArguments;\n }\n\n /**\n * Inherit the children of the given TypeScript node to the current scope.\n *\n * @param baseNode The node whose children should be inherited.\n * @param typeArguments The type arguments that apply while inheriting the given node.\n * @return The resulting reflection / the current scope.\n */\n inherit(baseNode: ts.Node, typeArguments?: ts.NodeArray): Reflection {\n const wasInherit = this.isInherit;\n const oldInherited = this.inherited;\n const oldInheritParent = this.inheritParent;\n const oldTypeArguments = this.typeArguments;\n\n this.isInherit = true;\n this.inheritParent = baseNode;\n this.inherited = [];\n\n const target = this.scope;\n if (!(target instanceof ContainerReflection)) {\n throw new Error('Expected container reflection');\n }\n\n if (baseNode.symbol) {\n const id = this.getSymbolID(baseNode.symbol);\n if (this.inheritedChildren && this.inheritedChildren.indexOf(id) !== -1) {\n return target;\n } else {\n this.inheritedChildren = this.inheritedChildren || [];\n this.inheritedChildren.push(id);\n }\n }\n\n if (target.children) {\n this.inherited = target.children.map((c) => c.name);\n } else {\n this.inherited = [];\n }\n\n if (typeArguments) {\n this.typeArguments = typeArguments.map((t) => this.converter.convertType(this, t));\n } else {\n this.typeArguments = null;\n }\n\n this.converter.convertNode(this, baseNode);\n\n this.isInherit = wasInherit;\n this.inherited = oldInherited;\n this.inheritParent = oldInheritParent;\n this.typeArguments = oldTypeArguments;\n\n if (!this.isInherit) {\n delete this.inheritedChildren;\n }\n\n return target;\n }\n\n /**\n * Convert the given list of type parameter declarations into a type mapping.\n *\n * @param parameters The list of type parameter declarations that should be converted.\n * @param preserve Should the currently set type parameters of the context be preserved?\n * @returns The resulting type mapping.\n */\n private extractTypeParameters(parameters: ts.NodeArray, preserve?: boolean): ts.MapLike {\n const typeParameters: ts.MapLike = {};\n\n if (preserve) {\n for (let key in this.typeParameters) {\n if (!this.typeParameters.hasOwnProperty(key)) {\n continue;\n }\n typeParameters[key] = this.typeParameters[key];\n }\n }\n\n parameters.forEach((declaration: ts.TypeParameterDeclaration, index: number) => {\n const name = declaration.symbol.name;\n if (this.typeArguments && this.typeArguments[index]) {\n typeParameters[name] = this.typeArguments[index];\n } else {\n typeParameters[name] = createTypeParameter(this, declaration);\n }\n });\n\n return typeParameters;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/convert-expression.d.ts b/dist/lib/converter/convert-expression.d.ts new file mode 100644 index 000000000..d11b5e7f3 --- /dev/null +++ b/dist/lib/converter/convert-expression.d.ts @@ -0,0 +1,3 @@ +import * as ts from 'typescript'; +export declare function convertDefaultValue(node: ts.VariableDeclaration | ts.ParameterDeclaration | ts.EnumMember): string; +export declare function convertExpression(expression: ts.Expression): string; diff --git a/dist/lib/converter/convert-expression.js b/dist/lib/converter/convert-expression.js new file mode 100644 index 000000000..09ae48426 --- /dev/null +++ b/dist/lib/converter/convert-expression.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../ts-internal"); +function convertDefaultValue(node) { + if (node.initializer) { + return convertExpression(node.initializer); + } + else { + return null; + } +} +exports.convertDefaultValue = convertDefaultValue; +function convertExpression(expression) { + switch (expression.kind) { + case ts.SyntaxKind.StringLiteral: + return '"' + expression.text + '"'; + case ts.SyntaxKind.NumericLiteral: + return expression.text; + case ts.SyntaxKind.TrueKeyword: + return 'true'; + case ts.SyntaxKind.FalseKeyword: + return 'false'; + default: + var source = _ts.getSourceFileOfNode(expression); + return source.text.substring(expression.pos, expression.end); + } +} +exports.convertExpression = convertExpression; +//# sourceMappingURL=convert-expression.js.map \ No newline at end of file diff --git a/dist/lib/converter/convert-expression.js.map b/dist/lib/converter/convert-expression.js.map new file mode 100644 index 000000000..9d8b86b18 --- /dev/null +++ b/dist/lib/converter/convert-expression.js.map @@ -0,0 +1 @@ +{"version":3,"file":"convert-expression.js","sourceRoot":"","sources":["../../../src/lib/converter/convert-expression.ts"],"names":[],"mappings":";;AAAA,+BAAiC;AACjC,oCAAsC;AAStC,6BAAoC,IAAkE;IAClG,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QACnB,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAND,kDAMC;AAED,2BAAkC,UAAyB;IACvD,MAAM,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QACtB,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa;YAC5B,MAAM,CAAC,GAAG,GAA2B,UAAW,CAAC,IAAI,GAAG,GAAG,CAAC;QAChE,KAAK,EAAE,CAAC,UAAU,CAAC,cAAc;YAC7B,MAAM,CAAyB,UAAW,CAAC,IAAI,CAAC;QACpD,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW;YAC1B,MAAM,CAAC,MAAM,CAAC;QAClB,KAAK,EAAE,CAAC,UAAU,CAAC,YAAY;YAC3B,MAAM,CAAC,OAAO,CAAC;QACnB;YACI,IAAM,MAAM,GAAG,GAAG,CAAC,mBAAmB,CAAW,UAAU,CAAC,CAAC;YAC7D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;AACL,CAAC;AAdD,8CAcC","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../ts-internal';\n\n/**\n * Return the default value of the given node.\n *\n * @param node The TypeScript node whose default value should be extracted.\n * @returns The default value as a string.\n */\n\nexport function convertDefaultValue(node: ts.VariableDeclaration|ts.ParameterDeclaration|ts.EnumMember): string {\n if (node.initializer) {\n return convertExpression(node.initializer);\n } else {\n return null;\n }\n}\n\nexport function convertExpression(expression: ts.Expression): string {\n switch (expression.kind) {\n case ts.SyntaxKind.StringLiteral:\n return '\"' + ( expression).text + '\"';\n case ts.SyntaxKind.NumericLiteral:\n return ( expression).text;\n case ts.SyntaxKind.TrueKeyword:\n return 'true';\n case ts.SyntaxKind.FalseKeyword:\n return 'false';\n default:\n const source = _ts.getSourceFileOfNode( expression);\n return source.text.substring(expression.pos, expression.end);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/converter.d.ts b/dist/lib/converter/converter.d.ts new file mode 100644 index 000000000..4cefdc321 --- /dev/null +++ b/dist/lib/converter/converter.d.ts @@ -0,0 +1,48 @@ +import * as ts from 'typescript'; +import { Application } from '../application'; +import { Reflection, Type, ProjectReflection } from '../models/index'; +import { Context } from './context'; +import { ConverterComponent } from './components'; +import { Component, ChildableComponent, ComponentClass } from '../utils/component'; +export interface ConverterResult { + errors: ReadonlyArray; + project: ProjectReflection; +} +export declare class Converter extends ChildableComponent { + name: string; + externalPattern: string; + includeDeclarations: boolean; + excludeExternals: boolean; + excludeNotExported: boolean; + excludePrivate: boolean; + excludeProtected: boolean; + private compilerHost; + private nodeConverters; + private typeNodeConverters; + private typeTypeConverters; + static EVENT_BEGIN: string; + static EVENT_END: string; + static EVENT_FILE_BEGIN: string; + static EVENT_CREATE_DECLARATION: string; + static EVENT_CREATE_SIGNATURE: string; + static EVENT_CREATE_PARAMETER: string; + static EVENT_CREATE_TYPE_PARAMETER: string; + static EVENT_FUNCTION_IMPLEMENTATION: string; + static EVENT_RESOLVE_BEGIN: string; + static EVENT_RESOLVE: string; + static EVENT_RESOLVE_END: string; + initialize(): void; + addComponent(name: string, componentClass: T | ComponentClass): T; + private addNodeConverter(converter); + private addTypeConverter(converter); + removeComponent(name: string): ConverterComponent; + private removeNodeConverter(converter); + private removeTypeConverter(converter); + removeAllComponents(): void; + convert(fileNames: string[]): ConverterResult; + convertNode(context: Context, node: ts.Node): Reflection; + convertType(context: Context, node?: ts.Node, type?: ts.Type): Type; + private compile(context); + private resolve(context); + getDefaultLib(): string; +} diff --git a/dist/lib/converter/converter.js b/dist/lib/converter/converter.js new file mode 100644 index 000000000..4809beaa4 --- /dev/null +++ b/dist/lib/converter/converter.js @@ -0,0 +1,255 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../ts-internal"); +var _ = require("lodash"); +var declaration_1 = require("../utils/options/declaration"); +var context_1 = require("./context"); +var components_1 = require("./components"); +var compiler_host_1 = require("./utils/compiler-host"); +var component_1 = require("../utils/component"); +var fs_1 = require("../utils/fs"); +var Converter = (function (_super) { + __extends(Converter, _super); + function Converter() { + return _super !== null && _super.apply(this, arguments) || this; + } + Converter_1 = Converter; + Converter.prototype.initialize = function () { + this.compilerHost = new compiler_host_1.CompilerHost(this); + this.nodeConverters = {}; + this.typeTypeConverters = []; + this.typeNodeConverters = []; + }; + Converter.prototype.addComponent = function (name, componentClass) { + var component = _super.prototype.addComponent.call(this, name, componentClass); + if (component instanceof components_1.ConverterNodeComponent) { + this.addNodeConverter(component); + } + else if (component instanceof components_1.ConverterTypeComponent) { + this.addTypeConverter(component); + } + return component; + }; + Converter.prototype.addNodeConverter = function (converter) { + for (var _i = 0, _a = converter.supports; _i < _a.length; _i++) { + var supports = _a[_i]; + this.nodeConverters[supports] = converter; + } + }; + Converter.prototype.addTypeConverter = function (converter) { + if ('supportsNode' in converter && 'convertNode' in converter) { + this.typeNodeConverters.push(converter); + this.typeNodeConverters.sort(function (a, b) { return (b.priority || 0) - (a.priority || 0); }); + } + if ('supportsType' in converter && 'convertType' in converter) { + this.typeTypeConverters.push(converter); + this.typeTypeConverters.sort(function (a, b) { return (b.priority || 0) - (a.priority || 0); }); + } + }; + Converter.prototype.removeComponent = function (name) { + var component = _super.prototype.removeComponent.call(this, name); + if (component instanceof components_1.ConverterNodeComponent) { + this.removeNodeConverter(component); + } + else if (component instanceof components_1.ConverterTypeComponent) { + this.removeTypeConverter(component); + } + return component; + }; + Converter.prototype.removeNodeConverter = function (converter) { + var converters = this.nodeConverters; + var keys = _.keys(this.nodeConverters); + for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { + var key = keys_1[_i]; + if (converters[key] === converter) { + delete converters[key]; + } + } + }; + Converter.prototype.removeTypeConverter = function (converter) { + var typeIndex = this.typeTypeConverters.indexOf(converter); + if (typeIndex !== -1) { + this.typeTypeConverters.splice(typeIndex, 1); + } + var nodeIndex = this.typeNodeConverters.indexOf(converter); + if (nodeIndex !== -1) { + this.typeNodeConverters.splice(nodeIndex, 1); + } + }; + Converter.prototype.removeAllComponents = function () { + _super.prototype.removeAllComponents.call(this); + this.nodeConverters = {}; + this.typeTypeConverters = []; + this.typeNodeConverters = []; + }; + Converter.prototype.convert = function (fileNames) { + for (var i = 0, c = fileNames.length; i < c; i++) { + fileNames[i] = fs_1.normalizePath(_ts.normalizeSlashes(fileNames[i])); + } + var program = ts.createProgram(fileNames, this.application.options.getCompilerOptions(), this.compilerHost); + var checker = program.getTypeChecker(); + var context = new context_1.Context(this, fileNames, checker, program); + this.trigger(Converter_1.EVENT_BEGIN, context); + var errors = this.compile(context); + var project = this.resolve(context); + this.trigger(Converter_1.EVENT_END, context); + return { + errors: errors, + project: project + }; + }; + Converter.prototype.convertNode = function (context, node) { + if (context.visitStack.indexOf(node) !== -1) { + return null; + } + var oldVisitStack = context.visitStack; + context.visitStack = oldVisitStack.slice(); + context.visitStack.push(node); + var result; + if (node.kind in this.nodeConverters) { + result = this.nodeConverters[node.kind].convert(context, node); + } + context.visitStack = oldVisitStack; + return result; + }; + Converter.prototype.convertType = function (context, node, type) { + if (node) { + type = type || context.getTypeAtLocation(node); + for (var _i = 0, _a = this.typeNodeConverters; _i < _a.length; _i++) { + var converter = _a[_i]; + if (converter.supportsNode(context, node, type)) { + return converter.convertNode(context, node, type); + } + } + } + if (type) { + for (var _b = 0, _c = this.typeTypeConverters; _b < _c.length; _b++) { + var converter = _c[_b]; + if (converter.supportsType(context, type)) { + return converter.convertType(context, type); + } + } + } + }; + Converter.prototype.compile = function (context) { + var _this = this; + var program = context.program; + program.getSourceFiles().forEach(function (sourceFile) { + _this.convertNode(context, sourceFile); + }); + var diagnostics = program.getOptionsDiagnostics(); + if (diagnostics.length) { + return diagnostics; + } + diagnostics = program.getSyntacticDiagnostics(); + if (diagnostics.length) { + return diagnostics; + } + diagnostics = program.getGlobalDiagnostics(); + if (diagnostics.length) { + return diagnostics; + } + diagnostics = program.getSemanticDiagnostics(); + if (diagnostics.length) { + return diagnostics; + } + return []; + }; + Converter.prototype.resolve = function (context) { + this.trigger(Converter_1.EVENT_RESOLVE_BEGIN, context); + var project = context.project; + for (var id in project.reflections) { + if (!project.reflections.hasOwnProperty(id)) { + continue; + } + this.trigger(Converter_1.EVENT_RESOLVE, context, project.reflections[id]); + } + this.trigger(Converter_1.EVENT_RESOLVE_END, context); + return project; + }; + Converter.prototype.getDefaultLib = function () { + return ts.getDefaultLibFileName(this.application.options.getCompilerOptions()); + }; + Converter.EVENT_BEGIN = 'begin'; + Converter.EVENT_END = 'end'; + Converter.EVENT_FILE_BEGIN = 'fileBegin'; + Converter.EVENT_CREATE_DECLARATION = 'createDeclaration'; + Converter.EVENT_CREATE_SIGNATURE = 'createSignature'; + Converter.EVENT_CREATE_PARAMETER = 'createParameter'; + Converter.EVENT_CREATE_TYPE_PARAMETER = 'createTypeParameter'; + Converter.EVENT_FUNCTION_IMPLEMENTATION = 'functionImplementation'; + Converter.EVENT_RESOLVE_BEGIN = 'resolveBegin'; + Converter.EVENT_RESOLVE = 'resolveReflection'; + Converter.EVENT_RESOLVE_END = 'resolveEnd'; + __decorate([ + component_1.Option({ + name: 'name', + help: 'Set the name of the project that will be used in the header of the template.' + }) + ], Converter.prototype, "name", void 0); + __decorate([ + component_1.Option({ + name: 'externalPattern', + help: 'Define a pattern for files that should be considered being external.' + }) + ], Converter.prototype, "externalPattern", void 0); + __decorate([ + component_1.Option({ + name: 'includeDeclarations', + help: 'Turn on parsing of .d.ts declaration files.', + type: declaration_1.ParameterType.Boolean + }) + ], Converter.prototype, "includeDeclarations", void 0); + __decorate([ + component_1.Option({ + name: 'excludeExternals', + help: 'Prevent externally resolved TypeScript files from being documented.', + type: declaration_1.ParameterType.Boolean + }) + ], Converter.prototype, "excludeExternals", void 0); + __decorate([ + component_1.Option({ + name: 'excludeNotExported', + help: 'Prevent symbols that are not exported from being documented.', + type: declaration_1.ParameterType.Boolean + }) + ], Converter.prototype, "excludeNotExported", void 0); + __decorate([ + component_1.Option({ + name: 'excludePrivate', + help: 'Ignores private variables and methods', + type: declaration_1.ParameterType.Boolean + }) + ], Converter.prototype, "excludePrivate", void 0); + __decorate([ + component_1.Option({ + name: 'excludeProtected', + help: 'Ignores protected variables and methods', + type: declaration_1.ParameterType.Boolean + }) + ], Converter.prototype, "excludeProtected", void 0); + Converter = Converter_1 = __decorate([ + component_1.Component({ name: 'converter', internal: true, childClass: components_1.ConverterComponent }) + ], Converter); + return Converter; + var Converter_1; +}(component_1.ChildableComponent)); +exports.Converter = Converter; +//# sourceMappingURL=converter.js.map \ No newline at end of file diff --git a/dist/lib/converter/converter.js.map b/dist/lib/converter/converter.js.map new file mode 100644 index 000000000..c34792636 --- /dev/null +++ b/dist/lib/converter/converter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../src/lib/converter/converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,oCAAsC;AACtC,0BAA4B;AAG5B,4DAA6D;AAE7D,qCAAoC;AAC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C,kBAAM,CAAC;YACJ,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,yCAAyC;YAC/C,IAAI,EAAE,2BAAa,CAAC,OAAO;SAC9B,CAAC;uDACwB;IAjDjB,SAAS;QADrB,qBAAS,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,+BAAkB,EAAC,CAAC;OAClE,SAAS,CA4XrB;IAAD,gBAAC;;CAAA,AA5XD,CAA+B,8BAAkB,GA4XhD;AA5XY,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 { CompilerHost } from './utils/compiler-host';\nimport { Component, Option, ChildableComponent, ComponentClass } from '../utils/component';\nimport { normalizePath } from '../utils/fs';\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;\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 {\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 a pattern for files that should be considered being external.'\n })\n externalPattern: 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 private compilerHost: CompilerHost;\n\n private nodeConverters: {[syntaxKind: number]: ConverterNodeComponent};\n\n private typeNodeConverters: TypeNodeConverter[];\n\n private typeTypeConverters: TypeTypeConverter[];\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.compilerHost = new CompilerHost(this);\n this.nodeConverters = {};\n this.typeTypeConverters = [];\n this.typeNodeConverters = [];\n }\n\n addComponent(name: string, componentClass: T | ComponentClass): 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) {\n for (let 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(> converter);\n this.typeNodeConverters.sort((a, b) => (b.priority || 0) - (a.priority || 0));\n }\n\n if ('supportsType' in converter && 'convertType' in converter) {\n this.typeTypeConverters.push(> converter);\n this.typeTypeConverters.sort((a, b) => (b.priority || 0) - (a.priority || 0));\n }\n }\n\n removeComponent(name: string): ConverterComponent {\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) {\n const converters = this.nodeConverters;\n const keys = _.keys(this.nodeConverters);\n for (let 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( converter);\n if (typeIndex !== -1) {\n this.typeTypeConverters.splice(typeIndex, 1);\n }\n\n const nodeIndex = this.typeNodeConverters.indexOf( 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 for (let i = 0, c = fileNames.length; i < c; i++) {\n fileNames[i] = normalizePath(_ts.normalizeSlashes(fileNames[i]));\n }\n\n const program = ts.createProgram(fileNames, this.application.options.getCompilerOptions(), this.compilerHost);\n const checker = program.getTypeChecker();\n const context = new Context(this, fileNames, 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 NULL.\n */\n convertNode(context: Context, node: ts.Node): Reflection {\n if (context.visitStack.indexOf(node) !== -1) {\n return null;\n }\n\n const oldVisitStack = context.visitStack;\n context.visitStack = oldVisitStack.slice();\n context.visitStack.push(node);\n\n let result: Reflection;\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 {\n // Run all node based type conversions\n if (node) {\n type = type || context.getTypeAtLocation(node);\n\n for (let 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 (let converter of this.typeTypeConverters) {\n if (converter.supportsType(context, type)) {\n return converter.convertType(context, type);\n }\n }\n }\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 {\n const program = context.program;\n\n program.getSourceFiles().forEach((sourceFile) => {\n this.convertNode(context, sourceFile);\n });\n\n let diagnostics = program.getOptionsDiagnostics();\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getSyntacticDiagnostics();\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getGlobalDiagnostics();\n if (diagnostics.length) {\n return diagnostics;\n }\n\n diagnostics = program.getSemanticDiagnostics();\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 (let 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"]} \ No newline at end of file diff --git a/dist/lib/converter/factories/comment.d.ts b/dist/lib/converter/factories/comment.d.ts new file mode 100644 index 000000000..6b582cecd --- /dev/null +++ b/dist/lib/converter/factories/comment.d.ts @@ -0,0 +1,5 @@ +import * as ts from 'typescript'; +import { Comment } from '../../models/comments/index'; +export declare function createComment(node: ts.Node): Comment; +export declare function getRawComment(node: ts.Node): string; +export declare function parseComment(text: string, comment?: Comment): Comment; diff --git a/dist/lib/converter/factories/comment.js b/dist/lib/converter/factories/comment.js new file mode 100644 index 000000000..a7dfd8e53 --- /dev/null +++ b/dist/lib/converter/factories/comment.js @@ -0,0 +1,143 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/comments/index"); +function createComment(node) { + var comment = getRawComment(node); + if (comment == null) { + return null; + } + return parseComment(comment); +} +exports.createComment = createComment; +function isTopmostModuleDeclaration(node) { + if (node.nextContainer && node.nextContainer.kind === ts.SyntaxKind.ModuleDeclaration) { + var next = node.nextContainer; + if (node.name.end + 1 === next.name.pos) { + return false; + } + } + return true; +} +function getRootModuleDeclaration(node) { + while (node.parent && node.parent.kind === ts.SyntaxKind.ModuleDeclaration) { + var parent_1 = node.parent; + if (node.name.pos === parent_1.name.end + 1) { + node = parent_1; + } + else { + break; + } + } + return node; +} +function getRawComment(node) { + if (node.parent && node.parent.kind === ts.SyntaxKind.VariableDeclarationList) { + node = node.parent.parent; + } + else if (node.kind === ts.SyntaxKind.ModuleDeclaration) { + if (!isTopmostModuleDeclaration(node)) { + return null; + } + else { + node = getRootModuleDeclaration(node); + } + } + var sourceFile = _ts.getSourceFileOfNode(node); + var comments = _ts.getJSDocCommentRanges(node, sourceFile.text); + if (comments && comments.length) { + var comment = void 0; + if (node.kind === ts.SyntaxKind.SourceFile) { + if (comments.length === 1) { + return null; + } + comment = comments[0]; + } + else { + comment = comments[comments.length - 1]; + } + return sourceFile.text.substring(comment.pos, comment.end); + } + else { + return null; + } +} +exports.getRawComment = getRawComment; +function parseComment(text, comment) { + if (comment === void 0) { comment = new index_1.Comment(); } + var currentTag; + var shortText = 0; + function consumeTypeData(line) { + line = line.replace(/^\{[^\}]*\}+/, ''); + line = line.replace(/^\[[^\[][^\]]*\]+/, ''); + return line.trim(); + } + function readBareLine(line) { + if (currentTag) { + currentTag.text += '\n' + line; + } + else if (line === '' && shortText === 0) { + } + else if (line === '' && shortText === 1) { + shortText = 2; + } + else { + if (shortText === 2) { + comment.text += (comment.text === '' ? '' : '\n') + line; + } + else { + comment.shortText += (comment.shortText === '' ? '' : '\n') + line; + shortText = 1; + } + } + } + function readTagLine(line, tag) { + var tagName = tag[1].toLowerCase(); + var paramName; + line = line.substr(tagName.length + 1).trim(); + if (tagName === 'return') { + tagName = 'returns'; + } + if (tagName === 'param' || tagName === 'typeparam') { + line = consumeTypeData(line); + var param = /[^\s]+/.exec(line); + if (param) { + paramName = param[0]; + line = line.substr(paramName.length + 1).trim(); + } + line = consumeTypeData(line); + line = line.replace(/^\-\s+/, ''); + } + else if (tagName === 'returns') { + line = consumeTypeData(line); + } + currentTag = new index_1.CommentTag(tagName, paramName, line); + if (!comment.tags) { + comment.tags = []; + } + comment.tags.push(currentTag); + } + var CODE_FENCE = /^\s*```(?!.*```)/; + var inCode = false; + function readLine(line) { + line = line.replace(/^\s*\*? ?/, ''); + line = line.replace(/\s*$/, ''); + if (CODE_FENCE.test(line)) { + inCode = !inCode; + } + if (!inCode) { + var tag = /^@(\S+)/.exec(line); + if (tag) { + return readTagLine(line, tag); + } + } + readBareLine(line); + } + text = text.replace(/^\s*\/\*+/, ''); + text = text.replace(/\*+\/\s*$/, ''); + text.split(/\r\n?|\n/).forEach(readLine); + return comment; +} +exports.parseComment = parseComment; +//# sourceMappingURL=comment.js.map \ No newline at end of file diff --git a/dist/lib/converter/factories/comment.js.map b/dist/lib/converter/factories/comment.js.map new file mode 100644 index 000000000..239f0e136 --- /dev/null +++ b/dist/lib/converter/factories/comment.js.map @@ -0,0 +1 @@ +{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/comment.ts"],"names":[],"m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AC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;QAAC,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IAED,IAAM,UAAU,GAAG,kBAAkB,CAAC;IACtC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,kBAAkB,IAAY;QAC1B,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACrC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEhC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC;YAC3B,MAAM,GAAG,CAAC,MAAM,CAAC;QACnB,CAAC;QAED,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACZ,IAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACR,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QACD,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAID,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,MAAM,CAAC,OAAO,CAAC;AACnB,CAAC;AA7ED,oCA6EC","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\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 NULL if\n * no comment is present.\n */\nexport function createComment(node: ts.Node): Comment {\n const comment = getRawComment(node);\n if (comment == null) {\n return null;\n }\n\n return parseComment(comment);\n}\n\n/**\n * Check whether the given module declaration is the topmost.\n *\n * This funtion returns TRUE if there is no trailing module defined, in\n * the following example this would be the case only for module C.\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 if (node.nextContainer && node.nextContainer.kind === ts.SyntaxKind.ModuleDeclaration) {\n let next = node.nextContainer;\n if (node.name.end + 1 === next.name.pos) {\n return false;\n }\n }\n\n return true;\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 * A 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 let parent = 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 * 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 NULL if no comment could be found.\n */\nexport function getRawComment(node: ts.Node): string {\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( node)) {\n return null;\n } else {\n node = getRootModuleDeclaration( node);\n }\n }\n\n const sourceFile = _ts.getSourceFileOfNode(node);\n const comments = _ts.getJSDocCommentRanges(node, sourceFile.text);\n if (comments && comments.length) {\n let comment: ts.CommentRange;\n if (node.kind === ts.SyntaxKind.SourceFile) {\n if (comments.length === 1) {\n return null;\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 null;\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;\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*\\/\\*+\\s*(\\r\\n?|\\n)/, '');\n // text = text.replace(/(\\r\\n?|\\n)\\s*\\*+\\/\\s*$/, '');\n text = text.replace(/^\\s*\\/\\*+/, '');\n text = text.replace(/\\*+\\/\\s*$/, '');\n text.split(/\\r\\n?|\\n/).forEach(readLine);\n\n return comment;\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/factories/declaration.d.ts b/dist/lib/converter/factories/declaration.d.ts new file mode 100644 index 000000000..8b8ccb98b --- /dev/null +++ b/dist/lib/converter/factories/declaration.d.ts @@ -0,0 +1,4 @@ +import * as ts from 'typescript'; +import { ReflectionKind, DeclarationReflection } from '../../models/index'; +import { Context } from '../context'; +export declare function createDeclaration(context: Context, node: ts.Node, kind: ReflectionKind, name?: string): DeclarationReflection; diff --git a/dist/lib/converter/factories/declaration.js b/dist/lib/converter/factories/declaration.js new file mode 100644 index 000000000..6bff3c181 --- /dev/null +++ b/dist/lib/converter/factories/declaration.js @@ -0,0 +1,133 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var converter_1 = require("../converter"); +var reference_1 = require("./reference"); +var nonStaticKinds = [ + index_1.ReflectionKind.Class, + index_1.ReflectionKind.Interface, + index_1.ReflectionKind.Module +]; +function createDeclaration(context, node, kind, name) { + var container = context.scope; + if (!(container instanceof index_1.ContainerReflection)) { + throw new Error('Expected container reflection.'); + } + if (!name) { + if (node.localSymbol) { + name = node.localSymbol.name; + } + else if (node.symbol) { + name = node.symbol.name; + } + else { + return null; + } + } + var modifiers = ts.getCombinedModifierFlags(node); + var isExported; + if (container.kindOf([index_1.ReflectionKind.Module, index_1.ReflectionKind.ExternalModule])) { + isExported = false; + } + else { + isExported = container.flags.isExported; + } + if (kind === index_1.ReflectionKind.ExternalModule) { + isExported = true; + } + else if (node.parent && node.parent.kind === ts.SyntaxKind.VariableDeclarationList) { + var parentModifiers = ts.getCombinedModifierFlags(node.parent.parent); + isExported = isExported || !!(parentModifiers & ts.ModifierFlags.Export); + } + else { + isExported = isExported || !!(modifiers & ts.ModifierFlags.Export); + } + if (!isExported && context.converter.excludeNotExported) { + return null; + } + var isPrivate = !!(modifiers & ts.ModifierFlags.Private); + if (context.isInherit && isPrivate) { + return null; + } + var isConstructorProperty = false; + var isStatic = false; + if (nonStaticKinds.indexOf(kind) === -1) { + isStatic = !!(modifiers & ts.ModifierFlags.Static); + if (container.kind === index_1.ReflectionKind.Class) { + if (node.parent && node.parent.kind === ts.SyntaxKind.Constructor) { + isConstructorProperty = true; + } + else if (!node.parent || node.parent.kind !== ts.SyntaxKind.ClassDeclaration) { + isStatic = true; + } + } + } + var child; + var children = container.children = container.children || []; + children.forEach(function (n) { + if (n.name === name && n.flags.isStatic === isStatic) { + child = n; + } + }); + if (!child) { + child = new index_1.DeclarationReflection(container, name, kind); + child.setFlag(index_1.ReflectionFlag.Static, isStatic); + child.setFlag(index_1.ReflectionFlag.Private, isPrivate); + child.setFlag(index_1.ReflectionFlag.ConstructorProperty, isConstructorProperty); + child.setFlag(index_1.ReflectionFlag.Exported, isExported); + child = setupDeclaration(context, child, node); + if (child) { + children.push(child); + context.registerReflection(child, node); + } + } + else { + child = mergeDeclarations(context, child, node, kind); + } + if (child) { + context.trigger(converter_1.Converter.EVENT_CREATE_DECLARATION, child, node); + } + return child; +} +exports.createDeclaration = createDeclaration; +function setupDeclaration(context, reflection, node) { + var modifiers = ts.getCombinedModifierFlags(node); + reflection.setFlag(index_1.ReflectionFlag.External, context.isExternal); + reflection.setFlag(index_1.ReflectionFlag.Protected, !!(modifiers & ts.ModifierFlags.Protected)); + reflection.setFlag(index_1.ReflectionFlag.Public, !!(modifiers & ts.ModifierFlags.Public)); + reflection.setFlag(index_1.ReflectionFlag.Optional, !!(node['questionToken'])); + if (context.isInherit && + (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)) { + if (!reflection.inheritedFrom) { + reflection.inheritedFrom = reference_1.createReferenceType(context, node.symbol, true); + reflection.getAllSignatures().forEach(function (signature) { + signature.inheritedFrom = reference_1.createReferenceType(context, node.symbol, true); + }); + } + } + return reflection; +} +function mergeDeclarations(context, reflection, node, kind) { + if (reflection.kind !== kind) { + var weights = [index_1.ReflectionKind.Module, index_1.ReflectionKind.Enum, index_1.ReflectionKind.Class]; + var kindWeight = weights.indexOf(kind); + var childKindWeight = weights.indexOf(reflection.kind); + if (kindWeight > childKindWeight) { + reflection.kind = kind; + } + } + if (context.isInherit && + context.inherited.indexOf(reflection.name) !== -1 && + (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)) { + if (!reflection.overwrites) { + reflection.overwrites = reference_1.createReferenceType(context, node.symbol, true); + reflection.getAllSignatures().forEach(function (signature) { + signature.overwrites = reference_1.createReferenceType(context, node.symbol, true); + }); + } + return null; + } + return reflection; +} +//# sourceMappingURL=declaration.js.map \ No newline at end of file diff --git a/dist/lib/converter/factories/declaration.js.map b/dist/lib/converter/factories/declaration.js.map new file mode 100644 index 000000000..259544c30 --- /dev/null +++ b/dist/lib/converter/factories/declaration.js.map @@ -0,0 +1 @@ +{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/declaration.ts"],"names":[],"mappings":";;AAAA,+BAAiC;AAEjC,4CAAgH;AAEhH,0CAAyC;AACzC,yCAAkD;AAKlD,IAAM,cAAc,GAAG;IACnB,sBAAc,CAAC,KAAK;IACpB,sBAAc,CAAC,SAAS;IACxB,sBAAc,CAAC,MAAM;CACxB,CAAC;AAYF,2BAAkC,OAAgB,EAAE,IAAa,EAAE,IAAoB,EAAE,IAAa;IAClG,IAAM,SAAS,GAAyB,OAAO,CAAC,KAAK,CAAC;IACtD,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,2BAAmB,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;IAGD,EAAE,CAAC,C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tB,CAAC","sourcesContent":["import * as ts from 'typescript';\n\nimport { ReflectionKind, ReflectionFlag, ContainerReflection, DeclarationReflection } from '../../models/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { createReferenceType } from './reference';\n\n/**\n * List of reflection kinds that never should be static.\n */\nconst nonStaticKinds = [\n ReflectionKind.Class,\n ReflectionKind.Interface,\n ReflectionKind.Module\n];\n\n/**\n * Create a declaration reflection from the given TypeScript node.\n *\n * @param context The context object describing the current state the converter is in. The\n * scope of the context will be the parent of the generated reflection.\n * @param node The TypeScript node that should be converted to a reflection.\n * @param kind The desired kind of the reflection.\n * @param name The desired name of the reflection.\n * @returns The resulting reflection.\n */\nexport function createDeclaration(context: Context, node: ts.Node, kind: ReflectionKind, name?: string): DeclarationReflection {\n const container = context.scope;\n if (!(container instanceof ContainerReflection)) {\n throw new Error('Expected container reflection.');\n }\n\n // Ensure we have a name for the reflection\n if (!name) {\n if (node.localSymbol) {\n name = node.localSymbol.name;\n } else if (node.symbol) {\n name = node.symbol.name;\n } else {\n return null;\n }\n }\n\n const modifiers = ts.getCombinedModifierFlags(node);\n\n // Test whether the node is exported\n let isExported: boolean;\n if (container.kindOf([ReflectionKind.Module, ReflectionKind.ExternalModule])) {\n isExported = false; // Don't inherit exported state in modules and namespaces\n } else {\n isExported = container.flags.isExported;\n }\n\n if (kind === ReflectionKind.ExternalModule) {\n isExported = true; // Always mark external modules as exported\n } else if (node.parent && node.parent.kind === ts.SyntaxKind.VariableDeclarationList) {\n const parentModifiers = ts.getCombinedModifierFlags(node.parent.parent);\n isExported = isExported || !!(parentModifiers & ts.ModifierFlags.Export);\n } else {\n isExported = isExported || !!(modifiers & ts.ModifierFlags.Export);\n }\n\n if (!isExported && context.converter.excludeNotExported) {\n return null;\n }\n\n // Test whether the node is private, when inheriting ignore private members\n const isPrivate = !!(modifiers & ts.ModifierFlags.Private);\n if (context.isInherit && isPrivate) {\n return null;\n }\n\n // Test whether the node is static, when merging a module to a class make the node static\n let isConstructorProperty = false;\n let isStatic = false;\n if (nonStaticKinds.indexOf(kind) === -1) {\n isStatic = !!(modifiers & ts.ModifierFlags.Static);\n if (container.kind === ReflectionKind.Class) {\n if (node.parent && node.parent.kind === ts.SyntaxKind.Constructor) {\n isConstructorProperty = true;\n } else if (!node.parent || node.parent.kind !== ts.SyntaxKind.ClassDeclaration) {\n isStatic = true;\n }\n }\n }\n\n // Check if we already have a child with the same name and static flag\n let child: DeclarationReflection;\n const children = container.children = container.children || [];\n children.forEach((n: DeclarationReflection) => {\n if (n.name === name && n.flags.isStatic === isStatic) {\n child = n;\n }\n });\n\n if (!child) {\n // Child does not exist, create a new reflection\n child = new DeclarationReflection(container, name, kind);\n child.setFlag(ReflectionFlag.Static, isStatic);\n child.setFlag(ReflectionFlag.Private, isPrivate);\n child.setFlag(ReflectionFlag.ConstructorProperty, isConstructorProperty);\n child.setFlag(ReflectionFlag.Exported, isExported);\n child = setupDeclaration(context, child, node);\n\n if (child) {\n children.push(child);\n context.registerReflection(child, node);\n }\n } else {\n // Merge the existent reflection with the given node\n child = mergeDeclarations(context, child, node, kind);\n }\n\n // If we have a reflection, trigger the corresponding event\n if (child) {\n context.trigger(Converter.EVENT_CREATE_DECLARATION, child, node);\n }\n\n return child;\n}\n\n/**\n * Setup a newly created declaration reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The newly created blank reflection.\n * @param node The TypeScript node whose properties should be applies to the given reflection.\n * @returns The reflection populated with the values of the given node.\n */\nfunction setupDeclaration(context: Context, reflection: DeclarationReflection, node: ts.Node) {\n const modifiers = ts.getCombinedModifierFlags(node);\n\n reflection.setFlag(ReflectionFlag.External, context.isExternal);\n reflection.setFlag(ReflectionFlag.Protected, !!(modifiers & ts.ModifierFlags.Protected));\n reflection.setFlag(ReflectionFlag.Public, !!(modifiers & ts.ModifierFlags.Public));\n reflection.setFlag(ReflectionFlag.Optional, !!(node['questionToken']));\n\n if (\n context.isInherit &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.inheritedFrom) {\n reflection.inheritedFrom = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.inheritedFrom = createReferenceType(context, node.symbol, true);\n });\n }\n }\n\n return reflection;\n}\n\n/**\n * Merge the properties of the given TypeScript node with the pre existent reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The pre existent reflection.\n * @param node The TypeScript node whose properties should be merged with the given reflection.\n * @param kind The desired kind of the reflection.\n * @returns The reflection merged with the values of the given node or NULL if the merge is invalid.\n */\nfunction mergeDeclarations(context: Context, reflection: DeclarationReflection, node: ts.Node, kind: ReflectionKind) {\n if (reflection.kind !== kind) {\n const weights = [ReflectionKind.Module, ReflectionKind.Enum, ReflectionKind.Class];\n const kindWeight = weights.indexOf(kind);\n const childKindWeight = weights.indexOf(reflection.kind);\n if (kindWeight > childKindWeight) {\n reflection.kind = kind;\n }\n }\n\n if (\n context.isInherit &&\n context.inherited.indexOf(reflection.name) !== -1 &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.overwrites) {\n reflection.overwrites = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.overwrites = createReferenceType(context, node.symbol, true);\n });\n }\n return null;\n }\n\n return reflection;\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/factories/index.d.ts b/dist/lib/converter/factories/index.d.ts new file mode 100644 index 000000000..8f5d9fe2c --- /dev/null +++ b/dist/lib/converter/factories/index.d.ts @@ -0,0 +1,6 @@ +export { createComment } from './comment'; +export { createDeclaration } from './declaration'; +export { createParameter } from './parameter'; +export { createReferenceType } from './reference'; +export { createSignature } from './signature'; +export { createTypeParameter } from './type-parameter'; diff --git a/dist/lib/converter/factories/index.js b/dist/lib/converter/factories/index.js new file mode 100644 index 000000000..d74997976 --- /dev/null +++ b/dist/lib/converter/factories/index.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var comment_1 = require("./comment"); +exports.createComment = comment_1.createComment; +var declaration_1 = require("./declaration"); +exports.createDeclaration = declaration_1.createDeclaration; +var parameter_1 = require("./parameter"); +exports.createParameter = parameter_1.createParameter; +var reference_1 = require("./reference"); +exports.createReferenceType = reference_1.createReferenceType; +var signature_1 = require("./signature"); +exports.createSignature = signature_1.createSignature; +var type_parameter_1 = require("./type-parameter"); +exports.createTypeParameter = type_parameter_1.createTypeParameter; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/converter/factories/index.js.map b/dist/lib/converter/factories/index.js.map new file mode 100644 index 000000000..852eaa553 --- /dev/null +++ b/dist/lib/converter/factories/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/index.ts"],"names":[],"mappings":";;AAAA,qCAA0C;AAAjC,kCAAA,aAAa,CAAA;AACtB,6CAAkD;AAAzC,0CAAA,iBAAiB,CAAA;AAC1B,yCAA8C;AAArC,sCAAA,eAAe,CAAA;AACxB,yCAAkD;AAAzC,0CAAA,mBAAmB,CAAA;AAC5B,yCAA8C;AAArC,sCAAA,eAAe,CAAA;AACxB,mDAAuD;AAA9C,+CAAA,mBAAmB,CAAA","sourcesContent":["export { createComment } from './comment';\nexport { createDeclaration } from './declaration';\nexport { createParameter } from './parameter';\nexport { createReferenceType } from './reference';\nexport { createSignature } from './signature';\nexport { createTypeParameter } from './type-parameter';\n"]} \ No newline at end of file diff --git a/dist/lib/converter/factories/parameter.d.ts b/dist/lib/converter/factories/parameter.d.ts new file mode 100644 index 000000000..ef28bad18 --- /dev/null +++ b/dist/lib/converter/factories/parameter.d.ts @@ -0,0 +1,4 @@ +import * as ts from 'typescript'; +import { ParameterReflection } from '../../models/reflections/index'; +import { Context } from '../context'; +export declare function createParameter(context: Context, node: ts.ParameterDeclaration): ParameterReflection; diff --git a/dist/lib/converter/factories/parameter.js b/dist/lib/converter/factories/parameter.js new file mode 100644 index 000000000..1279490ed --- /dev/null +++ b/dist/lib/converter/factories/parameter.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/reflections/index"); +var converter_1 = require("../converter"); +var convert_expression_1 = require("../convert-expression"); +function createParameter(context, node) { + var signature = context.scope; + if (!(signature instanceof index_1.SignatureReflection)) { + throw new Error('Expected signature reflection.'); + } + var parameter = new index_1.ParameterReflection(signature, node.symbol.name, index_1.ReflectionKind.Parameter); + context.registerReflection(parameter, node); + context.withScope(parameter, function () { + if (_ts.isBindingPattern(node.name)) { + parameter.type = context.converter.convertType(context, node.name); + parameter.name = '__namedParameters'; + } + else { + parameter.type = context.converter.convertType(context, node.type, context.getTypeAtLocation(node)); + } + parameter.defaultValue = convert_expression_1.convertDefaultValue(node); + parameter.setFlag(index_1.ReflectionFlag.Optional, !!node.questionToken); + parameter.setFlag(index_1.ReflectionFlag.Rest, !!node.dotDotDotToken); + parameter.setFlag(index_1.ReflectionFlag.DefaultValue, !!parameter.defaultValue); + if (!signature.parameters) { + signature.parameters = []; + } + signature.parameters.push(parameter); + }); + context.trigger(converter_1.Converter.EVENT_CREATE_PARAMETER, parameter, node); + return parameter; +} +exports.createParameter = createParameter; +//# sourceMappingURL=parameter.js.map \ No newline at end of file diff --git a/dist/lib/converter/factories/parameter.js.map b/dist/lib/converter/factories/parameter.js.map new file mode 100644 index 000000000..f8b1b5e2b --- /dev/null +++ b/dist/lib/converter/factories/parameter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/parameter.ts"],"names":[],"mappings":";;AACA,uCAAyC;AAEzC,wDAA0H;AAE1H,0CAAyC;AACzC,4DAA4D;AAS5D,yBAAgC,OAAgB,EAAE,IAA6B;IAC3E,IAAM,SAAS,GAAyB,OAAO,CAAC,KAAK,CAAC;IACtD,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,2BAAmB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C9B,CAAC;QACD,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,CAAC,qBAAS,CAAC,sBAAsB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACnE,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC;AA7BD,0CA6BC","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { ReflectionFlag, ReflectionKind, ParameterReflection, SignatureReflection } from '../../models/reflections/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { convertDefaultValue } from '../convert-expression';\n\n/**\n * Create a parameter reflection for the given node.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The parameter node that should be reflected.\n * @returns The newly created parameter reflection.\n */\nexport function createParameter(context: Context, node: ts.ParameterDeclaration): ParameterReflection {\n const signature = context.scope;\n if (!(signature instanceof SignatureReflection)) {\n throw new Error('Expected signature reflection.');\n }\n\n const parameter = new ParameterReflection(signature, node.symbol.name, ReflectionKind.Parameter);\n context.registerReflection(parameter, node);\n context.withScope(parameter, () => {\n if (_ts.isBindingPattern(node.name)) {\n parameter.type = context.converter.convertType(context, node.name);\n parameter.name = '__namedParameters';\n } else {\n parameter.type = context.converter.convertType(context, node.type, context.getTypeAtLocation(node));\n }\n\n parameter.defaultValue = convertDefaultValue(node);\n parameter.setFlag(ReflectionFlag.Optional, !!node.questionToken);\n parameter.setFlag(ReflectionFlag.Rest, !!node.dotDotDotToken);\n parameter.setFlag(ReflectionFlag.DefaultValue, !!parameter.defaultValue);\n\n if (!signature.parameters) {\n signature.parameters = [];\n }\n signature.parameters.push(parameter);\n });\n\n context.trigger(Converter.EVENT_CREATE_PARAMETER, parameter, node);\n return parameter;\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/factories/reference.d.ts b/dist/lib/converter/factories/reference.d.ts new file mode 100644 index 000000000..640e7d15a --- /dev/null +++ b/dist/lib/converter/factories/reference.d.ts @@ -0,0 +1,4 @@ +import * as ts from 'typescript'; +import { ReferenceType } from '../../models/types/index'; +import { Context } from '../context'; +export declare function createReferenceType(context: Context, symbol: ts.Symbol, includeParent?: boolean): ReferenceType; diff --git a/dist/lib/converter/factories/reference.js b/dist/lib/converter/factories/reference.js new file mode 100644 index 000000000..829622fa5 --- /dev/null +++ b/dist/lib/converter/factories/reference.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/types/index"); +function createReferenceType(context, symbol, includeParent) { + var checker = context.checker; + var id = context.getSymbolID(symbol); + var name = checker.symbolToString(symbol); + if (includeParent && symbol.parent) { + name = checker.symbolToString(symbol.parent) + '.' + name; + } + return new index_1.ReferenceType(name, id); +} +exports.createReferenceType = createReferenceType; +//# sourceMappingURL=reference.js.map \ No newline at end of file diff --git a/dist/lib/converter/factories/reference.js.map b/dist/lib/converter/factories/reference.js.map new file mode 100644 index 000000000..c3a8d43ef --- /dev/null +++ b/dist/lib/converter/factories/reference.js.map @@ -0,0 +1 @@ +{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/reference.ts"],"names":[],"mappings":";;AAEA,kDAAyD;AAWzD,6BAAoC,OAAgB,EAAE,MAAiB,EAAE,aAAuB;IAC5F,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,IAAM,EAAE,GAAQ,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,IAAI,GAAM,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAE7C,EAAE,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACjC,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;IAC9D,CAAC;IAED,MAAM,CAAC,IAAI,qBAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC;AAVD,kDAUC","sourcesContent":["import * as ts from 'typescript';\n\nimport { ReferenceType } from '../../models/types/index';\nimport { Context } from '../context';\n\n/**\n * Create a new reference type pointing to the given symbol.\n *\n * @param context The context object describing the current state the converter is in.\n * @param symbol The symbol the reference type should point to.\n * @param includeParent Should the name of the parent be provided within the fallback name?\n * @returns A new reference type instance pointing to the given symbol.\n */\nexport function createReferenceType(context: Context, symbol: ts.Symbol, includeParent?: boolean): ReferenceType {\n const checker = context.checker;\n const id = context.getSymbolID(symbol);\n let name = checker.symbolToString(symbol);\n\n if (includeParent && symbol.parent) {\n name = checker.symbolToString(symbol.parent) + '.' + name;\n }\n\n return new ReferenceType(name, id);\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/factories/signature.d.ts b/dist/lib/converter/factories/signature.d.ts new file mode 100644 index 000000000..3c6d821d8 --- /dev/null +++ b/dist/lib/converter/factories/signature.d.ts @@ -0,0 +1,4 @@ +import * as ts from 'typescript'; +import { ReflectionKind, SignatureReflection } from '../../models/index'; +import { Context } from '../context'; +export declare function createSignature(context: Context, node: ts.SignatureDeclaration, name: string, kind: ReflectionKind): SignatureReflection; diff --git a/dist/lib/converter/factories/signature.js b/dist/lib/converter/factories/signature.js new file mode 100644 index 000000000..5d08e4bfc --- /dev/null +++ b/dist/lib/converter/factories/signature.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var converter_1 = require("../converter"); +var parameter_1 = require("./parameter"); +var reference_1 = require("./reference"); +function createSignature(context, node, name, kind) { + var container = context.scope; + if (!(container instanceof index_1.ContainerReflection)) { + throw new Error('Expected container reflection.'); + } + var signature = new index_1.SignatureReflection(container, name, kind); + context.registerReflection(signature, node); + context.withScope(signature, node.typeParameters, true, function () { + node.parameters.forEach(function (parameter) { + parameter_1.createParameter(context, parameter); + }); + signature.type = extractSignatureType(context, node); + if (container.inheritedFrom) { + signature.inheritedFrom = reference_1.createReferenceType(context, node.symbol, true); + } + }); + context.trigger(converter_1.Converter.EVENT_CREATE_SIGNATURE, signature, node); + return signature; +} +exports.createSignature = createSignature; +function extractSignatureType(context, node) { + var checker = context.checker; + if (node.kind & ts.SyntaxKind.CallSignature || node.kind & ts.SyntaxKind.CallExpression) { + try { + var signature = checker.getSignatureFromDeclaration(node); + return context.converter.convertType(context, node.type, checker.getReturnTypeOfSignature(signature)); + } + catch (error) { } + } + if (node.type) { + return context.converter.convertType(context, node.type); + } + else { + return context.converter.convertType(context, node); + } +} +//# sourceMappingURL=signature.js.map \ No newline at end of file diff --git a/dist/lib/converter/factories/signature.js.map b/dist/lib/converter/factories/signature.js.map new file mode 100644 index 000000000..ea32f1b27 --- /dev/null +++ b/dist/lib/converter/factories/signature.js.map @@ -0,0 +1 @@ +{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/signature.ts"],"names":[],"mappings":";;AAAA,+BAAiC;AAEjC,4CAA2H;AAE3H,0CAAyC;AACzC,yCAA8C;AAC9C,yCAAkD;AAWlD,yBAAgC,OAAgB,EAAE,IAA6B,EAAE,IAAY,EAAE,IAAoB;IAC/G,IAAM,SAAS,GAA2B,OAAO,CAAC,KAAK,CAAC;IACxD,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,2BAAmB,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;IAED,IAAM,SAAS,GAAG,IAAI,2BAAmB,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACjE,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC5C,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE;QACpD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,SAAkC;YACvD,2BAAe,CAAC,OA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AO,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;AACL,CAAC","sourcesContent":["import * as ts from 'typescript';\n\nimport { ReflectionKind, SignatureReflection, ContainerReflection, DeclarationReflection, Type } from '../../models/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { createParameter } from './parameter';\nimport { createReferenceType } from './reference';\n\n/**\n * Create a new signature reflection from the given node.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The TypeScript node containing the signature declaration that should be reflected.\n * @param name The name of the function or method this signature belongs to.\n * @param kind The desired kind of the reflection.\n * @returns The newly created signature reflection describing the given node.\n */\nexport function createSignature(context: Context, node: ts.SignatureDeclaration, name: string, kind: ReflectionKind): SignatureReflection {\n const container = context.scope;\n if (!(container instanceof ContainerReflection)) {\n throw new Error('Expected container reflection.');\n }\n\n const signature = new SignatureReflection(container, name, kind);\n context.registerReflection(signature, node);\n context.withScope(signature, node.typeParameters, true, () => {\n node.parameters.forEach((parameter: ts.ParameterDeclaration) => {\n createParameter(context, parameter);\n });\n\n signature.type = extractSignatureType(context, node);\n\n if (container.inheritedFrom) {\n signature.inheritedFrom = createReferenceType(context, node.symbol, true);\n }\n });\n\n context.trigger(Converter.EVENT_CREATE_SIGNATURE, signature, node);\n return signature;\n}\n\n/**\n * Extract the return type of the given signature declaration.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The signature declaration whose return type should be determined.\n * @returns The return type reflection of the given signature.\n */\nfunction extractSignatureType(context: Context, node: ts.SignatureDeclaration): Type {\n const checker = context.checker;\n if (node.kind & ts.SyntaxKind.CallSignature || node.kind & ts.SyntaxKind.CallExpression) {\n try {\n const signature = checker.getSignatureFromDeclaration(node);\n return context.converter.convertType(context, node.type, checker.getReturnTypeOfSignature(signature));\n } catch (error) {}\n }\n\n if (node.type) {\n return context.converter.convertType(context, node.type);\n } else {\n return context.converter.convertType(context, node);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/factories/type-parameter.d.ts b/dist/lib/converter/factories/type-parameter.d.ts new file mode 100644 index 000000000..9c3ac07f6 --- /dev/null +++ b/dist/lib/converter/factories/type-parameter.d.ts @@ -0,0 +1,4 @@ +import * as ts from 'typescript'; +import { TypeParameterType } from '../../models/index'; +import { Context } from '../context'; +export declare function createTypeParameter(context: Context, node: ts.TypeParameterDeclaration): TypeParameterType; diff --git a/dist/lib/converter/factories/type-parameter.js b/dist/lib/converter/factories/type-parameter.js new file mode 100644 index 000000000..5f4ad307f --- /dev/null +++ b/dist/lib/converter/factories/type-parameter.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/index"); +var converter_1 = require("../converter"); +function createTypeParameter(context, node) { + var typeParameter = new index_1.TypeParameterType(); + typeParameter.name = node.symbol.name; + if (node.constraint) { + typeParameter.constraint = context.converter.convertType(context, node.constraint); + } + var reflection = context.scope; + var typeParameterReflection = new index_1.TypeParameterReflection(reflection, typeParameter); + if (!reflection.typeParameters) { + reflection.typeParameters = []; + } + reflection.typeParameters.push(typeParameterReflection); + context.registerReflection(typeParameterReflection, node); + context.trigger(converter_1.Converter.EVENT_CREATE_TYPE_PARAMETER, typeParameterReflection, node); + return typeParameter; +} +exports.createTypeParameter = createTypeParameter; +//# sourceMappingURL=type-parameter.js.map \ No newline at end of file diff --git a/dist/lib/converter/factories/type-parameter.js.map b/dist/lib/converter/factories/type-parameter.js.map new file mode 100644 index 000000000..c9b71a7b3 --- /dev/null +++ b/dist/lib/converter/factories/type-parameter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"type-parameter.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/type-parameter.ts"],"names":[],"mappings":";;AAEA,4CAAwG;AAExG,0CAAyC;AASzC,6BAAoC,OAAgB,EAAE,IAAiC;IACnF,IAAM,aAAa,GAAG,IAAI,yBAAiB,EAAE,CAAC;IAC9C,aAAa,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACtC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAClB,aAAa,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvF,CAAC;IAED,IAAM,UAAU,GAA4B,OAAO,CAAC,KAAK,CAAC;IAC1D,IAAM,uBAAuB,GAAG,IAAI,+BAAuB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAEvF,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7B,UAAU,CAAC,cAAc,GAAG,EAAE,CAAC;IACnC,CAAC;IACD,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAExD,OAAO,CAAC,kBAAkB,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;IAC1D,OAAO,CAAC,OAAO,CAAC,qBAAS,CAAC,2BAA2B,EAAE,uBAAuB,EAAE,IAAI,CAAC,CAAC;IAEtF,MAAM,CAAC,aAAa,CAAC;AACzB,CAAC;AAnBD,kDAmBC","sourcesContent":["import * as ts from 'typescript';\n\nimport { TypeParameterContainer, TypeParameterReflection, TypeParameterType } from '../../models/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\n\n/**\n * Create a type parameter reflection for the given node.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The type parameter node that should be reflected.\n * @returns The newly created type parameter reflection.\n */\nexport function createTypeParameter(context: Context, node: ts.TypeParameterDeclaration): TypeParameterType {\n const typeParameter = new TypeParameterType();\n typeParameter.name = node.symbol.name;\n if (node.constraint) {\n typeParameter.constraint = context.converter.convertType(context, node.constraint);\n }\n\n const reflection = context.scope;\n const typeParameterReflection = new TypeParameterReflection(reflection, typeParameter);\n\n if (!reflection.typeParameters) {\n reflection.typeParameters = [];\n }\n reflection.typeParameters.push(typeParameterReflection);\n\n context.registerReflection(typeParameterReflection, node);\n context.trigger(Converter.EVENT_CREATE_TYPE_PARAMETER, typeParameterReflection, node);\n\n return typeParameter;\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/index.d.ts b/dist/lib/converter/index.d.ts new file mode 100644 index 000000000..754b9425b --- /dev/null +++ b/dist/lib/converter/index.d.ts @@ -0,0 +1,6 @@ +export { Context } from './context'; +export { Converter } from './converter'; +export { convertDefaultValue, convertExpression } from './convert-expression'; +import './nodes/index'; +import './types/index'; +import './plugins/index'; diff --git a/dist/lib/converter/index.js b/dist/lib/converter/index.js new file mode 100644 index 000000000..db75f739d --- /dev/null +++ b/dist/lib/converter/index.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var context_1 = require("./context"); +exports.Context = context_1.Context; +var converter_1 = require("./converter"); +exports.Converter = converter_1.Converter; +var convert_expression_1 = require("./convert-expression"); +exports.convertDefaultValue = convert_expression_1.convertDefaultValue; +exports.convertExpression = convert_expression_1.convertExpression; +require("./nodes/index"); +require("./types/index"); +require("./plugins/index"); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/converter/index.js.map b/dist/lib/converter/index.js.map new file mode 100644 index 000000000..0bb8e26a0 --- /dev/null +++ b/dist/lib/converter/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/converter/index.ts"],"names":[],"mappings":";;AAAA,qCAAoC;AAA3B,4BAAA,OAAO,CAAA;AAChB,yCAAwC;AAA/B,gCAAA,SAAS,CAAA;AAElB,2DAA8E;AAArE,mDAAA,mBAAmB,CAAA;AAAE,iDAAA,iBAAiB,CAAA;AAE/C,yBAAuB;AACvB,yBAAuB;AACvB,2BAAyB","sourcesContent":["export { Context } from './context';\nexport { Converter } from './converter';\n\nexport { convertDefaultValue, convertExpression } from './convert-expression';\n\nimport './nodes/index';\nimport './types/index';\nimport './plugins/index';\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/accessor.d.ts b/dist/lib/converter/nodes/accessor.d.ts new file mode 100644 index 000000000..d1aa425a7 --- /dev/null +++ b/dist/lib/converter/nodes/accessor.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class AccessorConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.SignatureDeclaration): Reflection; +} diff --git a/dist/lib/converter/nodes/accessor.js b/dist/lib/converter/nodes/accessor.js new file mode 100644 index 000000000..f2085f1ae --- /dev/null +++ b/dist/lib/converter/nodes/accessor.js @@ -0,0 +1,51 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var AccessorConverter = (function (_super) { + __extends(AccessorConverter, _super); + function AccessorConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.GetAccessor, + ts.SyntaxKind.SetAccessor + ]; + return _this; + } + AccessorConverter.prototype.convert = function (context, node) { + var accessor = index_2.createDeclaration(context, node, index_1.ReflectionKind.Accessor); + context.withScope(accessor, function () { + if (node.kind === ts.SyntaxKind.GetAccessor) { + accessor.getSignature = index_2.createSignature(context, node, '__get', index_1.ReflectionKind.GetSignature); + } + else { + accessor.setSignature = index_2.createSignature(context, node, '__set', index_1.ReflectionKind.SetSignature); + } + }); + return accessor; + }; + AccessorConverter = __decorate([ + components_1.Component({ name: 'node:accessor' }) + ], AccessorConverter); + return AccessorConverter; +}(components_1.ConverterNodeComponent)); +exports.AccessorConverter = AccessorConverter; +//# sourceMappingURL=accessor.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/accessor.js.map b/dist/lib/converter/nodes/accessor.js.map new file mode 100644 index 000000000..ee8d58e2c --- /dev/null +++ b/dist/lib/converter/nodes/accessor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"accessor.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/accessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAgE;AAChE,4CAAwE;AAExE,4CAAkE;AAGlE;IAAuC,qCAA+C;IADtF;QAAA,qEA8BC;QAzBG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,WAAW;YACzB,EAAE,CAAC,UAAU,CAAC,WAAW;SAC5B,CAAC;;IAsBN,CAAC;IAbG,mCAAO,GAAP,UAAQ,OAAgB,EAAE,IAA6B;QACnD,IAAM,QAAQ,GAAG,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,sBAAc,CAAC,QAAQ,CAAC,CAAC;QAE3E,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;YACxB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC1C,QAAQ,CAAC,YAAY,GAAG,uBAAe,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,sBAAc,CAAC,YAAY,CAAC,CAAC;YACjG,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,QAAQ,CAAC,YAAY,GAAG,uBAAe,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,sBAAc,CAAC,YAAY,CAAC,CAAC;YACjG,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,QAAQ,CAAC;IACpB,CAAC;IA5BQ,iBAAiB;QAD7B,sBAAS,CAAC,EAAC,IAAI,EAAE,eAAe,EAAC,CAAC;OACtB,iBAAiB,CA6B7B;IAAD,wBAAC;CAAA,AA7BD,CAAuC,mCAAsB,GA6B5D;AA7BY,8CAAiB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind } from '../../models/index';\nimport { createDeclaration, createSignature } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:accessor'})\nexport class AccessorConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.GetAccessor,\n ts.SyntaxKind.SetAccessor\n ];\n\n /**\n * Analyze the given getter declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The signature declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.SignatureDeclaration): Reflection {\n const accessor = createDeclaration(context, node, ReflectionKind.Accessor);\n\n context.withScope(accessor, () => {\n if (node.kind === ts.SyntaxKind.GetAccessor) {\n accessor.getSignature = createSignature(context, node, '__get', ReflectionKind.GetSignature);\n } else {\n accessor.setSignature = createSignature(context, node, '__set', ReflectionKind.SetSignature);\n }\n });\n\n return accessor;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/alias.d.ts b/dist/lib/converter/nodes/alias.d.ts new file mode 100644 index 000000000..e9cb497e1 --- /dev/null +++ b/dist/lib/converter/nodes/alias.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class AliasConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.TypeAliasDeclaration): Reflection; +} diff --git a/dist/lib/converter/nodes/alias.js b/dist/lib/converter/nodes/alias.js new file mode 100644 index 000000000..6bf995705 --- /dev/null +++ b/dist/lib/converter/nodes/alias.js @@ -0,0 +1,46 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var AliasConverter = (function (_super) { + __extends(AliasConverter, _super); + function AliasConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.TypeAliasDeclaration + ]; + return _this; + } + AliasConverter.prototype.convert = function (context, node) { + var _this = this; + var alias = index_2.createDeclaration(context, node, index_1.ReflectionKind.TypeAlias); + context.withScope(alias, node.typeParameters, function () { + alias.type = _this.owner.convertType(context, node.type, context.getTypeAtLocation(node.type)); + }); + return alias; + }; + AliasConverter = __decorate([ + components_1.Component({ name: 'node:alias' }) + ], AliasConverter); + return AliasConverter; +}(components_1.ConverterNodeComponent)); +exports.AliasConverter = AliasConverter; +//# sourceMappingURL=alias.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/alias.js.map b/dist/lib/converter/nodes/alias.js.map new file mode 100644 index 000000000..85d9ea8b5 --- /dev/null +++ b/dist/lib/converter/nodes/alias.js.map @@ -0,0 +1 @@ +{"version":3,"file":"alias.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/alias.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAgE;AAChE,4CAAuD;AAEvD,4CAAkE;AAGlE;IAAoC,kCAA+C;IADnF;QAAA,qEAyBC;QApBG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,oBAAoB;SACrC,CAAC;;IAkBN,CAAC;IATG,gCAAO,GAAP,UAAQ,OAAgB,EAAE,IAA6B;QAAvD,iBAQC;QAPG,IAAM,KAAK,GAAG,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,sBAAc,CAAC,SAAS,CAAC,CAAC;QAEzE,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE;YAC1C,KAAK,CAAC,IAAI,GAAG,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAClG,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAvBQ,cAAc;QAD1B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,cAAc,CAwB1B;IAAD,qBAAC;CAAA,AAxBD,CAAoC,mCAAsB,GAwBzD;AAxBY,wCAAc","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:alias'})\nexport class AliasConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.TypeAliasDeclaration\n ];\n\n /**\n * Analyze the given type alias declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The type alias declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.TypeAliasDeclaration): Reflection {\n const alias = createDeclaration(context, node, ReflectionKind.TypeAlias);\n\n context.withScope(alias, node.typeParameters, () => {\n alias.type = this.owner.convertType(context, node.type, context.getTypeAtLocation(node.type));\n });\n\n return alias;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/block.d.ts b/dist/lib/converter/nodes/block.d.ts new file mode 100644 index 000000000..769c8d0ce --- /dev/null +++ b/dist/lib/converter/nodes/block.d.ts @@ -0,0 +1,15 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare enum SourceFileMode { + File = 0, + Modules = 1, +} +export declare class BlockConverter extends ConverterNodeComponent { + mode: number; + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.SourceFile | ts.Block | ts.ModuleBlock): Reflection; + private convertSourceFile(context, node); + private convertStatements(context, node); +} diff --git a/dist/lib/converter/nodes/block.js b/dist/lib/converter/nodes/block.js new file mode 100644 index 000000000..cb168de61 --- /dev/null +++ b/dist/lib/converter/nodes/block.js @@ -0,0 +1,107 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var component_1 = require("../../utils/component"); +var declaration_1 = require("../../utils/options/declaration"); +var prefered = [ + ts.SyntaxKind.ClassDeclaration, + ts.SyntaxKind.InterfaceDeclaration, + ts.SyntaxKind.EnumDeclaration +]; +var SourceFileMode; +(function (SourceFileMode) { + SourceFileMode[SourceFileMode["File"] = 0] = "File"; + SourceFileMode[SourceFileMode["Modules"] = 1] = "Modules"; +})(SourceFileMode = exports.SourceFileMode || (exports.SourceFileMode = {})); +var BlockConverter = (function (_super) { + __extends(BlockConverter, _super); + function BlockConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.Block, + ts.SyntaxKind.ModuleBlock, + ts.SyntaxKind.SourceFile + ]; + return _this; + } + BlockConverter.prototype.convert = function (context, node) { + if (node.kind === ts.SyntaxKind.SourceFile) { + this.convertSourceFile(context, node); + } + else { + this.convertStatements(context, node); + } + return context.scope; + }; + BlockConverter.prototype.convertSourceFile = function (context, node) { + var _this = this; + var result = context.scope; + context.withSourceFile(node, function () { + if (_this.mode === SourceFileMode.Modules) { + result = index_2.createDeclaration(context, node, index_1.ReflectionKind.ExternalModule, node.fileName); + context.withScope(result, function () { + _this.convertStatements(context, node); + result.setFlag(index_1.ReflectionFlag.Exported); + }); + } + else { + _this.convertStatements(context, node); + } + }); + return result; + }; + BlockConverter.prototype.convertStatements = function (context, node) { + var _this = this; + if (node.statements) { + var statements_1 = []; + node.statements.forEach(function (statement) { + if (prefered.indexOf(statement.kind) !== -1) { + _this.owner.convertNode(context, statement); + } + else { + statements_1.push(statement); + } + }); + statements_1.forEach(function (statement) { + _this.owner.convertNode(context, statement); + }); + } + }; + __decorate([ + component_1.Option({ + name: 'mode', + help: "Specifies the output mode the project is used to be compiled with: 'file' or 'modules'", + type: declaration_1.ParameterType.Map, + map: { + 'file': SourceFileMode.File, + 'modules': SourceFileMode.Modules + }, + defaultValue: SourceFileMode.Modules + }) + ], BlockConverter.prototype, "mode", void 0); + BlockConverter = __decorate([ + components_1.Component({ name: 'node:block' }) + ], BlockConverter); + return BlockConverter; +}(components_1.ConverterNodeComponent)); +exports.BlockConverter = BlockConverter; +//# sourceMappingURL=block.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/block.js.map b/dist/lib/converter/nodes/block.js.map new file mode 100644 index 000000000..2d7a33e15 --- /dev/null +++ b/dist/lib/converter/nodes/block.js.map @@ -0,0 +1 @@ +{"version":3,"file":"block.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/block.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAgF;AAChF,4CAAuD;AAEvD,4CAAkE;AAClE,mDAA+C;AAC/C,+DAAgE;AAEhE,IAAM,QAAQ,GAAoB;IAC9B,EAAE,CAAC,UAAU,CAAC,gBAAgB;IAC9B,EAAE,CAAC,UAAU,CAAC,oBAAoB;IAClC,EAAE,CAAC,UAAU,CAAC,eAAe;CAChC,CAAC;AAEF,IAAY,cAEX;AAFD,WAAY,cAAc;IACtB,mDAAI,CAAA;IAAE,yDAAO,CAAA;AACjB,CAAC,EAFW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAEzB;AAGD;IAAoC,kCAA6D;IADjG;QAAA,qEAkFC;QAjEG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UA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AAzB,UAA0B,OAAgB,EAAE,IAA2C;QAAvF,iBAgBC;QAfG,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YAClB,IAAM,YAAU,GAAmB,EAAE,CAAC;YAEtC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,SAAS;gBAC9B,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC1C,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;gBAC/C,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACJ,YAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,YAAU,CAAC,OAAO,CAAC,UAAC,SAAS;gBACzB,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IArED;QAVC,kBAAM,CAAC;YACJ,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,wFAAwF;YAC9F,IAAI,EAAE,2BAAa,CAAC,GAAG;YACvB,GAAG,EAAE;gBACD,MAAM,EAAE,cAAc,CAAC,IAAI;gBAC3B,SAAS,EAAE,cAAc,CAAC,OAAO;aACpC;YACD,YAAY,EAAE,cAAc,CAAC,OAAO;SACvC,CAAC;gDACW;IAXJ,cAAc;QAD1B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,cAAc,CAiF1B;IAAD,qBAAC;CAAA,AAjFD,CAAoC,mCAAsB,GAiFzD;AAjFY,wCAAc","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind, ReflectionFlag } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\nimport { Option } from '../../utils/component';\nimport { ParameterType } from '../../utils/options/declaration';\n\nconst prefered: ts.SyntaxKind[] = [\n ts.SyntaxKind.ClassDeclaration,\n ts.SyntaxKind.InterfaceDeclaration,\n ts.SyntaxKind.EnumDeclaration\n];\n\nexport enum SourceFileMode {\n File, Modules\n}\n\n@Component({name: 'node:block'})\nexport class BlockConverter extends ConverterNodeComponent {\n @Option({\n name: 'mode',\n help: \"Specifies the output mode the project is used to be compiled with: 'file' or 'modules'\",\n type: ParameterType.Map,\n map: {\n 'file': SourceFileMode.File,\n 'modules': SourceFileMode.Modules\n },\n defaultValue: SourceFileMode.Modules\n })\n mode: number;\n\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.Block,\n ts.SyntaxKind.ModuleBlock,\n ts.SyntaxKind.SourceFile\n ];\n\n /**\n * Analyze the given class declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The class declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.SourceFile|ts.Block|ts.ModuleBlock): Reflection {\n if (node.kind === ts.SyntaxKind.SourceFile) {\n this.convertSourceFile(context, node);\n } else {\n this.convertStatements(context, node);\n }\n\n return context.scope;\n }\n\n /**\n * Analyze the given source file node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The source file node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n private convertSourceFile(context: Context, node: ts.SourceFile): Reflection {\n let result = context.scope;\n\n context.withSourceFile(node, () => {\n if (this.mode === SourceFileMode.Modules) {\n result = createDeclaration(context, node, ReflectionKind.ExternalModule, node.fileName);\n context.withScope(result, () => {\n this.convertStatements(context, node);\n result.setFlag(ReflectionFlag.Exported);\n });\n } else {\n this.convertStatements(context, node);\n }\n });\n\n return result;\n }\n\n private convertStatements(context: Context, node: ts.SourceFile|ts.Block|ts.ModuleBlock) {\n if (node.statements) {\n const statements: ts.Statement[] = [];\n\n node.statements.forEach((statement) => {\n if (prefered.indexOf(statement.kind) !== -1) {\n this.owner.convertNode(context, statement);\n } else {\n statements.push(statement);\n }\n });\n\n statements.forEach((statement) => {\n this.owner.convertNode(context, statement);\n });\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/class.d.ts b/dist/lib/converter/nodes/class.d.ts new file mode 100644 index 000000000..1699e9296 --- /dev/null +++ b/dist/lib/converter/nodes/class.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class ClassConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.ClassDeclaration): Reflection; +} diff --git a/dist/lib/converter/nodes/class.js b/dist/lib/converter/nodes/class.js new file mode 100644 index 000000000..3637fcc8c --- /dev/null +++ b/dist/lib/converter/nodes/class.js @@ -0,0 +1,92 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var ClassConverter = (function (_super) { + __extends(ClassConverter, _super); + function ClassConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.ClassExpression, + ts.SyntaxKind.ClassDeclaration + ]; + return _this; + } + ClassConverter.prototype.convert = function (context, node) { + var _this = this; + var reflection; + if (context.isInherit && context.inheritParent === node) { + reflection = context.scope; + } + else { + reflection = index_2.createDeclaration(context, node, index_1.ReflectionKind.Class); + if (node.modifiers && node.modifiers.some(function (m) { return m.kind === ts.SyntaxKind.AbstractKeyword; })) { + reflection.setFlag(index_1.ReflectionFlag.Abstract, true); + } + } + context.withScope(reflection, node.typeParameters, function () { + if (node.members) { + node.members.forEach(function (member) { + var modifiers = ts.getCombinedModifierFlags(member); + var privateMember = (modifiers & ts.ModifierFlags.Private) > 0; + var protectedMember = (modifiers & ts.ModifierFlags.Protected) > 0; + var exclude = (context.converter.excludePrivate && privateMember) + || (context.converter.excludeProtected && protectedMember); + if (!exclude) { + _this.owner.convertNode(context, member); + } + }); + } + var baseType = _ts.getClassExtendsHeritageClauseElement(node); + if (baseType) { + var type = context.getTypeAtLocation(baseType); + if (!context.isInherit) { + if (!reflection.extendedTypes) { + reflection.extendedTypes = []; + } + reflection.extendedTypes.push(_this.owner.convertType(context, baseType, type)); + } + if (type && type.symbol) { + type.symbol.declarations.forEach(function (declaration) { + context.inherit(declaration, baseType.typeArguments); + }); + } + } + var implementedTypes = _ts.getClassImplementsHeritageClauseElements(node); + if (implementedTypes) { + implementedTypes.forEach(function (implementedType) { + if (!reflection.implementedTypes) { + reflection.implementedTypes = []; + } + reflection.implementedTypes.push(_this.owner.convertType(context, implementedType)); + }); + } + }); + return reflection; + }; + ClassConverter = __decorate([ + components_1.Component({ name: 'node:class' }) + ], ClassConverter); + return ClassConverter; +}(components_1.ConverterNodeComponent)); +exports.ClassConverter = ClassConverter; +//# sourceMappingURL=class.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/class.js.map b/dist/lib/converter/nodes/class.js.map new file mode 100644 index 000000000..39fa1c337 --- /dev/null +++ b/dist/lib/converter/nodes/class.js.map @@ -0,0 +1 @@ +{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/class.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,uCAAyC;AAEzC,4CAAuG;AACvG,4CAAuD;AAEvD,4CAAkE;AAGlE;IAAoC,kCAA2C;IAD/E;QAAA,qEA2EC;QAtEG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,eAAe;YAC7B,EAAE,CAAC,UAAU,CAAC,gBAAgB;SACjC,CAAC;;IAmEN,CAAC;IA1DG,gCAAO,GAAP,UAAQ,OAAgB,EAAE,IAAyB;QAAnD,iBAyDC;QAxDG,IAAI,UAAiC,CAAC;QACtC,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC;YACtD,UAAU,GAA2B,OAAO,CAAC,KAAK,CAAC;QACvD,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,UAAU,GAAG,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,sBAAc,CAAC,KAAK,CAAC,CAAC;YAEpE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,EAAxC,CAAwC,CAAE,CAAC,CAAC,CAAC;gBACzF,UAAU,CAAC,OAAO,CAAC,sBAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE;YAC/C,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;g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,CAAC;oBACtB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAC,WAAW;wBACzC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;oBACzD,CAAC,CAAC,CAAC;gBACP,CAAC;YACL,CAAC;YAED,IAAM,gBAAgB,GAAG,GAAG,CAAC,wCAAwC,CAAC,IAAI,CAAC,CAAC;YAC5E,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBACnB,gBAAgB,CAAC,OAAO,CAAC,UAAC,eAAe;oBACrC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC;wBAC/B,UAAU,CAAC,gBAAgB,GAAG,EAAE,CAAC;oBACrC,CAAC;oBAED,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;gBACvF,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,UAAU,CAAC;IACtB,CAAC;IAzEQ,cAAc;QAD1B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,cAAc,CA0E1B;IAAD,qBAAC;CAAA,AA1ED,CAAoC,mCAAsB,GA0EzD;AA1EY,wCAAc","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection, ReflectionFlag, ReflectionKind, DeclarationReflection } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:class'})\nexport class ClassConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.ClassExpression,\n ts.SyntaxKind.ClassDeclaration\n ];\n\n /**\n * Analyze the given class declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The class declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.ClassDeclaration): Reflection {\n let reflection: DeclarationReflection;\n if (context.isInherit && context.inheritParent === node) {\n reflection = context.scope;\n } else {\n reflection = createDeclaration(context, node, ReflectionKind.Class);\n // set possible abstract flag here, where node is not the inherited parent\n if (node.modifiers && node.modifiers.some( m => m.kind === ts.SyntaxKind.AbstractKeyword )) {\n reflection.setFlag(ReflectionFlag.Abstract, true);\n }\n }\n\n context.withScope(reflection, node.typeParameters, () => {\n if (node.members) {\n node.members.forEach((member) => {\n const modifiers = ts.getCombinedModifierFlags(member);\n const privateMember = (modifiers & ts.ModifierFlags.Private) > 0;\n const protectedMember = (modifiers & ts.ModifierFlags.Protected) > 0;\n const exclude = (context.converter.excludePrivate && privateMember)\n || (context.converter.excludeProtected && protectedMember);\n\n if (!exclude) {\n this.owner.convertNode(context, member);\n }\n });\n }\n\n const baseType = _ts.getClassExtendsHeritageClauseElement(node);\n if (baseType) {\n const type = context.getTypeAtLocation(baseType);\n if (!context.isInherit) {\n if (!reflection.extendedTypes) {\n reflection.extendedTypes = [];\n }\n reflection.extendedTypes.push(this.owner.convertType(context, baseType, type));\n }\n\n if (type && type.symbol) {\n type.symbol.declarations.forEach((declaration) => {\n context.inherit(declaration, baseType.typeArguments);\n });\n }\n }\n\n const implementedTypes = _ts.getClassImplementsHeritageClauseElements(node);\n if (implementedTypes) {\n implementedTypes.forEach((implementedType) => {\n if (!reflection.implementedTypes) {\n reflection.implementedTypes = [];\n }\n\n reflection.implementedTypes.push(this.owner.convertType(context, implementedType));\n });\n }\n });\n\n return reflection;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/constructor.d.ts b/dist/lib/converter/nodes/constructor.d.ts new file mode 100644 index 000000000..cc00baf00 --- /dev/null +++ b/dist/lib/converter/nodes/constructor.d.ts @@ -0,0 +1,9 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class ConstructorConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.ConstructorDeclaration): Reflection; + private addParameterProperty(context, parameter, comment); +} diff --git a/dist/lib/converter/nodes/constructor.js b/dist/lib/converter/nodes/constructor.js new file mode 100644 index 000000000..56c0a9857 --- /dev/null +++ b/dist/lib/converter/nodes/constructor.js @@ -0,0 +1,95 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var converter_1 = require("../converter"); +var components_1 = require("../components"); +var ConstructorConverter = (function (_super) { + __extends(ConstructorConverter, _super); + function ConstructorConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.Constructor, + ts.SyntaxKind.ConstructSignature + ]; + return _this; + } + ConstructorConverter.prototype.convert = function (context, node) { + var parent = context.scope; + var hasBody = !!node.body; + var method = index_2.createDeclaration(context, node, index_1.ReflectionKind.Constructor, 'constructor'); + if (node.parameters && node.parameters.length) { + var comment = method ? method.comment : index_2.createComment(node); + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + this.addParameterProperty(context, parameter, comment); + } + } + context.withScope(method, function () { + if (!hasBody || !method.signatures) { + var name_1 = 'new ' + parent.name; + var signature = index_2.createSignature(context, node, name_1, index_1.ReflectionKind.ConstructorSignature); + if (!node.type) { + signature.type = new index_1.ReferenceType(parent.name, index_1.ReferenceType.SYMBOL_ID_RESOLVED, parent); + } + method.signatures = method.signatures || []; + method.signatures.push(signature); + } + else { + context.trigger(converter_1.Converter.EVENT_FUNCTION_IMPLEMENTATION, method, node); + } + }); + return method; + }; + ConstructorConverter.prototype.addParameterProperty = function (context, parameter, comment) { + var modifiers = ts.getCombinedModifierFlags(parameter); + var visibility = modifiers & (ts.ModifierFlags.Public | ts.ModifierFlags.Protected | + ts.ModifierFlags.Private | ts.ModifierFlags.Readonly); + if (!visibility) { + return; + } + var privateParameter = modifiers & ts.ModifierFlags.Private; + if (privateParameter && context.converter.excludePrivate) { + return; + } + var protectedParameter = modifiers & ts.ModifierFlags.Protected; + if (protectedParameter && context.converter.excludeProtected) { + return; + } + var property = index_2.createDeclaration(context, parameter, index_1.ReflectionKind.Property); + if (!property) { + return; + } + property.setFlag(index_1.ReflectionFlag.Static, false); + property.type = this.owner.convertType(context, parameter.type, context.getTypeAtLocation(parameter)); + if (comment) { + var tag = comment.getTag('param', property.name); + if (tag && tag.text) { + property.comment = new index_1.Comment(tag.text); + } + } + }; + ConstructorConverter = __decorate([ + components_1.Component({ name: 'node:constructor' }) + ], ConstructorConverter); + return ConstructorConverter; +}(components_1.ConverterNodeComponent)); +exports.ConstructorConverter = ConstructorConverter; +//# sourceMappingURL=constructor.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/constructor.js.map b/dist/lib/converter/nodes/constructor.js.map new file mode 100644 index 000000000..4a6b70ed5 --- /dev/null +++ b/dist/lib/converter/nodes/constructor.js.map @@ -0,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,IAAM,kBAAkB,GAAG,SAAS,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC;QAClE,EAAE,CAAC,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;YAC3D,MAAM,CAAC;QACX,CAAC;QAED,IAAM,QAAQ,GAAG,yBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,sBAAc,CAAC,QAAQ,CAAC,CAAC;QAChF,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACZ,MAAM,CAAC;QACX,CAAC;QAED,QAAQ,CAAC,OAAO,CAAC,sBAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC/C,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;QAEtG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACV,IAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YACnD,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;gBAClB,QAAQ,CAAC,OAAO,GAAG,IAAI,eAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC7C,CAAC;QACL,CAAC;IACL,CAAC;IArFQ,oBAAoB;QADhC,sBAAS,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC;OACzB,oBAAoB,CAsFhC;IAAD,2BAAC;CAAA,AAtFD,CAA0C,mCAAsB,GAsF/D;AAtFY,oDAAoB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind, ReflectionFlag, ReferenceType, Comment } from '../../models/index';\nimport { createDeclaration, createSignature, createComment } from '../factories/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:constructor'})\nexport class ConstructorConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.Constructor,\n ts.SyntaxKind.ConstructSignature\n ];\n\n /**\n * Analyze the given constructor declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The constructor declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.ConstructorDeclaration): Reflection {\n const parent = context.scope;\n const hasBody = !!node.body;\n const method = createDeclaration(context, node, ReflectionKind.Constructor, 'constructor');\n\n if (node.parameters && node.parameters.length) {\n const comment = method ? method.comment : createComment(node);\n for (let parameter of node.parameters) {\n this.addParameterProperty(context, parameter, comment);\n }\n }\n\n context.withScope(method, () => {\n if (!hasBody || !method.signatures) {\n const name = 'new ' + parent.name;\n const signature = createSignature(context, node, name, ReflectionKind.ConstructorSignature);\n // If no return type defined, use the parent one.\n if (!node.type) {\n signature.type = new ReferenceType(parent.name, ReferenceType.SYMBOL_ID_RESOLVED, parent);\n }\n method.signatures = method.signatures || [];\n method.signatures.push(signature);\n } else {\n context.trigger(Converter.EVENT_FUNCTION_IMPLEMENTATION, method, node);\n }\n });\n\n return method;\n }\n\n /**\n * Analyze parameters in given constructor declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The constructor declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n private addParameterProperty(context: Context, parameter: ts.ParameterDeclaration, comment: Comment) {\n const modifiers = ts.getCombinedModifierFlags(parameter);\n const visibility = modifiers & (ts.ModifierFlags.Public | ts.ModifierFlags.Protected |\n ts.ModifierFlags.Private | ts.ModifierFlags.Readonly);\n if (!visibility) {\n return;\n }\n\n const privateParameter = modifiers & ts.ModifierFlags.Private;\n if (privateParameter && context.converter.excludePrivate) {\n return;\n }\n\n const protectedParameter = modifiers & ts.ModifierFlags.Protected;\n if (protectedParameter && context.converter.excludeProtected) {\n return;\n }\n\n const property = createDeclaration(context, parameter, ReflectionKind.Property);\n if (!property) {\n return;\n }\n\n property.setFlag(ReflectionFlag.Static, false);\n property.type = this.owner.convertType(context, parameter.type, context.getTypeAtLocation(parameter));\n\n if (comment) {\n const tag = comment.getTag('param', property.name);\n if (tag && tag.text) {\n property.comment = new Comment(tag.text);\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/enum.d.ts b/dist/lib/converter/nodes/enum.d.ts new file mode 100644 index 000000000..9b6240c01 --- /dev/null +++ b/dist/lib/converter/nodes/enum.d.ts @@ -0,0 +1,9 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class EnumConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.EnumDeclaration): Reflection; + private convertMember(context, node); +} diff --git a/dist/lib/converter/nodes/enum.js b/dist/lib/converter/nodes/enum.js new file mode 100644 index 000000000..787080830 --- /dev/null +++ b/dist/lib/converter/nodes/enum.js @@ -0,0 +1,59 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var index_3 = require("../index"); +var EnumConverter = (function (_super) { + __extends(EnumConverter, _super); + function EnumConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.EnumDeclaration + ]; + return _this; + } + EnumConverter.prototype.convert = function (context, node) { + var _this = this; + var enumeration = index_2.createDeclaration(context, node, index_1.ReflectionKind.Enum); + context.withScope(enumeration, function () { + if (node.members) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + _this.convertMember(context, member); + } + } + }); + return enumeration; + }; + EnumConverter.prototype.convertMember = function (context, node) { + var member = index_2.createDeclaration(context, node, index_1.ReflectionKind.EnumMember); + if (member) { + member.defaultValue = index_3.convertDefaultValue(node); + } + return member; + }; + EnumConverter = __decorate([ + components_1.Component({ name: 'node:enum' }) + ], EnumConverter); + return EnumConverter; +}(components_1.ConverterNodeComponent)); +exports.EnumConverter = EnumConverter; +//# sourceMappingURL=enum.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/enum.js.map b/dist/lib/converter/nodes/enum.js.map new file mode 100644 index 000000000..403ba89df --- /dev/null +++ b/dist/lib/converter/nodes/enum.js.map @@ -0,0 +1 @@ +{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/enum.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAgE;AAChE,4CAAuD;AAEvD,4CAAkE;AAClE,kCAA+C;AAG/C;IAAmC,iCAA0C;IAD7E;QAAA,qEA6CC;QAxCG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,eAAe;SAChC,CAAC;;IAsCN,CAAC;IA7BG,+BAAO,GAAP,UAAQ,OAAgB,EAAE,IAAwB;QAAlD,iBAYC;QAXG,IAAM,WAAW,GAAG,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,sBAAc,CAAC,IAAI,CAAC,CAAC;QAE1E,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE;YAC3B,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBACf,GAAG,CAAC,CAAe,UAAY,EAAZ,KAAA,IAAI,CAAC,OAAO,EAAZ,cAAY,EAAZ,IAAY;oBAA1B,IAAI,MAAM,SAAA;oBACX,KAAI,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;iBACvC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,WAAW,CAAC;IACvB,CAAC;IASO,qCAAa,GAArB,UAAsB,OAAgB,EAAE,IAAmB;QACvD,IAAM,MAAM,GAAG,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,sBAAc,CAAC,UAAU,CAAC,CAAC;QAC3E,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACT,MAAM,CAAC,YAAY,GAAG,2BAAmB,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IA3CQ,aAAa;QADzB,sBAAS,CAAC,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC;OAClB,aAAa,CA4CzB;IAAD,oBAAC;CAAA,AA5CD,CAAmC,mCAAsB,GA4CxD;AA5CY,sCAAa","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\nimport { convertDefaultValue } from '../index';\n\n@Component({name: 'node:enum'})\nexport class EnumConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.EnumDeclaration\n ];\n\n /**\n * Analyze the given enumeration declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The enumeration declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.EnumDeclaration): Reflection {\n const enumeration = createDeclaration(context, node, ReflectionKind.Enum);\n\n context.withScope(enumeration, () => {\n if (node.members) {\n for (let member of node.members) {\n this.convertMember(context, member);\n }\n }\n });\n\n return enumeration;\n }\n\n /**\n * Analyze the given enumeration member node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The enumeration member node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n private convertMember(context: Context, node: ts.EnumMember): Reflection {\n const member = createDeclaration(context, node, ReflectionKind.EnumMember);\n if (member) {\n member.defaultValue = convertDefaultValue(node);\n }\n\n return member;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/export.d.ts b/dist/lib/converter/nodes/export.d.ts new file mode 100644 index 000000000..e5b3a0668 --- /dev/null +++ b/dist/lib/converter/nodes/export.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class ExportConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.ExportAssignment): Reflection; +} diff --git a/dist/lib/converter/nodes/export.js b/dist/lib/converter/nodes/export.js new file mode 100644 index 000000000..05b836348 --- /dev/null +++ b/dist/lib/converter/nodes/export.js @@ -0,0 +1,71 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var components_1 = require("../components"); +var ExportConverter = (function (_super) { + __extends(ExportConverter, _super); + function ExportConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.ExportAssignment + ]; + return _this; + } + ExportConverter.prototype.convert = function (context, node) { + var symbol = undefined; + if (node.symbol && (node.symbol.flags & ts.SymbolFlags.Alias) === ts.SymbolFlags.Alias) { + symbol = context.checker.getAliasedSymbol(node.symbol); + } + else { + var type = context.getTypeAtLocation(node.expression); + symbol = type ? type.symbol : undefined; + } + if (symbol && symbol.declarations) { + var project_1 = context.project; + symbol.declarations.forEach(function (declaration) { + if (!declaration.symbol) { + return; + } + var id = project_1.symbolMapping[context.getSymbolID(declaration.symbol)]; + if (!id) { + return; + } + var reflection = project_1.reflections[id]; + if (node.isExportEquals && reflection instanceof index_1.DeclarationReflection) { + reflection.setFlag(index_1.ReflectionFlag.ExportAssignment, true); + } + markAsExported(reflection); + }); + } + function markAsExported(reflection) { + if (reflection instanceof index_1.DeclarationReflection) { + reflection.setFlag(index_1.ReflectionFlag.Exported, true); + } + reflection.traverse(markAsExported); + } + return context.scope; + }; + ExportConverter = __decorate([ + components_1.Component({ name: 'node:export' }) + ], ExportConverter); + return ExportConverter; +}(components_1.ConverterNodeComponent)); +exports.ExportConverter = ExportConverter; +//# sourceMappingURL=export.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/export.js.map b/dist/lib/converter/nodes/export.js.map new file mode 100644 index 000000000..f9d9ff5c0 --- /dev/null +++ b/dist/lib/converter/nodes/export.js.map @@ -0,0 +1 @@ +{"version":3,"file":"export.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/export.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAuF;AAEvF,4CAAkE;AAGlE;IAAqC,mCAA2C;IADhF;QAAA,qEAgDC;QA3CG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,gBAAgB;SACjC,CAAC;;IAyCN,CAAC;IAvCG,iCAAO,GAAP,UAAQ,OAAgB,EAAE,IAAyB;QAC/C,IAAI,MAAM,GAAc,SAAS,CAAC;QAGlC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;YACrF,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3D,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,IAAI,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACtD,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5C,CAAC;QACD,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;YAChC,IAAM,SAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YAChC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAC,WAAW;gBACpC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;oBACtB,MAAM,CAAC;gBACX,CAAC;gBACD,IAAM,EAAE,GAAG,SAAO,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC1E,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACN,MAAM,CAAC;gBACX,CAAC;gBAED,IAAM,UAAU,GAAG,SAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;gBAC3C,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,UAAU,YAAY,6BAAqB,CAAC,CAAC,CAAC;oBAC5C,UAAW,CAAC,OAAO,CAAC,sBAAc,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;gBACxF,CAAC;gBACD,cAAc,CAAC,UAAU,CAAC,CAAC;YAC/B,CAAC,CAAC,CAAC;QACP,CAAC;QAED,wBAAwB,UAAsB;YAC1C,EAAE,CAAC,CAAC,UAAU,YAAY,6BAAqB,CAAC,CAAC,CAAC;gBACrB,UAAW,CAAC,OAAO,CAAC,sBAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAChF,CAAC;YAED,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QACxC,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IA9CQ,eAAe;QAD3B,sBAAS,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC,CAAC;OACpB,eAAe,CA+C3B;IAAD,sBAAC;CAAA,AA/CD,CAAqC,mCAAsB,GA+C1D;AA/CY,0CAAe","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionFlag, DeclarationReflection } from '../../models/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:export'})\nexport class ExportConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.ExportAssignment\n ];\n\n convert(context: Context, node: ts.ExportAssignment): Reflection {\n let symbol: ts.Symbol = undefined;\n\n // default export\n if (node.symbol && (node.symbol.flags & ts.SymbolFlags.Alias) === ts.SymbolFlags.Alias) {\n symbol = context.checker.getAliasedSymbol(node.symbol);\n } else {\n let type = context.getTypeAtLocation(node.expression);\n symbol = type ? type.symbol : undefined;\n }\n if (symbol && symbol.declarations) {\n const project = context.project;\n symbol.declarations.forEach((declaration) => {\n if (!declaration.symbol) {\n return;\n }\n const id = project.symbolMapping[context.getSymbolID(declaration.symbol)];\n if (!id) {\n return;\n }\n\n const reflection = project.reflections[id];\n if (node.isExportEquals && reflection instanceof DeclarationReflection) {\n ( reflection).setFlag(ReflectionFlag.ExportAssignment, true);\n }\n markAsExported(reflection);\n });\n }\n\n function markAsExported(reflection: Reflection) {\n if (reflection instanceof DeclarationReflection) {\n ( reflection).setFlag(ReflectionFlag.Exported, true);\n }\n\n reflection.traverse(markAsExported);\n }\n\n return context.scope;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/function.d.ts b/dist/lib/converter/nodes/function.d.ts new file mode 100644 index 000000000..c553ee92e --- /dev/null +++ b/dist/lib/converter/nodes/function.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class FunctionConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.FunctionDeclaration | ts.MethodDeclaration): Reflection; +} diff --git a/dist/lib/converter/nodes/function.js b/dist/lib/converter/nodes/function.js new file mode 100644 index 000000000..c26b2de77 --- /dev/null +++ b/dist/lib/converter/nodes/function.js @@ -0,0 +1,66 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var converter_1 = require("../converter"); +var components_1 = require("../components"); +var FunctionConverter = (function (_super) { + __extends(FunctionConverter, _super); + function FunctionConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.MethodSignature, + ts.SyntaxKind.MethodDeclaration, + ts.SyntaxKind.FunctionDeclaration + ]; + return _this; + } + FunctionConverter.prototype.convert = function (context, node) { + var scope = context.scope; + var kind = scope.kind & index_1.ReflectionKind.ClassOrInterface ? index_1.ReflectionKind.Method : index_1.ReflectionKind.Function; + var hasBody = !!node.body; + var method = index_2.createDeclaration(context, node, kind); + if (method + && kind & index_1.ReflectionKind.Method + && node.modifiers + && node.modifiers.some(function (m) { return m.kind === ts.SyntaxKind.AbstractKeyword; })) { + method.setFlag(index_1.ReflectionFlag.Abstract, true); + } + context.withScope(method, function () { + if (!hasBody || !method.signatures) { + var signature = index_2.createSignature(context, node, method.name, index_1.ReflectionKind.CallSignature); + if (!method.signatures) { + method.signatures = []; + } + method.signatures.push(signature); + } + else { + context.trigger(converter_1.Converter.EVENT_FUNCTION_IMPLEMENTATION, method, node); + } + }); + return method; + }; + FunctionConverter = __decorate([ + components_1.Component({ name: 'node:function' }) + ], FunctionConverter); + return FunctionConverter; +}(components_1.ConverterNodeComponent)); +exports.FunctionConverter = FunctionConverter; +//# sourceMappingURL=function.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/function.js.map b/dist/lib/converter/nodes/function.js.map new file mode 100644 index 000000000..5e2fe527f --- /dev/null +++ b/dist/lib/converter/nodes/function.js.map @@ -0,0 +1 @@ +{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/function.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAgF;AAChF,4CAAwE;AAExE,0CAAyC;AACzC,4CAAkE;AAGlE;IAAuC,qCAAmE;IAD1G;QAAA,qEA6CC;QAxCG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,eAAe;YAC7B,EAAE,CAAC,UAAU,CAAC,iBAAiB;YAC/B,EAAE,CAAC,UAAU,CAAC,mBAAmB;SACpC,CAAC;;IAoCN,CAAC;IA3BG,mCAAO,GAAP,UAAQ,OAAgB,EAAE,IAAiD;QACvE,IAAM,KAAK,GAAK,OAAO,CAAC,KAAK,CAAC;QAC9B,IAAM,IAAI,GAAM,KAAK,CAAC,IAAI,GAAG,sBAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,sBAAc,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAc,CAAC,QAAQ,CAAC;QAC/G,IAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5B,IAAM,MAAM,GAAI,yBAAiB,CAAC,OAAO,EAAY,IAAI,EAAE,IAAI,CAAC,CAAC;QAEjE,EAAE,CAAC,CAAC,MAAM;eACH,IAAI,GAAG,sBAAc,CAAC,MAAM;eAC5B,IAAI,CAAC,SAAS;eACd,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,EAAxC,CAAwC,CAAE,CAAC,CAAC,CAAC;YAC5E,MAAM,CAAC,OAAO,CAAC,sBAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE;YACtB,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;gBACjC,IAAM,SAAS,GAAG,uBAAe,CAAC,OAAO,EAA4B,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,sBAAc,CAAC,aAAa,CAAC,CAAC;gBACtH,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;oBACrB,MAAM,CAAC,UAAU,GAAG,EAAE,CAAC;gBAC3B,CAAC;gBACD,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACtC,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,OAAO,CAAC,OAAO,CAAC,qBAAS,CAAC,6BAA6B,EAAE,MAAM,EAAY,IAAI,CAAC,CAAC;YACrF,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IA3CQ,iBAAiB;QAD7B,sBAAS,CAAC,EAAC,IAAI,EAAE,eAAe,EAAC,CAAC;OACtB,iBAAiB,CA4C7B;IAAD,wBAAC;CAAA,AA5CD,CAAuC,mCAAsB,GA4C5D;AA5CY,8CAAiB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionFlag, ReflectionKind } from '../../models/index';\nimport { createDeclaration, createSignature } from '../factories/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:function'})\nexport class FunctionConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.MethodSignature,\n ts.SyntaxKind.MethodDeclaration,\n ts.SyntaxKind.FunctionDeclaration\n ];\n\n /**\n * Analyze the given function declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The function declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.FunctionDeclaration|ts.MethodDeclaration): Reflection {\n const scope = context.scope;\n const kind = scope.kind & ReflectionKind.ClassOrInterface ? ReflectionKind.Method : ReflectionKind.Function;\n const hasBody = !!node.body;\n const method = createDeclaration(context, node, kind);\n\n if (method // child inheriting will return null on createDeclaration\n && kind & ReflectionKind.Method\n && node.modifiers\n && node.modifiers.some( m => m.kind === ts.SyntaxKind.AbstractKeyword )) {\n method.setFlag(ReflectionFlag.Abstract, true);\n }\n\n context.withScope(method, () => {\n if (!hasBody || !method.signatures) {\n const signature = createSignature(context, node, method.name, ReflectionKind.CallSignature);\n if (!method.signatures) {\n method.signatures = [];\n }\n method.signatures.push(signature);\n } else {\n context.trigger(Converter.EVENT_FUNCTION_IMPLEMENTATION, method, node);\n }\n });\n\n return method;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/index.d.ts b/dist/lib/converter/nodes/index.d.ts new file mode 100644 index 000000000..bdf4e681f --- /dev/null +++ b/dist/lib/converter/nodes/index.d.ts @@ -0,0 +1,16 @@ +export { AccessorConverter } from './accessor'; +export { AliasConverter } from './alias'; +export { BlockConverter } from './block'; +export { ClassConverter } from './class'; +export { ConstructorConverter } from './constructor'; +export { EnumConverter } from './enum'; +export { ExportConverter } from './export'; +export { FunctionConverter } from './function'; +export { InterfaceConverter } from './interface'; +export { TypeLiteralConverter } from './literal-type'; +export { ObjectLiteralConverter } from './literal-object'; +export { ModuleConverter } from './module'; +export { SignatureConverter } from './signature-call'; +export { IndexSignatureConverter } from './signature-index'; +export { VariableStatementConverter } from './variable-statement'; +export { VariableConverter } from './variable'; diff --git a/dist/lib/converter/nodes/index.js b/dist/lib/converter/nodes/index.js new file mode 100644 index 000000000..360bb60d5 --- /dev/null +++ b/dist/lib/converter/nodes/index.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var accessor_1 = require("./accessor"); +exports.AccessorConverter = accessor_1.AccessorConverter; +var alias_1 = require("./alias"); +exports.AliasConverter = alias_1.AliasConverter; +var block_1 = require("./block"); +exports.BlockConverter = block_1.BlockConverter; +var class_1 = require("./class"); +exports.ClassConverter = class_1.ClassConverter; +var constructor_1 = require("./constructor"); +exports.ConstructorConverter = constructor_1.ConstructorConverter; +var enum_1 = require("./enum"); +exports.EnumConverter = enum_1.EnumConverter; +var export_1 = require("./export"); +exports.ExportConverter = export_1.ExportConverter; +var function_1 = require("./function"); +exports.FunctionConverter = function_1.FunctionConverter; +var interface_1 = require("./interface"); +exports.InterfaceConverter = interface_1.InterfaceConverter; +var literal_type_1 = require("./literal-type"); +exports.TypeLiteralConverter = literal_type_1.TypeLiteralConverter; +var literal_object_1 = require("./literal-object"); +exports.ObjectLiteralConverter = literal_object_1.ObjectLiteralConverter; +var module_1 = require("./module"); +exports.ModuleConverter = module_1.ModuleConverter; +var signature_call_1 = require("./signature-call"); +exports.SignatureConverter = signature_call_1.SignatureConverter; +var signature_index_1 = require("./signature-index"); +exports.IndexSignatureConverter = signature_index_1.IndexSignatureConverter; +var variable_statement_1 = require("./variable-statement"); +exports.VariableStatementConverter = variable_statement_1.VariableStatementConverter; +var variable_1 = require("./variable"); +exports.VariableConverter = variable_1.VariableConverter; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/index.js.map b/dist/lib/converter/nodes/index.js.map new file mode 100644 index 000000000..558c14d53 --- /dev/null +++ b/dist/lib/converter/nodes/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/index.ts"],"names":[],"mappings":";;AAAA,uCAA+C;AAAtC,uCAAA,iBAAiB,CAAA;AAC1B,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,iCAAyC;AAAhC,iCAAA,cAAc,CAAA;AACvB,6CAAqD;AAA5C,6CAAA,oBAAoB,CAAA;AAC7B,+BAAuC;AAA9B,+BAAA,aAAa,CAAA;AACtB,mCAA2C;AAAlC,mCAAA,eAAe,CAAA;AACxB,uCAA+C;AAAtC,uCAAA,iBAAiB,CAAA;AAC1B,yCAAiD;AAAxC,yCAAA,kBAAkB,CAAA;AAC3B,+CAAsD;AAA7C,8CAAA,oBAAoB,CAAA;AAC7B,mDAA0D;AAAjD,kDAAA,sBAAsB,CAAA;AAC/B,mCAA2C;AAAlC,mCAAA,eAAe,CAAA;AACxB,mDAAsD;AAA7C,8CAAA,kBAAkB,CAAA;AAC3B,qDAA4D;AAAnD,oDAAA,uBAAuB,CAAA;AAChC,2DAAkE;AAAzD,0DAAA,0BAA0B,CAAA;AACnC,uCAA+C;AAAtC,uCAAA,iBAAiB,CAAA","sourcesContent":["export { AccessorConverter } from './accessor';\nexport { AliasConverter } from './alias';\nexport { BlockConverter } from './block';\nexport { ClassConverter } from './class';\nexport { ConstructorConverter } from './constructor';\nexport { EnumConverter } from './enum';\nexport { ExportConverter } from './export';\nexport { FunctionConverter } from './function';\nexport { InterfaceConverter } from './interface';\nexport { TypeLiteralConverter } from './literal-type';\nexport { ObjectLiteralConverter } from './literal-object';\nexport { ModuleConverter } from './module';\nexport { SignatureConverter } from './signature-call';\nexport { IndexSignatureConverter } from './signature-index';\nexport { VariableStatementConverter } from './variable-statement';\nexport { VariableConverter } from './variable';\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/interface.d.ts b/dist/lib/converter/nodes/interface.d.ts new file mode 100644 index 000000000..c6a49e0d4 --- /dev/null +++ b/dist/lib/converter/nodes/interface.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class InterfaceConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.InterfaceDeclaration): Reflection; +} diff --git a/dist/lib/converter/nodes/interface.js b/dist/lib/converter/nodes/interface.js new file mode 100644 index 000000000..906b84017 --- /dev/null +++ b/dist/lib/converter/nodes/interface.js @@ -0,0 +1,74 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var InterfaceConverter = (function (_super) { + __extends(InterfaceConverter, _super); + function InterfaceConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.InterfaceDeclaration + ]; + return _this; + } + InterfaceConverter.prototype.convert = function (context, node) { + var _this = this; + var reflection; + if (context.isInherit && context.inheritParent === node) { + reflection = context.scope; + } + else { + reflection = index_2.createDeclaration(context, node, index_1.ReflectionKind.Interface); + } + context.withScope(reflection, node.typeParameters, function () { + if (node.members) { + node.members.forEach(function (member, isInherit) { + _this.owner.convertNode(context, member); + }); + } + var baseTypes = _ts.getInterfaceBaseTypeNodes(node); + if (baseTypes) { + baseTypes.forEach(function (baseType) { + var type = context.getTypeAtLocation(baseType); + if (!context.isInherit) { + if (!reflection.extendedTypes) { + reflection.extendedTypes = []; + } + reflection.extendedTypes.push(_this.owner.convertType(context, baseType, type)); + } + if (type && type.symbol) { + type.symbol.declarations.forEach(function (declaration) { + context.inherit(declaration, baseType.typeArguments); + }); + } + }); + } + }); + return reflection; + }; + InterfaceConverter = __decorate([ + components_1.Component({ name: 'node:interface' }) + ], InterfaceConverter); + return InterfaceConverter; +}(components_1.ConverterNodeComponent)); +exports.InterfaceConverter = InterfaceConverter; +//# sourceMappingURL=interface.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/interface.js.map b/dist/lib/converter/nodes/interface.js.map new file mode 100644 index 000000000..924c3d1d9 --- /dev/null +++ b/dist/lib/converter/nodes/interface.js.map @@ -0,0 +1 @@ +{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/interface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,uCAAyC;AAEzC,4CAAuF;AACvF,4CAAuD;AAEvD,4CAAkE;AAGlE;IAAwC,sCAA+C;IADvF;QAAA,qEAqDC;QAhDG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,oBAAoB;SACrC,CAAC;;IA8CN,CAAC;IArCG,oCAAO,GAAP,UAAQ,OAAgB,EAAE,IAA6B;QAAvD,iBAoCC;QAnCG,IAAI,UAAiC,CAAC;QACtC,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC;YACtD,UAAU,GAA2B,OAAO,CAAC,KAAK,CAAC;QACvD,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,UAAU,GAAG,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,sBAAc,CAAC,SAAS,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE;YAC/C,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBACf,IAAI,CAAC,OAAO,CAAC,OAAO,C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ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection, ReflectionKind, DeclarationReflection } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:interface'})\nexport class InterfaceConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.InterfaceDeclaration\n ];\n\n /**\n * Analyze the given interface declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The interface declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.InterfaceDeclaration): Reflection {\n let reflection: DeclarationReflection;\n if (context.isInherit && context.inheritParent === node) {\n reflection = context.scope;\n } else {\n reflection = createDeclaration(context, node, ReflectionKind.Interface);\n }\n\n context.withScope(reflection, node.typeParameters, () => {\n if (node.members) {\n node.members.forEach((member, isInherit) => {\n this.owner.convertNode(context, member);\n });\n }\n\n const baseTypes = _ts.getInterfaceBaseTypeNodes(node);\n if (baseTypes) {\n baseTypes.forEach((baseType) => {\n const type = context.getTypeAtLocation(baseType);\n if (!context.isInherit) {\n if (!reflection.extendedTypes) {\n reflection.extendedTypes = [];\n }\n reflection.extendedTypes.push(this.owner.convertType(context, baseType, type));\n }\n\n if (type && type.symbol) {\n type.symbol.declarations.forEach((declaration) => {\n context.inherit(declaration, baseType.typeArguments);\n });\n }\n });\n }\n });\n\n return reflection;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/literal-object.d.ts b/dist/lib/converter/nodes/literal-object.d.ts new file mode 100644 index 000000000..76436d2d4 --- /dev/null +++ b/dist/lib/converter/nodes/literal-object.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class ObjectLiteralConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.ObjectLiteralExpression): Reflection; +} diff --git a/dist/lib/converter/nodes/literal-object.js b/dist/lib/converter/nodes/literal-object.js new file mode 100644 index 000000000..c6345fda2 --- /dev/null +++ b/dist/lib/converter/nodes/literal-object.js @@ -0,0 +1,45 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var components_1 = require("../components"); +var ObjectLiteralConverter = (function (_super) { + __extends(ObjectLiteralConverter, _super); + function ObjectLiteralConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.ObjectLiteralExpression + ]; + return _this; + } + ObjectLiteralConverter.prototype.convert = function (context, node) { + var _this = this; + if (node.properties) { + node.properties.forEach(function (node) { + _this.owner.convertNode(context, node); + }); + } + return context.scope; + }; + ObjectLiteralConverter = __decorate([ + components_1.Component({ name: 'node:literal-object' }) + ], ObjectLiteralConverter); + return ObjectLiteralConverter; +}(components_1.ConverterNodeComponent)); +exports.ObjectLiteralConverter = ObjectLiteralConverter; +//# sourceMappingURL=literal-object.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/literal-object.js.map b/dist/lib/converter/nodes/literal-object.js.map new file mode 100644 index 000000000..58509c39f --- /dev/null +++ b/dist/lib/converter/nodes/literal-object.js.map @@ -0,0 +1 @@ +{"version":3,"file":"literal-object.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/literal-object.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAIjC,4CAAkE;AAGlE;IAA4C,0CAAkD;IAD9F;QAAA,qEAyBC;QApBG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,uBAAuB;SACxC,CAAC;;IAkBN,CAAC;IATG,wCAAO,GAAP,UAAQ,OAAgB,EAAE,IAAgC;QAA1D,iBAQC;QAPG,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,IAAI;gBACzB,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACP,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IAvBQ,sBAAsB;QADlC,sBAAS,CAAC,EAAC,IAAI,EAAE,qBAAqB,EAAC,CAAC;OAC5B,sBAAsB,CAwBlC;IAAD,6BAAC;CAAA,AAxBD,CAA4C,mCAAsB,GAwBjE;AAxBY,wDAAsB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection } from '../../models/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:literal-object'})\nexport class ObjectLiteralConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.ObjectLiteralExpression\n ];\n\n /**\n * Analyze the given object literal node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The object literal node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.ObjectLiteralExpression): Reflection {\n if (node.properties) {\n node.properties.forEach((node) => {\n this.owner.convertNode(context, node);\n });\n }\n\n return context.scope;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/literal-type.d.ts b/dist/lib/converter/nodes/literal-type.d.ts new file mode 100644 index 000000000..01243c9b0 --- /dev/null +++ b/dist/lib/converter/nodes/literal-type.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class TypeLiteralConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.TypeLiteralNode): Reflection; +} diff --git a/dist/lib/converter/nodes/literal-type.js b/dist/lib/converter/nodes/literal-type.js new file mode 100644 index 000000000..93eb7d2f0 --- /dev/null +++ b/dist/lib/converter/nodes/literal-type.js @@ -0,0 +1,45 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var components_1 = require("../components"); +var TypeLiteralConverter = (function (_super) { + __extends(TypeLiteralConverter, _super); + function TypeLiteralConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.TypeLiteral + ]; + return _this; + } + TypeLiteralConverter.prototype.convert = function (context, node) { + var _this = this; + if (node.members) { + node.members.forEach(function (node) { + _this.owner.convertNode(context, node); + }); + } + return context.scope; + }; + TypeLiteralConverter = __decorate([ + components_1.Component({ name: 'node:literal-type' }) + ], TypeLiteralConverter); + return TypeLiteralConverter; +}(components_1.ConverterNodeComponent)); +exports.TypeLiteralConverter = TypeLiteralConverter; +//# sourceMappingURL=literal-type.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/literal-type.js.map b/dist/lib/converter/nodes/literal-type.js.map new file mode 100644 index 000000000..909784143 --- /dev/null +++ b/dist/lib/converter/nodes/literal-type.js.map @@ -0,0 +1 @@ +{"version":3,"file":"literal-type.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/literal-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAIjC,4CAAkE;AAGlE;IAA0C,wCAA0C;IADpF;QAAA,qEAyBC;QApBG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,WAAW;SAC5B,CAAC;;IAkBN,CAAC;IATG,sCAAO,GAAP,UAAQ,OAAgB,EAAE,IAAwB;QAAlD,iBAQC;QAPG,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAC,IAAI;gBACtB,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACP,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IAvBQ,oBAAoB;QADhC,sBAAS,CAAC,EAAC,IAAI,EAAE,mBAAmB,EAAC,CAAC;OAC1B,oBAAoB,CAwBhC;IAAD,2BAAC;CAAA,AAxBD,CAA0C,mCAAsB,GAwB/D;AAxBY,oDAAoB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection } from '../../models/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:literal-type'})\nexport class TypeLiteralConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.TypeLiteral\n ];\n\n /**\n * Analyze the given type literal node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The type literal node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.TypeLiteralNode): Reflection {\n if (node.members) {\n node.members.forEach((node) => {\n this.owner.convertNode(context, node);\n });\n }\n\n return context.scope;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/module.d.ts b/dist/lib/converter/nodes/module.d.ts new file mode 100644 index 000000000..3d1c9c883 --- /dev/null +++ b/dist/lib/converter/nodes/module.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class ModuleConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.ModuleDeclaration): Reflection; +} diff --git a/dist/lib/converter/nodes/module.js b/dist/lib/converter/nodes/module.js new file mode 100644 index 000000000..5abea7f11 --- /dev/null +++ b/dist/lib/converter/nodes/module.js @@ -0,0 +1,53 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var ModuleConverter = (function (_super) { + __extends(ModuleConverter, _super); + function ModuleConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.ModuleDeclaration + ]; + return _this; + } + ModuleConverter.prototype.convert = function (context, node) { + var _this = this; + var parent = context.scope; + var reflection = index_2.createDeclaration(context, node, index_1.ReflectionKind.Module); + context.withScope(reflection, function () { + if (parent instanceof index_1.ProjectReflection && !context.isDeclaration && + (!module || module.valueOf() === ts.ModuleKind.None.valueOf())) { + reflection.setFlag(index_1.ReflectionFlag.Exported); + } + if (node.body) { + _this.owner.convertNode(context, node.body); + } + }); + return reflection; + }; + ModuleConverter = __decorate([ + components_1.Component({ name: 'node:module' }) + ], ModuleConverter); + return ModuleConverter; +}(components_1.ConverterNodeComponent)); +exports.ModuleConverter = ModuleConverter; +//# sourceMappingURL=module.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/module.js.map b/dist/lib/converter/nodes/module.js.map new file mode 100644 index 000000000..f244ada22 --- /dev/null +++ b/dist/lib/converter/nodes/module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAmG;AACnG,4CAAuD;AAEvD,4CAAkE;AAGlE;IAAqC,mCAA4C;IADjF;QAAA,qEAiCC;QA5BG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,iBAAiB;SAClC,CAAC;;IA0BN,CAAC;IAjBG,iCAAO,GAAP,UAAQ,OAAgB,EAAE,IAA0B;QAApD,iBAgBC;QAfG,IAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC7B,IAAM,UAAU,GAAG,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,sBAAc,CAAC,MAAM,CAAC,CAAC;QAE3E,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE;YAC1B,EAAE,CAAC,CAAC,MAAM,YAAY,yBAAiB,IAAI,CAAC,OAAO,CAAC,aAAa;gBAC7D,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;gBACjE,UAAU,CAAC,OAAO,CAAC,sBAAc,CAAC,QAAQ,CAAC,CAAC;YAChD,CAAC;YAED,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBACZ,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,UAAU,CAAC;IACtB,CAAC;IA/BQ,eAAe;QAD3B,sBAAS,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC,CAAC;OACpB,eAAe,CAgC3B;IAAD,sBAAC;CAAA,AAhCD,CAAqC,mCAAsB,GAgC1D;AAhCY,0CAAe","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind, ReflectionFlag, ProjectReflection } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:module'})\nexport class ModuleConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.ModuleDeclaration\n ];\n\n /**\n * Analyze the given module node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The module node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.ModuleDeclaration): Reflection {\n const parent = context.scope;\n const reflection = createDeclaration(context, node, ReflectionKind.Module);\n\n context.withScope(reflection, () => {\n if (parent instanceof ProjectReflection && !context.isDeclaration &&\n (!module || module.valueOf() === ts.ModuleKind.None.valueOf())) {\n reflection.setFlag(ReflectionFlag.Exported);\n }\n\n if (node.body) {\n this.owner.convertNode(context, node.body);\n }\n });\n\n return reflection;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/signature-call.d.ts b/dist/lib/converter/nodes/signature-call.d.ts new file mode 100644 index 000000000..ef8fb211f --- /dev/null +++ b/dist/lib/converter/nodes/signature-call.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class SignatureConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.FunctionExpression | ts.SignatureDeclaration | ts.FunctionExpression): Reflection; +} diff --git a/dist/lib/converter/nodes/signature-call.js b/dist/lib/converter/nodes/signature-call.js new file mode 100644 index 000000000..70d6b4513 --- /dev/null +++ b/dist/lib/converter/nodes/signature-call.js @@ -0,0 +1,53 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var components_1 = require("../components"); +var index_2 = require("../factories/index"); +var SignatureConverter = (function (_super) { + __extends(SignatureConverter, _super); + function SignatureConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.CallSignature, + ts.SyntaxKind.FunctionType, + ts.SyntaxKind.FunctionExpression, + ts.SyntaxKind.ArrowFunction + ]; + return _this; + } + SignatureConverter.prototype.convert = function (context, node) { + var scope = context.scope; + if (scope instanceof index_1.DeclarationReflection) { + var name_1 = scope.kindOf(index_1.ReflectionKind.FunctionOrMethod) ? scope.name : '__call'; + var signature = index_2.createSignature(context, node, name_1, index_1.ReflectionKind.CallSignature); + if (!scope.signatures) { + scope.signatures = []; + } + scope.signatures.push(signature); + } + return scope; + }; + SignatureConverter = __decorate([ + components_1.Component({ name: 'node:signature-call' }) + ], SignatureConverter); + return SignatureConverter; +}(components_1.ConverterNodeComponent)); +exports.SignatureConverter = SignatureConverter; +//# sourceMappingURL=signature-call.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/signature-call.js.map b/dist/lib/converter/nodes/signature-call.js.map new file mode 100644 index 000000000..726002696 --- /dev/null +++ b/dist/lib/converter/nodes/signature-call.js.map @@ -0,0 +1 @@ +{"version":3,"file":"signature-call.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/signature-call.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAuF;AAEvF,4CAAkE;AAClE,4CAAqD;AAGrD;IAAwC,sCAA2F;IADnI;QAAA,qEAgCC;QA3BG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,aAAa;YAC3B,EAAE,CAAC,UAAU,CAAC,YAAY;YAC1B,EAAE,CAAC,UAAU,CAAC,kBAAkB;YAChC,EAAE,CAAC,UAAU,CAAC,aAAa;SAC9B,CAAC;;IAsBN,CAAC;IAbG,oCAAO,GAAP,UAAQ,OAAgB,EAAE,IAAyE;QAC/F,IAAM,KAAK,GAA2B,OAAO,CAAC,KAAK,CAAC;QACpD,EAAE,CAAC,CAAC,KAAK,YAAY,6BAAqB,CAAC,CAAC,CAAC;YACzC,IAAM,MAAI,GAAG,KAAK,CAAC,MAAM,CAAC,sBAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;YACnF,IAAM,SAAS,GAAG,uBAAe,CAAC,OAAO,EAA4B,IAAI,EAAE,MAAI,EAAE,sBAAc,CAAC,aAAa,CAAC,CAAC;YAC/G,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;gBACpB,KAAK,CAAC,UAAU,GAAG,EAAE,CAAC;YAC1B,CAAC;YACD,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IA9BQ,kBAAkB;QAD9B,sBAAS,CAAC,EAAC,IAAI,EAAE,qBAAqB,EAAC,CAAC;OAC5B,kBAAkB,CA+B9B;IAAD,yBAAC;CAAA,AA/BD,CAAwC,mCAAsB,GA+B7D;AA/BY,gDAAkB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind, DeclarationReflection } from '../../models/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\nimport { createSignature } from '../factories/index';\n\n@Component({name: 'node:signature-call'})\nexport class SignatureConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.CallSignature,\n ts.SyntaxKind.FunctionType,\n ts.SyntaxKind.FunctionExpression,\n ts.SyntaxKind.ArrowFunction\n ];\n\n /**\n * Analyze the given call signature declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The signature declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.FunctionExpression|ts.SignatureDeclaration|ts.FunctionExpression): Reflection {\n const scope = context.scope;\n if (scope instanceof DeclarationReflection) {\n const name = scope.kindOf(ReflectionKind.FunctionOrMethod) ? scope.name : '__call';\n const signature = createSignature(context, node, name, ReflectionKind.CallSignature);\n if (!scope.signatures) {\n scope.signatures = [];\n }\n scope.signatures.push(signature);\n }\n\n return scope;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/signature-index.d.ts b/dist/lib/converter/nodes/signature-index.d.ts new file mode 100644 index 000000000..588519d67 --- /dev/null +++ b/dist/lib/converter/nodes/signature-index.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class IndexSignatureConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.SignatureDeclaration): Reflection; +} diff --git a/dist/lib/converter/nodes/signature-index.js b/dist/lib/converter/nodes/signature-index.js new file mode 100644 index 000000000..0faae85d6 --- /dev/null +++ b/dist/lib/converter/nodes/signature-index.js @@ -0,0 +1,45 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var IndexSignatureConverter = (function (_super) { + __extends(IndexSignatureConverter, _super); + function IndexSignatureConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.IndexSignature + ]; + return _this; + } + IndexSignatureConverter.prototype.convert = function (context, node) { + var scope = context.scope; + if (scope instanceof index_1.DeclarationReflection) { + scope.indexSignature = index_2.createSignature(context, node, '__index', index_1.ReflectionKind.IndexSignature); + } + return scope; + }; + IndexSignatureConverter = __decorate([ + components_1.Component({ name: 'node:signature-index' }) + ], IndexSignatureConverter); + return IndexSignatureConverter; +}(components_1.ConverterNodeComponent)); +exports.IndexSignatureConverter = IndexSignatureConverter; +//# sourceMappingURL=signature-index.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/signature-index.js.map b/dist/lib/converter/nodes/signature-index.js.map new file mode 100644 index 000000000..03903fee8 --- /dev/null +++ b/dist/lib/converter/nodes/signature-index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"signature-index.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/signature-index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAuF;AACvF,4CAAqD;AAErD,4CAAkE;AAGlE;IAA6C,2CAA+C;IAD5F;QAAA,qEAwBC;QAnBG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,cAAc;SAC/B,CAAC;;IAiBN,CAAC;IARG,yCAAO,GAAP,UAAQ,OAAgB,EAAE,IAA6B;QACnD,IAAM,KAAK,GAA2B,OAAO,CAAC,KAAK,CAAC;QACpD,EAAE,CAAC,CAAC,KAAK,YAAY,6BAAqB,CAAC,CAAC,CAAC;YACzC,KAAK,CAAC,cAAc,GAAG,uBAAe,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,sBAAc,CAAC,cAAc,CAAC,CAAC;QACpG,CAAC;QAED,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAtBQ,uBAAuB;QADnC,sBAAS,CAAC,EAAC,IAAI,EAAE,sBAAsB,EAAC,CAAC;OAC7B,uBAAuB,CAuBnC;IAAD,8BAAC;CAAA,AAvBD,CAA6C,mCAAsB,GAuBlE;AAvBY,0DAAuB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind, DeclarationReflection } from '../../models/index';\nimport { createSignature } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:signature-index'})\nexport class IndexSignatureConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.IndexSignature\n ];\n\n /**\n * Analyze the given index signature declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The signature declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.SignatureDeclaration): Reflection {\n const scope = context.scope;\n if (scope instanceof DeclarationReflection) {\n scope.indexSignature = createSignature(context, node, '__index', ReflectionKind.IndexSignature);\n }\n\n return scope;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/variable-statement.d.ts b/dist/lib/converter/nodes/variable-statement.d.ts new file mode 100644 index 000000000..3c1d0f598 --- /dev/null +++ b/dist/lib/converter/nodes/variable-statement.d.ts @@ -0,0 +1,9 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class VariableStatementConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + convert(context: Context, node: ts.VariableStatement): Reflection; + convertBindingPattern(context: Context, node: ts.BindingPattern): void; +} diff --git a/dist/lib/converter/nodes/variable-statement.js b/dist/lib/converter/nodes/variable-statement.js new file mode 100644 index 000000000..440d8f7da --- /dev/null +++ b/dist/lib/converter/nodes/variable-statement.js @@ -0,0 +1,60 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var components_1 = require("../components"); +var VariableStatementConverter = (function (_super) { + __extends(VariableStatementConverter, _super); + function VariableStatementConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.VariableStatement + ]; + return _this; + } + VariableStatementConverter.prototype.convert = function (context, node) { + var _this = this; + if (node.declarationList && node.declarationList.declarations) { + node.declarationList.declarations.forEach(function (variableDeclaration) { + if (_ts.isBindingPattern(variableDeclaration.name)) { + _this.convertBindingPattern(context, variableDeclaration.name); + } + else { + _this.owner.convertNode(context, variableDeclaration); + } + }); + } + return context.scope; + }; + VariableStatementConverter.prototype.convertBindingPattern = function (context, node) { + var _this = this; + node.elements.forEach(function (element) { + _this.owner.convertNode(context, element); + if (_ts.isBindingPattern(element.name)) { + _this.convertBindingPattern(context, element.name); + } + }); + }; + VariableStatementConverter = __decorate([ + components_1.Component({ name: 'node:variable-statement' }) + ], VariableStatementConverter); + return VariableStatementConverter; +}(components_1.ConverterNodeComponent)); +exports.VariableStatementConverter = VariableStatementConverter; +//# sourceMappingURL=variable-statement.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/variable-statement.js.map b/dist/lib/converter/nodes/variable-statement.js.map new file mode 100644 index 000000000..d16e82873 --- /dev/null +++ b/dist/lib/converter/nodes/variable-statement.js.map @@ -0,0 +1 @@ +{"version":3,"file":"variable-statement.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/variable-statement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,uCAAyC;AAIzC,4CAAkE;AAGlE;IAAgD,8CAA4C;IAD5F;QAAA,qEA6CC;QAxCG,cAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,iBAAiB;SAClC,CAAC;;IAsCN,CAAC;IA7BG,4CAAO,GAAP,UAAQ,OAAgB,EAAE,IAA0B;QAApD,iBAYC;QAXG,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,OAAO,CAAC,UAAC,mBAAmB;gBAC1D,EAAE,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACjD,KAAI,CAAC,qBAAqB,CAAC,OAAO,EAAsB,mBAAmB,CAAC,IAAI,CAAC,CAAC;gBACtF,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACJ,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;gBACzD,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IAQD,0DAAqB,GAArB,UAAsB,OAAgB,EAAE,IAAuB;QAA/D,iBAQC;QAPI,IAAI,CAAC,QAA4C,CAAC,OAAO,CAAC,UAAC,OAA0B;YAClF,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEzC,EAAE,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACrC,KAAI,CAAC,qBAAqB,CAAC,OAAO,EAAsB,OAAO,CAAC,IAAI,CAAC,CAAC;YAC1E,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IA3CQ,0BAA0B;QADtC,sBAAS,CAAC,EAAC,IAAI,EAAE,yBAAyB,EAAC,CAAC;OAChC,0BAA0B,CA4CtC;IAAD,iCAAC;CAAA,AA5CD,CAAgD,mCAAsB,GA4CrE;AA5CY,gEAA0B","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection } from '../../models/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:variable-statement'})\nexport class VariableStatementConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.VariableStatement\n ];\n\n /**\n * Analyze the given variable statement node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The variable statement node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.VariableStatement): Reflection {\n if (node.declarationList && node.declarationList.declarations) {\n node.declarationList.declarations.forEach((variableDeclaration) => {\n if (_ts.isBindingPattern(variableDeclaration.name)) {\n this.convertBindingPattern(context, variableDeclaration.name);\n } else {\n this.owner.convertNode(context, variableDeclaration);\n }\n });\n }\n\n return context.scope;\n }\n\n /**\n * Traverse the elements of the given binding pattern and create the corresponding variable reflections.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The binding pattern node that should be analyzed.\n */\n convertBindingPattern(context: Context, node: ts.BindingPattern) {\n (node.elements as ts.NodeArray).forEach((element: ts.BindingElement) => {\n this.owner.convertNode(context, element);\n\n if (_ts.isBindingPattern(element.name)) {\n this.convertBindingPattern(context, element.name);\n }\n });\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/nodes/variable.d.ts b/dist/lib/converter/nodes/variable.d.ts new file mode 100644 index 000000000..66bc8c2a1 --- /dev/null +++ b/dist/lib/converter/nodes/variable.d.ts @@ -0,0 +1,9 @@ +import * as ts from 'typescript'; +import { Reflection } from '../../models/index'; +import { Context } from '../context'; +import { ConverterNodeComponent } from '../components'; +export declare class VariableConverter extends ConverterNodeComponent { + supports: ts.SyntaxKind[]; + isSimpleObjectLiteral(objectLiteral: ts.ObjectLiteralExpression): boolean; + convert(context: Context, node: ts.VariableDeclaration): Reflection; +} diff --git a/dist/lib/converter/nodes/variable.js b/dist/lib/converter/nodes/variable.js new file mode 100644 index 000000000..72d0749a8 --- /dev/null +++ b/dist/lib/converter/nodes/variable.js @@ -0,0 +1,125 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/index"); +var index_2 = require("../factories/index"); +var components_1 = require("../components"); +var index_3 = require("../index"); +var VariableConverter = (function (_super) { + __extends(VariableConverter, _super); + function VariableConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.supports = [ + ts.SyntaxKind.PropertySignature, + ts.SyntaxKind.PropertyDeclaration, + ts.SyntaxKind.PropertyAssignment, + ts.SyntaxKind.ShorthandPropertyAssignment, + ts.SyntaxKind.VariableDeclaration, + ts.SyntaxKind.BindingElement + ]; + return _this; + } + VariableConverter.prototype.isSimpleObjectLiteral = function (objectLiteral) { + if (!objectLiteral.properties) { + return true; + } + return objectLiteral.properties.length === 0; + }; + VariableConverter.prototype.convert = function (context, node) { + var _this = this; + var comment = index_2.createComment(node); + if (comment && comment.hasTag('resolve')) { + var resolveType = context.getTypeAtLocation(node); + if (resolveType && resolveType.symbol) { + var resolved = this.owner.convertNode(context, resolveType.symbol.declarations[0]); + if (resolved) { + resolved.name = node.symbol.name; + } + return resolved; + } + } + var name, isBindingPattern; + if (_ts.isBindingPattern(node.name)) { + if (node['propertyName']) { + name = _ts.declarationNameToString(node['propertyName']); + isBindingPattern = true; + } + else { + return null; + } + } + var scope = context.scope; + var kind = scope.kind & index_1.ReflectionKind.ClassOrInterface ? index_1.ReflectionKind.Property : index_1.ReflectionKind.Variable; + var variable = index_2.createDeclaration(context, node, kind, name); + if (variable) { + switch (kind) { + case index_1.ReflectionKind.Variable: + if (node.parent.flags & ts.NodeFlags.Const) { + variable.setFlag(index_1.ReflectionFlag.Const, true); + } + else if (node.parent.flags & ts.NodeFlags.Let) { + variable.setFlag(index_1.ReflectionFlag.Let, true); + } + break; + case index_1.ReflectionKind.Property: + if (node.modifiers + && node.modifiers.some(function (m) { return m.kind === ts.SyntaxKind.AbstractKeyword; })) { + variable.setFlag(index_1.ReflectionFlag.Abstract, true); + } + break; + } + } + context.withScope(variable, function () { + if (node.initializer) { + switch (node.initializer.kind) { + case ts.SyntaxKind.ArrowFunction: + case ts.SyntaxKind.FunctionExpression: + variable.kind = scope.kind & index_1.ReflectionKind.ClassOrInterface ? index_1.ReflectionKind.Method : index_1.ReflectionKind.Function; + _this.owner.convertNode(context, node.initializer); + break; + case ts.SyntaxKind.ObjectLiteralExpression: + if (!_this.isSimpleObjectLiteral(node.initializer)) { + variable.kind = index_1.ReflectionKind.ObjectLiteral; + variable.type = new index_1.IntrinsicType('object'); + _this.owner.convertNode(context, node.initializer); + } + break; + default: + variable.defaultValue = index_3.convertDefaultValue(node); + } + } + if (variable.kind === kind || variable.kind === index_1.ReflectionKind.Event) { + if (isBindingPattern) { + variable.type = _this.owner.convertType(context, node.name); + } + else { + variable.type = _this.owner.convertType(context, node.type, context.getTypeAtLocation(node)); + } + } + }); + return variable; + }; + VariableConverter = __decorate([ + components_1.Component({ name: 'node:variable' }) + ], VariableConverter); + return VariableConverter; +}(components_1.ConverterNodeComponent)); +exports.VariableConverter = VariableConverter; +//# sourceMappingURL=variable.js.map \ No newline at end of file diff --git a/dist/lib/converter/nodes/variable.js.map b/dist/lib/converter/nodes/variable.js.map new file mode 100644 index 000000000..feb93105f --- /dev/null +++ b/dist/lib/converter/nodes/variable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"variable.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/variable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,uCAAyC;AAEzC,4CAA+F;AAC/F,4CAAsE;AAEtE,4CAAkE;AAClE,kCAA+C;AAG/C;IAAuC,qCAA8C;IADrF;QAAA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AAC,CAAC;wBACtD,CAAC;wBACD,KAAK,CAAC;oBACV;wBACI,QAAQ,CAAC,YAAY,GAAG,2BAAmB,CAAC,IAAI,CAAC,CAAC;gBAC1D,CAAC;YACL,CAAC;YAED,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;gBACnE,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;oBACnB,QAAQ,CAAC,IAAI,GAAG,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/D,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACJ,QAAQ,CAAC,IAAI,GAAG,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;gBAChG,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,QAAQ,CAAC;IACpB,CAAC;IAvGQ,iBAAiB;QAD7B,sBAAS,CAAC,EAAC,IAAI,EAAE,eAAe,EAAC,CAAC;OACtB,iBAAiB,CAwG7B;IAAD,wBAAC;CAAA,AAxGD,CAAuC,mCAAsB,GAwG5D;AAxGY,8CAAiB","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection, ReflectionFlag, ReflectionKind, IntrinsicType } from '../../models/index';\nimport { createDeclaration, createComment } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\nimport { convertDefaultValue } from '../index';\n\n@Component({name: 'node:variable'})\nexport class VariableConverter extends ConverterNodeComponent {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.PropertySignature,\n ts.SyntaxKind.PropertyDeclaration,\n ts.SyntaxKind.PropertyAssignment,\n ts.SyntaxKind.ShorthandPropertyAssignment,\n ts.SyntaxKind.VariableDeclaration,\n ts.SyntaxKind.BindingElement\n ];\n\n isSimpleObjectLiteral(objectLiteral: ts.ObjectLiteralExpression): boolean {\n if (!objectLiteral.properties) {\n return true;\n }\n return objectLiteral.properties.length === 0;\n }\n\n /**\n * Analyze the given variable declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The variable declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.VariableDeclaration): Reflection {\n const comment = createComment(node);\n if (comment && comment.hasTag('resolve')) {\n const resolveType = context.getTypeAtLocation(node);\n if (resolveType && resolveType.symbol) {\n const resolved = this.owner.convertNode(context, resolveType.symbol.declarations[0]);\n if (resolved) {\n resolved.name = node.symbol.name;\n }\n return resolved;\n }\n }\n\n let name: string, isBindingPattern: boolean;\n if (_ts.isBindingPattern(node.name)) {\n if (node['propertyName']) {\n name = _ts.declarationNameToString(node['propertyName']);\n isBindingPattern = true;\n } else {\n return null;\n }\n }\n\n const scope = context.scope;\n const kind = scope.kind & ReflectionKind.ClassOrInterface ? ReflectionKind.Property : ReflectionKind.Variable;\n const variable = createDeclaration(context, node, kind, name);\n\n // The variable can be null if `excludeNotExported` is `true`\n if (variable) {\n switch (kind) {\n case ReflectionKind.Variable:\n if (node.parent.flags & ts.NodeFlags.Const) {\n variable.setFlag(ReflectionFlag.Const, true);\n } else if (node.parent.flags & ts.NodeFlags.Let) {\n variable.setFlag(ReflectionFlag.Let, true);\n }\n break;\n case ReflectionKind.Property:\n if (node.modifiers\n && node.modifiers.some( m => m.kind === ts.SyntaxKind.AbstractKeyword )) {\n variable.setFlag(ReflectionFlag.Abstract, true);\n }\n break;\n }\n }\n\n context.withScope(variable, () => {\n if (node.initializer) {\n switch (node.initializer.kind) {\n case ts.SyntaxKind.ArrowFunction:\n case ts.SyntaxKind.FunctionExpression:\n variable.kind = scope.kind & ReflectionKind.ClassOrInterface ? ReflectionKind.Method : ReflectionKind.Function;\n this.owner.convertNode(context, node.initializer);\n break;\n case ts.SyntaxKind.ObjectLiteralExpression:\n if (!this.isSimpleObjectLiteral( node.initializer)) {\n variable.kind = ReflectionKind.ObjectLiteral;\n variable.type = new IntrinsicType('object');\n this.owner.convertNode(context, node.initializer);\n }\n break;\n default:\n variable.defaultValue = convertDefaultValue(node);\n }\n }\n\n if (variable.kind === kind || variable.kind === ReflectionKind.Event) {\n if (isBindingPattern) {\n variable.type = this.owner.convertType(context, node.name);\n } else {\n variable.type = this.owner.convertType(context, node.type, context.getTypeAtLocation(node));\n }\n }\n });\n\n return variable;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/CategoryPlugin.d.ts b/dist/lib/converter/plugins/CategoryPlugin.d.ts new file mode 100644 index 000000000..84193292a --- /dev/null +++ b/dist/lib/converter/plugins/CategoryPlugin.d.ts @@ -0,0 +1,13 @@ +import { Reflection } from '../../models/reflections/index'; +import { ReflectionCategory } from '../../models/ReflectionCategory'; +import { ConverterComponent } from '../components'; +export declare class CategoryPlugin extends ConverterComponent { + static WEIGHTS: any[]; + initialize(): void; + private onResolve(context, reflection); + private onEndResolve(context); + static getReflectionCategories(reflections: Reflection[]): ReflectionCategory[]; + static getCategory(reflection: Reflection): string; + static sortCallback(a: Reflection, b: Reflection): number; + static sortCatCallback(a: ReflectionCategory, b: ReflectionCategory): number; +} diff --git a/dist/lib/converter/plugins/CategoryPlugin.js b/dist/lib/converter/plugins/CategoryPlugin.js new file mode 100644 index 000000000..b5d0d4c1e --- /dev/null +++ b/dist/lib/converter/plugins/CategoryPlugin.js @@ -0,0 +1,132 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/reflections/index"); +var ReflectionCategory_1 = require("../../models/ReflectionCategory"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var GroupPlugin_1 = require("./GroupPlugin"); +var CategoryPlugin = (function (_super) { + __extends(CategoryPlugin, _super); + function CategoryPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + CategoryPlugin_1 = CategoryPlugin; + CategoryPlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[converter_1.Converter.EVENT_RESOLVE] = this.onResolve, + _a[converter_1.Converter.EVENT_RESOLVE_END] = this.onEndResolve, + _a)); + var _a; + }; + CategoryPlugin.prototype.onResolve = function (context, reflection) { + if (reflection instanceof index_1.ContainerReflection) { + var container = reflection; + if (container.children && container.children.length > 0) { + container.children.sort(GroupPlugin_1.GroupPlugin.sortCallback); + container.categories = CategoryPlugin_1.getReflectionCategories(container.children); + } + if (container.categories && container.categories.length > 1) { + container.categories.sort(CategoryPlugin_1.sortCatCallback); + } + } + }; + CategoryPlugin.prototype.onEndResolve = function (context) { + function walkDirectory(directory) { + directory.categories = CategoryPlugin_1.getReflectionCategories(directory.getAllReflections()); + for (var key in directory.directories) { + if (!directory.directories.hasOwnProperty(key)) { + continue; + } + walkDirectory(directory.directories[key]); + } + } + var project = context.project; + if (project.children && project.children.length > 0) { + project.children.sort(GroupPlugin_1.GroupPlugin.sortCallback); + project.categories = CategoryPlugin_1.getReflectionCategories(project.children); + } + if (project.categories && project.categories.length > 1) { + project.categories.sort(CategoryPlugin_1.sortCatCallback); + } + walkDirectory(project.directory); + project.files.forEach(function (file) { + file.categories = CategoryPlugin_1.getReflectionCategories(file.reflections); + }); + }; + CategoryPlugin.getReflectionCategories = function (reflections) { + var categories = []; + reflections.forEach(function (child) { + var childCat = CategoryPlugin_1.getCategory(child); + if (childCat === '') { + return; + } + for (var i = 0; i < categories.length; i++) { + var category_1 = categories[i]; + if (category_1.title !== childCat) { + continue; + } + category_1.children.push(child); + return; + } + var category = new ReflectionCategory_1.ReflectionCategory(childCat); + category.children.push(child); + categories.push(category); + }); + return categories; + }; + CategoryPlugin.getCategory = function (reflection) { + if (reflection.comment) { + var tags = reflection.comment.tags; + if (tags) { + for (var i = 0; i < tags.length; i++) { + if (tags[i].tagName === 'category') { + var tag = tags[i].text; + return (tag.charAt(0).toUpperCase() + tag.slice(1).toLowerCase()).trim(); + } + } + } + } + return ''; + }; + CategoryPlugin.sortCallback = function (a, b) { + return a.name > b.name ? 1 : -1; + }; + CategoryPlugin.sortCatCallback = function (a, b) { + var aWeight = CategoryPlugin_1.WEIGHTS.indexOf(a.title); + var bWeight = CategoryPlugin_1.WEIGHTS.indexOf(b.title); + if (aWeight < 0 && bWeight < 0) { + return a.title > b.title ? 1 : -1; + } + if (aWeight < 0) { + return 1; + } + if (bWeight < 0) { + return -1; + } + return aWeight - bWeight; + }; + CategoryPlugin.WEIGHTS = []; + CategoryPlugin = CategoryPlugin_1 = __decorate([ + components_1.Component({ name: 'category' }) + ], CategoryPlugin); + return CategoryPlugin; + var CategoryPlugin_1; +}(components_1.ConverterComponent)); +exports.CategoryPlugin = CategoryPlugin; +//# sourceMappingURL=CategoryPlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/CategoryPlugin.js.map b/dist/lib/converter/plugins/CategoryPlugin.js.map new file mode 100644 index 000000000..fe156608e --- /dev/null +++ b/dist/lib/converter/plugins/CategoryPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CategoryPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/CategoryPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,wDAAiF;AACjF,sEAAqE;AAErE,4CAA8D;AAC9D,0CAAyC;AAEzC,6CAA4C;AAQ5C;IAAoC,kCAAkB;IAAtD;;IAuJA,CAAC;uBAvJY,cAAc;IASvB,mCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,qBAAS,CAAC,aAAa,IAAO,IAAI,CAAC,SAAS;YAC7C,GAAC,qBAAS,CAAC,iBAAiB,IAAG,IAAI,CAAC,YAAY;gBAClD,CAAC;;IACP,CAAC;IAQO,kCAAS,GAAjB,UAAkB,OAAgB,EAAE,UAAsB;QACtD,EAAE,CAAC,CAAC,UAAU,YAAY,2BAAmB,CAAC,CAAC,CAAC;YAC5C,IAAM,SAAS,GAAyB,UAAU,CAAC;YACnD,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;gBACtD,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,yBAAW,CAAC,YAAY,CAAC,CAAC;gBAClD,SAAS,CAAC,UAAU,GAAG,gBAAc,CAAC,uBAAuB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACtF,CAAC;YACD,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC1D,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAc,CAAC,eAAe,CAAC,CAAC;YAC9D,CAAC;QACL,CAAC;IACL,CAAC;IAOO,qCAAY,GAApB,UAAqB,OAAgB;QACjC,uBAAuB,SAA0B;YAC7C,SAAS,CAAC,UAAU,GA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AC,EAAC,IAAI,EAAE,UAAU,EAAC,CAAC;OACjB,cAAc,CAuJ1B;IAAD,qBAAC;;CAAA,AAvJD,CAAoC,+BAAkB,GAuJrD;AAvJY,wCAAc","sourcesContent":["import { Reflection, ContainerReflection } from '../../models/reflections/index';\nimport { ReflectionCategory } from '../../models/ReflectionCategory';\nimport { SourceDirectory } from '../../models/sources/directory';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { GroupPlugin } from './GroupPlugin';\n\n/**\n * A handler that sorts and categorizes the found reflections in the resolving phase.\n *\n * The handler sets the ´category´ property of all reflections.\n */\n@Component({name: 'category'})\nexport class CategoryPlugin extends ConverterComponent {\n /**\n * Define the sort order of categories. By default, sort alphabetically.\n */\n static WEIGHTS = [];\n\n /**\n * Create a new CategoryPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [Converter.EVENT_RESOLVE]: this.onResolve,\n [Converter.EVENT_RESOLVE_END]: this.onEndResolve\n });\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: Reflection) {\n if (reflection instanceof ContainerReflection) {\n const container = reflection;\n if (container.children && container.children.length > 0) {\n container.children.sort(GroupPlugin.sortCallback);\n container.categories = CategoryPlugin.getReflectionCategories(container.children);\n }\n if (container.categories && container.categories.length > 1) {\n container.categories.sort(CategoryPlugin.sortCatCallback);\n }\n }\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onEndResolve(context: Context) {\n function walkDirectory(directory: SourceDirectory) {\n directory.categories = CategoryPlugin.getReflectionCategories(directory.getAllReflections());\n\n for (let key in directory.directories) {\n if (!directory.directories.hasOwnProperty(key)) {\n continue;\n }\n walkDirectory(directory.directories[key]);\n }\n }\n\n const project = context.project;\n if (project.children && project.children.length > 0) {\n project.children.sort(GroupPlugin.sortCallback);\n project.categories = CategoryPlugin.getReflectionCategories(project.children);\n }\n if (project.categories && project.categories.length > 1) {\n project.categories.sort(CategoryPlugin.sortCatCallback);\n }\n\n walkDirectory(project.directory);\n project.files.forEach((file) => {\n file.categories = CategoryPlugin.getReflectionCategories(file.reflections);\n });\n }\n\n /**\n * Create a categorized representation of the given list of reflections.\n *\n * @param reflections The reflections that should be categorized.\n * @returns An array containing all children of the given reflection categorized\n */\n static getReflectionCategories(reflections: Reflection[]): ReflectionCategory[] {\n const categories: ReflectionCategory[] = [];\n reflections.forEach((child) => {\n const childCat = CategoryPlugin.getCategory(child);\n if (childCat === '') {\n return;\n }\n for (let i = 0; i < categories.length; i++) {\n const category = categories[i];\n\n if (category.title !== childCat) {\n continue;\n }\n\n category.children.push(child);\n return;\n }\n\n const category = new ReflectionCategory(childCat);\n category.children.push(child);\n categories.push(category);\n });\n return categories;\n }\n\n /**\n * Return the category of a given reflection.\n *\n * @param reflection The reflection.\n * @returns The category the reflection belongs to\n */\n static getCategory(reflection: Reflection): string {\n if (reflection.comment) {\n const tags = reflection.comment.tags;\n if (tags) {\n for (let i = 0; i < tags.length; i++) {\n if (tags[i].tagName === 'category') {\n let tag = tags[i].text;\n return (tag.charAt(0).toUpperCase() + tag.slice(1).toLowerCase()).trim();\n }\n }\n }\n }\n return '';\n }\n\n /**\n * Callback used to sort reflections by name.\n *\n * @param a The left reflection to sort.\n * @param b The right reflection to sort.\n * @returns The sorting weight.\n */\n static sortCallback(a: Reflection, b: Reflection): number {\n return a.name > b.name ? 1 : -1;\n }\n\n /**\n * Callback used to sort categories by name.\n *\n * @param a The left reflection to sort.\n * @param b The right reflection to sort.\n * @returns The sorting weight.\n */\n static sortCatCallback(a: ReflectionCategory, b: ReflectionCategory): number {\n const aWeight = CategoryPlugin.WEIGHTS.indexOf(a.title);\n const bWeight = CategoryPlugin.WEIGHTS.indexOf(b.title);\n if (aWeight < 0 && bWeight < 0) {\n return a.title > b.title ? 1 : -1;\n }\n if (aWeight < 0) {\n return 1;\n }\n if (bWeight < 0) {\n return -1;\n }\n return aWeight - bWeight;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/CommentPlugin.d.ts b/dist/lib/converter/plugins/CommentPlugin.d.ts new file mode 100644 index 000000000..f995d5712 --- /dev/null +++ b/dist/lib/converter/plugins/CommentPlugin.d.ts @@ -0,0 +1,18 @@ +import { Comment } from '../../models/comments/index'; +import { Reflection, ProjectReflection } from '../../models/reflections/index'; +import { ConverterComponent } from '../components'; +export declare class CommentPlugin extends ConverterComponent { + private comments; + private hidden; + initialize(): void; + private storeModuleComment(comment, reflection); + private applyModifiers(reflection, comment); + private onBegin(context); + private onCreateTypeParameter(context, reflection, node?); + private onDeclaration(context, reflection, node?); + private onFunctionImplementation(context, reflection, node?); + private onBeginResolve(context); + private onResolve(context, reflection); + static removeTags(comment: Comment, tagName: string): void; + static removeReflection(project: ProjectReflection, reflection: Reflection): void; +} diff --git a/dist/lib/converter/plugins/CommentPlugin.js b/dist/lib/converter/plugins/CommentPlugin.js new file mode 100644 index 000000000..922b06dac --- /dev/null +++ b/dist/lib/converter/plugins/CommentPlugin.js @@ -0,0 +1,279 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/comments/index"); +var index_2 = require("../../models/types/index"); +var index_3 = require("../../models/reflections/index"); +var components_1 = require("../components"); +var comment_1 = require("../factories/comment"); +var converter_1 = require("../converter"); +var CommentPlugin = (function (_super) { + __extends(CommentPlugin, _super); + function CommentPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + CommentPlugin_1 = CommentPlugin; + CommentPlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[converter_1.Converter.EVENT_BEGIN] = this.onBegin, + _a[converter_1.Converter.EVENT_CREATE_DECLARATION] = this.onDeclaration, + _a[converter_1.Converter.EVENT_CREATE_SIGNATURE] = this.onDeclaration, + _a[converter_1.Converter.EVENT_CREATE_TYPE_PARAMETER] = this.onCreateTypeParameter, + _a[converter_1.Converter.EVENT_FUNCTION_IMPLEMENTATION] = this.onFunctionImplementation, + _a[converter_1.Converter.EVENT_RESOLVE_BEGIN] = this.onBeginResolve, + _a[converter_1.Converter.EVENT_RESOLVE] = this.onResolve, + _a)); + var _a; + }; + CommentPlugin.prototype.storeModuleComment = function (comment, reflection) { + var isPreferred = (comment.toLowerCase().indexOf('@preferred') !== -1); + if (this.comments[reflection.id]) { + var info = this.comments[reflection.id]; + if (!isPreferred && (info.isPreferred || info.fullText.length > comment.length)) { + return; + } + info.fullText = comment; + info.isPreferred = isPreferred; + } + else { + this.comments[reflection.id] = { + reflection: reflection, + fullText: comment, + isPreferred: isPreferred + }; + } + }; + CommentPlugin.prototype.applyModifiers = function (reflection, comment) { + if (comment.hasTag('private')) { + reflection.setFlag(index_3.ReflectionFlag.Private); + CommentPlugin_1.removeTags(comment, 'private'); + } + if (comment.hasTag('protected')) { + reflection.setFlag(index_3.ReflectionFlag.Protected); + CommentPlugin_1.removeTags(comment, 'protected'); + } + if (comment.hasTag('public')) { + reflection.setFlag(index_3.ReflectionFlag.Public); + CommentPlugin_1.removeTags(comment, 'public'); + } + if (comment.hasTag('event')) { + reflection.kind = index_3.ReflectionKind.Event; + CommentPlugin_1.removeTags(comment, 'event'); + } + if (comment.hasTag('hidden')) { + if (!this.hidden) { + this.hidden = []; + } + this.hidden.push(reflection); + } + }; + CommentPlugin.prototype.onBegin = function (context) { + this.comments = {}; + }; + CommentPlugin.prototype.onCreateTypeParameter = function (context, reflection, node) { + var comment = reflection.parent.comment; + if (comment) { + var tag = comment.getTag('typeparam', reflection.name); + if (!tag) { + tag = comment.getTag('param', "<" + reflection.name + ">"); + } + if (!tag) { + tag = comment.getTag('param', reflection.name); + } + if (tag) { + reflection.comment = new index_1.Comment(tag.text); + comment.tags.splice(comment.tags.indexOf(tag), 1); + } + } + }; + CommentPlugin.prototype.onDeclaration = function (context, reflection, node) { + if (!node) { + return; + } + var rawComment = comment_1.getRawComment(node); + if (!rawComment) { + return; + } + if (reflection.kindOf(index_3.ReflectionKind.FunctionOrMethod) || (reflection.kindOf(index_3.ReflectionKind.Event) && reflection['signatures'])) { + var comment = comment_1.parseComment(rawComment, reflection.comment); + this.applyModifiers(reflection, comment); + } + else if (reflection.kindOf(index_3.ReflectionKind.Module)) { + this.storeModuleComment(rawComment, reflection); + } + else { + var comment = comment_1.parseComment(rawComment, reflection.comment); + this.applyModifiers(reflection, comment); + reflection.comment = comment; + } + }; + CommentPlugin.prototype.onFunctionImplementation = function (context, reflection, node) { + if (!node) { + return; + } + var comment = comment_1.getRawComment(node); + if (comment) { + reflection.comment = comment_1.parseComment(comment, reflection.comment); + } + }; + CommentPlugin.prototype.onBeginResolve = function (context) { + for (var id in this.comments) { + if (!this.comments.hasOwnProperty(id)) { + continue; + } + var info = this.comments[id]; + var comment = comment_1.parseComment(info.fullText); + CommentPlugin_1.removeTags(comment, 'preferred'); + this.applyModifiers(info.reflection, comment); + info.reflection.comment = comment; + } + if (this.hidden) { + var project_1 = context.project; + this.hidden.forEach(function (reflection) { + CommentPlugin_1.removeReflection(project_1, reflection); + }); + } + }; + CommentPlugin.prototype.onResolve = function (context, reflection) { + if (!(reflection instanceof index_3.DeclarationReflection)) { + return; + } + var signatures = reflection.getAllSignatures(); + if (signatures.length) { + var comment_2 = reflection.comment; + if (comment_2 && comment_2.hasTag('returns')) { + comment_2.returns = comment_2.getTag('returns').text; + CommentPlugin_1.removeTags(comment_2, 'returns'); + } + signatures.forEach(function (signature) { + var childComment = signature.comment; + if (childComment && childComment.hasTag('returns')) { + childComment.returns = childComment.getTag('returns').text; + CommentPlugin_1.removeTags(childComment, 'returns'); + } + if (comment_2) { + if (!childComment) { + childComment = signature.comment = new index_1.Comment(); + } + childComment.shortText = childComment.shortText || comment_2.shortText; + childComment.text = childComment.text || comment_2.text; + childComment.returns = childComment.returns || comment_2.returns; + } + if (signature.parameters) { + signature.parameters.forEach(function (parameter) { + var tag; + if (childComment) { + tag = childComment.getTag('param', parameter.name); + } + if (comment_2 && !tag) { + tag = comment_2.getTag('param', parameter.name); + } + if (tag) { + parameter.comment = new index_1.Comment(tag.text); + } + }); + } + CommentPlugin_1.removeTags(childComment, 'param'); + }); + CommentPlugin_1.removeTags(comment_2, 'param'); + } + }; + CommentPlugin.removeTags = function (comment, tagName) { + if (!comment || !comment.tags) { + return; + } + var i = 0, c = comment.tags.length; + while (i < c) { + if (comment.tags[i].tagName === tagName) { + comment.tags.splice(i, 1); + c--; + } + else { + i++; + } + } + }; + CommentPlugin.removeReflection = function (project, reflection) { + reflection.traverse(function (child) { return CommentPlugin_1.removeReflection(project, child); }); + var parent = reflection.parent; + parent.traverse(function (child, property) { + if (child === reflection) { + switch (property) { + case index_3.TraverseProperty.Children: + if (parent.children) { + var index = parent.children.indexOf(reflection); + if (index !== -1) { + parent.children.splice(index, 1); + } + } + break; + case index_3.TraverseProperty.GetSignature: + delete parent.getSignature; + break; + case index_3.TraverseProperty.IndexSignature: + delete parent.indexSignature; + break; + case index_3.TraverseProperty.Parameters: + if (reflection.parent.parameters) { + var index = reflection.parent.parameters.indexOf(reflection); + if (index !== -1) { + reflection.parent.parameters.splice(index, 1); + } + } + break; + case index_3.TraverseProperty.SetSignature: + delete parent.setSignature; + break; + case index_3.TraverseProperty.Signatures: + if (parent.signatures) { + var index = parent.signatures.indexOf(reflection); + if (index !== -1) { + parent.signatures.splice(index, 1); + } + } + break; + case index_3.TraverseProperty.TypeLiteral: + parent.type = new index_2.IntrinsicType('Object'); + break; + case index_3.TraverseProperty.TypeParameter: + if (parent.typeParameters) { + var index = parent.typeParameters.indexOf(reflection); + if (index !== -1) { + parent.typeParameters.splice(index, 1); + } + } + break; + } + } + }); + var id = reflection.id; + delete project.reflections[id]; + for (var key in project.symbolMapping) { + if (project.symbolMapping.hasOwnProperty(key) && project.symbolMapping[key] === id) { + delete project.symbolMapping[key]; + } + } + }; + CommentPlugin = CommentPlugin_1 = __decorate([ + components_1.Component({ name: 'comment' }) + ], CommentPlugin); + return CommentPlugin; + var CommentPlugin_1; +}(components_1.ConverterComponent)); +exports.CommentPlugin = CommentPlugin; +//# sourceMappingURL=CommentPlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/CommentPlugin.js.map b/dist/lib/converter/plugins/CommentPlugin.js.map new file mode 100644 index 000000000..3fb3c58cd --- /dev/null +++ b/dist/lib/converter/plugins/CommentPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CommentPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/CommentPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,qDAAkE;AAClE,kDAAyD;AACzD,wDAEqF;AACrF,4CAA8D;AAC9D,gDAAmE;AACnE,0CAAyC;AA4BzC;IAAmC,iCAAkB;IAArD;;IAwVA,CAAC;sBAxVY,aAAa;IActB,kCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,qBAAS,CAAC,WAAW,IAAqB,IAAI,CAAC,OAAO;YACvD,GAAC,qBAAS,CAAC,wBAAwB,IAAQ,IAAI,CAA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D,CAAmC,+BAAkB,GAwVpD;AAxVY,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 */\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().indexOf('@preferred') !== -1);\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 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.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.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.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 (let 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 this.hidden.forEach((reflection) => {\n CommentPlugin.removeReflection(project, reflection);\n });\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;\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, 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 given reflection from the project.\n */\n static removeReflection(project: ProjectReflection, reflection: Reflection) {\n reflection.traverse((child) => CommentPlugin.removeReflection(project, child));\n\n const parent = 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( 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 (( reflection.parent).parameters) {\n const index = ( reflection.parent).parameters.indexOf( reflection);\n if (index !== -1) {\n ( 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( 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( reflection);\n if (index !== -1) {\n parent.typeParameters.splice(index, 1);\n }\n }\n break;\n }\n }\n });\n\n let id = reflection.id;\n delete project.reflections[id];\n\n for (let key in project.symbolMapping) {\n if (project.symbolMapping.hasOwnProperty(key) && project.symbolMapping[key] === id) {\n delete project.symbolMapping[key];\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/DecoratorPlugin.d.ts b/dist/lib/converter/plugins/DecoratorPlugin.d.ts new file mode 100644 index 000000000..07adecf75 --- /dev/null +++ b/dist/lib/converter/plugins/DecoratorPlugin.d.ts @@ -0,0 +1,9 @@ +import { ConverterComponent } from '../components'; +export declare class DecoratorPlugin extends ConverterComponent { + private usages; + initialize(): void; + private extractArguments(args, signature); + private onBegin(context); + private onDeclaration(context, reflection, node?); + private onBeginResolve(context); +} diff --git a/dist/lib/converter/plugins/DecoratorPlugin.js b/dist/lib/converter/plugins/DecoratorPlugin.js new file mode 100644 index 000000000..2f3f7dd81 --- /dev/null +++ b/dist/lib/converter/plugins/DecoratorPlugin.js @@ -0,0 +1,121 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/types/index"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var DecoratorPlugin = (function (_super) { + __extends(DecoratorPlugin, _super); + function DecoratorPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + DecoratorPlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[converter_1.Converter.EVENT_BEGIN] = this.onBegin, + _a[converter_1.Converter.EVENT_CREATE_DECLARATION] = this.onDeclaration, + _a[converter_1.Converter.EVENT_CREATE_PARAMETER] = this.onDeclaration, + _a[converter_1.Converter.EVENT_RESOLVE] = this.onBeginResolve, + _a)); + var _a; + }; + DecoratorPlugin.prototype.extractArguments = function (args, signature) { + var result = {}; + args.forEach(function (arg, index) { + if (index < signature.parameters.length) { + var parameter = signature.parameters[index]; + result[parameter.name] = _ts.getTextOfNode(arg); + } + else { + if (!result['...']) { + result['...'] = []; + } + result['...'].push(_ts.getTextOfNode(arg)); + } + }); + return result; + }; + DecoratorPlugin.prototype.onBegin = function (context) { + this.usages = {}; + }; + DecoratorPlugin.prototype.onDeclaration = function (context, reflection, node) { + var _this = this; + if (!node || !node.decorators) { + return; + } + node.decorators.forEach(function (decorator) { + var callExpression; + var identifier; + switch (decorator.expression.kind) { + case ts.SyntaxKind.Identifier: + identifier = decorator.expression; + break; + case ts.SyntaxKind.CallExpression: + callExpression = decorator.expression; + identifier = callExpression.expression; + break; + default: + return; + } + var info = { + name: _ts.getTextOfNode(identifier) + }; + var type = context.checker.getTypeAtLocation(identifier); + if (type && type.symbol) { + var symbolID = context.getSymbolID(type.symbol); + info.type = new index_1.ReferenceType(info.name, symbolID); + if (callExpression && callExpression.arguments) { + var signature = context.checker.getResolvedSignature(callExpression); + if (signature) { + info.arguments = _this.extractArguments(callExpression.arguments, signature); + } + } + if (!_this.usages[symbolID]) { + _this.usages[symbolID] = []; + } + _this.usages[symbolID].push(new index_1.ReferenceType(reflection.name, index_1.ReferenceType.SYMBOL_ID_RESOLVED, reflection)); + } + if (!reflection.decorators) { + reflection.decorators = []; + } + reflection.decorators.push(info); + }); + }; + DecoratorPlugin.prototype.onBeginResolve = function (context) { + for (var symbolID in this.usages) { + if (!this.usages.hasOwnProperty(symbolID)) { + continue; + } + var id = context.project.symbolMapping[symbolID]; + if (!id) { + continue; + } + var reflection = context.project.reflections[id]; + if (reflection) { + reflection.decorates = this.usages[symbolID]; + } + } + }; + DecoratorPlugin = __decorate([ + components_1.Component({ name: 'decorator' }) + ], DecoratorPlugin); + return DecoratorPlugin; +}(components_1.ConverterComponent)); +exports.DecoratorPlugin = DecoratorPlugin; +//# sourceMappingURL=DecoratorPlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/DecoratorPlugin.js.map b/dist/lib/converter/plugins/DecoratorPlugin.js.map new file mode 100644 index 000000000..7f1c8f698 --- /dev/null +++ b/dist/lib/converter/plugins/DecoratorPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DecoratorPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/DecoratorPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,uCAAyC;AAEzC,kDAAyD;AAEzD,4CAA8D;AAC9D,0CAAyC;AAOzC;IAAqC,mCAAkB;IAAvD;;IA+HA,CAAC;IAzHG,oCAAU,GAAV;QACI,IA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CAAC;IACL,CAAC;IA9HQ,eAAe;QAD3B,sBAAS,CAAC,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC;OAClB,eAAe,CA+H3B;IAAD,sBAAC;CAAA,AA/HD,CAAqC,+BAAkB,GA+HtD;AA/HY,0CAAe","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { ReferenceType } from '../../models/types/index';\nimport { Reflection, Decorator } from '../../models/reflections/index';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A plugin that detects decorators.\n */\n@Component({name: 'decorator'})\nexport class DecoratorPlugin extends ConverterComponent {\n private usages: {[symbolID: number]: ReferenceType[]};\n\n /**\n * Create a new ImplementsPlugin 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_PARAMETER]: this.onDeclaration,\n [Converter.EVENT_RESOLVE]: this.onBeginResolve\n });\n }\n\n /**\n * Create an object describing the arguments a decorator is set with.\n *\n * @param args The arguments resolved from the decorator's call expression.\n * @param signature The signature definition of the decorator being used.\n * @returns An object describing the decorator parameters,\n */\n private extractArguments(args: ts.NodeArray, signature: ts.Signature): any {\n const result = {};\n args.forEach((arg: ts.Expression, index: number) => {\n if (index < signature.parameters.length) {\n const parameter = signature.parameters[index];\n result[parameter.name] = _ts.getTextOfNode(arg);\n } else {\n if (!result['...']) {\n result['...'] = [];\n }\n result['...'].push(_ts.getTextOfNode(arg));\n }\n });\n\n return result;\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.usages = {};\n }\n\n /**\n * Triggered when the converter has created a declaration or signature reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onDeclaration(context: Context, reflection: Reflection, node?: ts.Node) {\n if (!node || !node.decorators) {\n return;\n }\n node.decorators.forEach((decorator: ts.Decorator) => {\n let callExpression: ts.CallExpression;\n let identifier: ts.Expression;\n\n switch (decorator.expression.kind) {\n case ts.SyntaxKind.Identifier:\n identifier = decorator.expression;\n break;\n case ts.SyntaxKind.CallExpression:\n callExpression = decorator.expression;\n identifier = callExpression.expression;\n break;\n default:\n return;\n }\n\n const info: Decorator = {\n name: _ts.getTextOfNode(identifier)\n };\n\n const type = context.checker.getTypeAtLocation(identifier);\n if (type && type.symbol) {\n const symbolID = context.getSymbolID(type.symbol);\n info.type = new ReferenceType(info.name, symbolID);\n\n if (callExpression && callExpression.arguments) {\n const signature = context.checker.getResolvedSignature(callExpression);\n if (signature) {\n info.arguments = this.extractArguments(callExpression.arguments, signature);\n }\n }\n\n if (!this.usages[symbolID]) {\n this.usages[symbolID] = [];\n }\n this.usages[symbolID].push(new ReferenceType(reflection.name, ReferenceType.SYMBOL_ID_RESOLVED, reflection));\n }\n\n if (!reflection.decorators) {\n reflection.decorators = [];\n }\n reflection.decorators.push(info);\n });\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onBeginResolve(context: Context) {\n for (let symbolID in this.usages) {\n if (!this.usages.hasOwnProperty(symbolID)) {\n continue;\n }\n\n const id = context.project.symbolMapping[symbolID];\n if (!id) {\n continue;\n }\n\n const reflection = context.project.reflections[id];\n if (reflection) {\n reflection.decorates = this.usages[symbolID];\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/DeepCommentPlugin.d.ts b/dist/lib/converter/plugins/DeepCommentPlugin.d.ts new file mode 100644 index 000000000..1332efb61 --- /dev/null +++ b/dist/lib/converter/plugins/DeepCommentPlugin.d.ts @@ -0,0 +1,5 @@ +import { ConverterComponent } from '../components'; +export declare class DeepCommentPlugin extends ConverterComponent { + initialize(): void; + private onBeginResolve(context); +} diff --git a/dist/lib/converter/plugins/DeepCommentPlugin.js b/dist/lib/converter/plugins/DeepCommentPlugin.js new file mode 100644 index 000000000..1a4618d5a --- /dev/null +++ b/dist/lib/converter/plugins/DeepCommentPlugin.js @@ -0,0 +1,82 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/reflections/index"); +var index_2 = require("../../models/comments/index"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var DeepCommentPlugin = (function (_super) { + __extends(DeepCommentPlugin, _super); + function DeepCommentPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + DeepCommentPlugin.prototype.initialize = function () { + this.listenTo(this.owner, converter_1.Converter.EVENT_RESOLVE_BEGIN, this.onBeginResolve, 512); + }; + DeepCommentPlugin.prototype.onBeginResolve = function (context) { + var project = context.project; + var name; + for (var key in project.reflections) { + var reflection = project.reflections[key]; + if (!reflection.comment) { + findDeepComment(reflection); + } + } + function push(parent) { + var part = parent.originalName; + if (!part || part.substr(0, 2) === '__' || parent instanceof index_1.SignatureReflection) { + part = ''; + } + if (part && part !== '') { + name = (name === '' ? part : part + '.' + name); + } + } + function findDeepComment(reflection) { + name = ''; + push(reflection); + var target = reflection.parent; + while (target && !(target instanceof index_1.ProjectReflection)) { + push(target); + if (target.comment) { + var tag = void 0; + if (reflection instanceof index_1.TypeParameterReflection) { + tag = target.comment.getTag('typeparam', reflection.name); + if (!tag) { + tag = target.comment.getTag('param', '<' + reflection.name + '>'); + } + } + if (!tag) { + tag = target.comment.getTag('param', name); + } + if (tag) { + target.comment.tags.splice(target.comment.tags.indexOf(tag), 1); + reflection.comment = new index_2.Comment('', tag.text); + break; + } + } + target = target.parent; + } + } + }; + DeepCommentPlugin = __decorate([ + components_1.Component({ name: 'deep-comment' }) + ], DeepCommentPlugin); + return DeepCommentPlugin; +}(components_1.ConverterComponent)); +exports.DeepCommentPlugin = DeepCommentPlugin; +//# sourceMappingURL=DeepCommentPlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/DeepCommentPlugin.js.map b/dist/lib/converter/plugins/DeepCommentPlugin.js.map new file mode 100644 index 000000000..aa8305666 --- /dev/null +++ b/dist/lib/converter/plugins/DeepCommentPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DeepCommentPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/DeepCommentPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,wDAA6H;AAC7H,qDAAkE;AAClE,4CAA8D;AAC9D,0CAAyC;AAOzC;IAAuC,qCAAkB;IAAzD;;IAiEA,CAAC;IA7DG,sCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,qBAAS,CAAC,mBAAmB,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACvF,CAAC;IAOO,0CAAc,GAAtB,UAAuB,OAAgB;QACnC,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,IAAI,IAAY,CAAC;QACjB,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,WAAW,CA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C,CAAC,CAAC;4BACP,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,GAAG,UAAU,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;wBACtE,CAAC;oBACL,CAAC;oBAED,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACP,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;oBAC/C,CAAC;oBAED,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACN,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;wBAChE,UAAU,CAAC,OAAO,GAAG,IAAI,eAAO,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;wBAC/C,KAAK,CAAC;oBACV,CAAC;gBACL,CAAC;gBAED,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;YAC3B,CAAC;QACL,CAAC;IACL,CAAC;IAhEQ,iBAAiB;QAD7B,sBAAS,CAAC,EAAC,IAAI,EAAE,cAAc,EAAC,CAAC;OACrB,iBAAiB,CAiE7B;IAAD,wBAAC;CAAA,AAjED,CAAuC,+BAAkB,GAiExD;AAjEY,8CAAiB","sourcesContent":["import { Reflection, SignatureReflection, ProjectReflection, TypeParameterReflection } from '../../models/reflections/index';\nimport { Comment, CommentTag } from '../../models/comments/index';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A handler that moves comments with dot syntax to their target.\n */\n@Component({name: 'deep-comment'})\nexport class DeepCommentPlugin extends ConverterComponent {\n /**\n * Create a new CommentHandler instance.\n */\n initialize() {\n this.listenTo(this.owner, Converter.EVENT_RESOLVE_BEGIN, this.onBeginResolve, 512);\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 let name: string;\n for (let key in project.reflections) {\n const reflection = project.reflections[key];\n if (!reflection.comment) {\n findDeepComment(reflection);\n }\n }\n\n function push(parent: Reflection) {\n let part = parent.originalName;\n if (!part || part.substr(0, 2) === '__' || parent instanceof SignatureReflection) {\n part = '';\n }\n\n if (part && part !== '') {\n name = (name === '' ? part : part + '.' + name);\n }\n }\n\n function findDeepComment(reflection: Reflection) {\n name = '';\n push(reflection);\n let target = reflection.parent;\n\n while (target && !(target instanceof ProjectReflection)) {\n push(target);\n if (target.comment) {\n let tag: CommentTag;\n if (reflection instanceof TypeParameterReflection) {\n tag = target.comment.getTag('typeparam', reflection.name);\n if (!tag) {\n tag = target.comment.getTag('param', '<' + reflection.name + '>');\n }\n }\n\n if (!tag) {\n tag = target.comment.getTag('param', name);\n }\n\n if (tag) {\n target.comment.tags.splice(target.comment.tags.indexOf(tag), 1);\n reflection.comment = new Comment('', tag.text);\n break;\n }\n }\n\n target = target.parent;\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/DynamicModulePlugin.d.ts b/dist/lib/converter/plugins/DynamicModulePlugin.d.ts new file mode 100644 index 000000000..84ad71030 --- /dev/null +++ b/dist/lib/converter/plugins/DynamicModulePlugin.d.ts @@ -0,0 +1,9 @@ +import { ConverterComponent } from '../components'; +export declare class DynamicModulePlugin extends ConverterComponent { + private basePath; + private reflections; + initialize(): void; + private onBegin(context); + private onDeclaration(context, reflection, node?); + private onBeginResolve(context); +} diff --git a/dist/lib/converter/plugins/DynamicModulePlugin.js b/dist/lib/converter/plugins/DynamicModulePlugin.js new file mode 100644 index 000000000..06eb4314e --- /dev/null +++ b/dist/lib/converter/plugins/DynamicModulePlugin.js @@ -0,0 +1,68 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var abstract_1 = require("../../models/reflections/abstract"); +var components_1 = require("../components"); +var base_path_1 = require("../utils/base-path"); +var converter_1 = require("../converter"); +var DynamicModulePlugin = (function (_super) { + __extends(DynamicModulePlugin, _super); + function DynamicModulePlugin() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.basePath = new base_path_1.BasePath(); + return _this; + } + DynamicModulePlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[converter_1.Converter.EVENT_BEGIN] = this.onBegin, + _a[converter_1.Converter.EVENT_CREATE_DECLARATION] = this.onDeclaration, + _a[converter_1.Converter.EVENT_RESOLVE_BEGIN] = this.onBeginResolve, + _a)); + var _a; + }; + DynamicModulePlugin.prototype.onBegin = function (context) { + this.basePath.reset(); + this.reflections = []; + }; + DynamicModulePlugin.prototype.onDeclaration = function (context, reflection, node) { + if (reflection.kindOf(abstract_1.ReflectionKind.ExternalModule)) { + var name_1 = reflection.name; + if (name_1.indexOf('/') === -1) { + return; + } + name_1 = name_1.replace(/"/g, ''); + this.reflections.push(reflection); + this.basePath.add(name_1); + } + }; + DynamicModulePlugin.prototype.onBeginResolve = function (context) { + var _this = this; + this.reflections.forEach(function (reflection) { + var name = reflection.name.replace(/"/g, ''); + name = name.substr(0, name.length - Path.extname(name).length); + reflection.name = '"' + _this.basePath.trim(name) + '"'; + }); + }; + DynamicModulePlugin = __decorate([ + components_1.Component({ name: 'dynamic-module' }) + ], DynamicModulePlugin); + return DynamicModulePlugin; +}(components_1.ConverterComponent)); +exports.DynamicModulePlugin = DynamicModulePlugin; +//# sourceMappingURL=DynamicModulePlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/DynamicModulePlugin.js.map b/dist/lib/converter/plugins/DynamicModulePlugin.js.map new file mode 100644 index 000000000..0b1bd698d --- /dev/null +++ b/dist/lib/converter/plugins/DynamicModulePlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DynamicModulePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/DynamicModulePlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,2BAA6B;AAE7B,8DAA+E;AAC/E,4CAA8D;AAC9D,gDAA8C;AAC9C,0CAAyC;AAQzC;IAAyC,uCAAkB;IAD3D;QAAA,qEAiEC;QA5DW,cAAQ,GAAG,IAAI,oBAAQ,EAAE,CAAC;;IA4DtC,CAAC;IAlDG,wCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,qBAAS,CAAC,WAAW,IAAgB,IAAI,CAAC,OAAO;YAClD,GAAC,qBAAS,CAAC,wBAAwB,IAAG,IAAI,CAAC,aAAa;YACxD,GAAC,qBAAS,CAAC,mBAAmB,IAAQ,IAAI,CAAC,cAAc;gBAC3D,CAAC;;IACP,CAAC;IAOO,qCAAO,GAAf,UAAgB,OAAgB;QAC5B,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IASO,2CAAa,GAArB,UAAsB,OAAgB,EAAE,UAAsB,EAAE,IAAc;QAC1E,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,yBAAc,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YACnD,IAAI,MAAI,GAAG,UAAU,CAAC,IAAI,CAAC;YAC3B,EAAE,CAAC,CAAC,MAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC3B,MAAM,CAAC;YACX,CAAC;YAED,MAAI,GAAG,MAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC9B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAI,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IAOO,4CAAc,GAAtB,UAAuB,OAAgB;QAAvC,iBAMC;QALG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAC,UAAU;YAChC,IAAI,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7C,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;YAC/D,UAAU,CAAC,IAAI,GAAG,GAAG,GAAG,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QAC3D,CAAC,CAAC,CAAC;IACP,CAAC;IA/DQ,mBAAmB;QAD/B,sBAAS,CAAC,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC;OACvB,mBAAmB,CAgE/B;IAAD,0BAAC;CAAA,AAhED,CAAyC,+BAAkB,GAgE1D;AAhEY,kDAAmB","sourcesContent":["import * as ts from 'typescript';\nimport * as Path from 'path';\n\nimport { Reflection, ReflectionKind } from '../../models/reflections/abstract';\nimport { Component, ConverterComponent } from '../components';\nimport { BasePath } from '../utils/base-path';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A handler that truncates the names of dynamic modules to not include the\n * project's base path.\n */\n@Component({name: 'dynamic-module'})\nexport class DynamicModulePlugin extends ConverterComponent {\n /**\n * Helper class for determining the base path.\n */\n private basePath = new BasePath();\n\n /**\n * List of reflections whose name must be trimmed.\n */\n private reflections: Reflection[];\n\n /**\n * Create a new DynamicModuleHandler instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [Converter.EVENT_BEGIN]: this.onBegin,\n [Converter.EVENT_CREATE_DECLARATION]: this.onDeclaration,\n [Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve\n });\n }\n\n /**\n * Triggered when the converter begins converting a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onBegin(context: Context) {\n this.basePath.reset();\n this.reflections = [];\n }\n\n /**\n * Triggered when the converter has created a declaration reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onDeclaration(context: Context, reflection: Reflection, node?: ts.Node) {\n if (reflection.kindOf(ReflectionKind.ExternalModule)) {\n let name = reflection.name;\n if (name.indexOf('/') === -1) {\n return;\n }\n\n name = name.replace(/\"/g, '');\n this.reflections.push(reflection);\n this.basePath.add(name);\n }\n }\n\n /**\n * Triggered when the converter begins resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onBeginResolve(context: Context) {\n this.reflections.forEach((reflection) => {\n let name = reflection.name.replace(/\"/g, '');\n name = name.substr(0, name.length - Path.extname(name).length);\n reflection.name = '\"' + this.basePath.trim(name) + '\"';\n });\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/GitHubPlugin.d.ts b/dist/lib/converter/plugins/GitHubPlugin.d.ts new file mode 100644 index 000000000..ac8e7deb2 --- /dev/null +++ b/dist/lib/converter/plugins/GitHubPlugin.d.ts @@ -0,0 +1,9 @@ +import { ConverterComponent } from '../components'; +export declare class GitHubPlugin extends ConverterComponent { + private repositories; + private ignoredPaths; + gitRevision: string; + initialize(): void; + private getRepository(fileName); + private onEndResolve(context); +} diff --git a/dist/lib/converter/plugins/GitHubPlugin.js b/dist/lib/converter/plugins/GitHubPlugin.js new file mode 100644 index 000000000..a324f757e --- /dev/null +++ b/dist/lib/converter/plugins/GitHubPlugin.js @@ -0,0 +1,165 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ShellJS = require("shelljs"); +var Path = require("path"); +var components_1 = require("../components"); +var base_path_1 = require("../utils/base-path"); +var converter_1 = require("../converter"); +var component_1 = require("../../utils/component"); +var declaration_1 = require("../../utils/options/declaration"); +var Repository = (function () { + function Repository(path, gitRevision) { + var _this = this; + this.files = []; + this.path = path; + this.branch = gitRevision || 'master'; + ShellJS.pushd(path); + var out = ShellJS.exec('git ls-remote --get-url', { silent: true }); + if (out.code === 0) { + var url = void 0; + var remotes = out.stdout.split('\n'); + for (var i = 0, c = remotes.length; i < c; i++) { + url = /github\.com[:\/]([^\/]+)\/(.*)/.exec(remotes[i]); + if (url) { + this.gitHubUser = url[1]; + this.gitHubProject = url[2]; + if (this.gitHubProject.substr(-4) === '.git') { + this.gitHubProject = this.gitHubProject.substr(0, this.gitHubProject.length - 4); + } + break; + } + } + } + out = ShellJS.exec('git ls-files', { silent: true }); + if (out.code === 0) { + out.stdout.split('\n').forEach(function (file) { + if (file !== '') { + _this.files.push(base_path_1.BasePath.normalize(path + '/' + file)); + } + }); + } + if (!gitRevision) { + out = ShellJS.exec('git rev-parse --short HEAD', { silent: true }); + if (out.code === 0) { + this.branch = out.stdout.replace('\n', ''); + } + } + ShellJS.popd(); + } + Repository.prototype.contains = function (fileName) { + return this.files.indexOf(fileName) !== -1; + }; + Repository.prototype.getGitHubURL = function (fileName) { + if (!this.gitHubUser || !this.gitHubProject || !this.contains(fileName)) { + return null; + } + return [ + 'https://github.com', + this.gitHubUser, + this.gitHubProject, + 'blob', + this.branch, + fileName.substr(this.path.length + 1) + ].join('/'); + }; + Repository.tryCreateRepository = function (path, gitRevision) { + ShellJS.pushd(path); + var out = ShellJS.exec('git rev-parse --show-toplevel', { silent: true }); + ShellJS.popd(); + if (!out || out.code !== 0) { + return null; + } + return new Repository(base_path_1.BasePath.normalize(out.stdout.replace('\n', '')), gitRevision); + }; + return Repository; +}()); +var GitHubPlugin = (function (_super) { + __extends(GitHubPlugin, _super); + function GitHubPlugin() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.repositories = {}; + _this.ignoredPaths = []; + return _this; + } + GitHubPlugin.prototype.initialize = function () { + ShellJS.config.silent = true; + if (ShellJS.which('git')) { + this.listenTo(this.owner, converter_1.Converter.EVENT_RESOLVE_END, this.onEndResolve); + } + }; + GitHubPlugin.prototype.getRepository = function (fileName) { + var dirName = Path.dirname(fileName); + for (var i = 0, c = this.ignoredPaths.length; i < c; i++) { + if (this.ignoredPaths[i] === dirName) { + return null; + } + } + for (var path in this.repositories) { + if (!this.repositories.hasOwnProperty(path)) { + continue; + } + if (fileName.substr(0, path.length) === path) { + return this.repositories[path]; + } + } + var repository = Repository.tryCreateRepository(dirName, this.gitRevision); + if (repository) { + this.repositories[repository.path] = repository; + return repository; + } + var segments = dirName.split('/'); + for (var i = segments.length; i > 0; i--) { + this.ignoredPaths.push(segments.slice(0, i).join('/')); + } + return null; + }; + GitHubPlugin.prototype.onEndResolve = function (context) { + var _this = this; + var project = context.project; + project.files.forEach(function (sourceFile) { + var repository = _this.getRepository(sourceFile.fullFileName); + if (repository) { + sourceFile.url = repository.getGitHubURL(sourceFile.fullFileName); + } + }); + for (var key in project.reflections) { + var reflection = project.reflections[key]; + if (reflection.sources) { + reflection.sources.forEach(function (source) { + if (source.file && source.file.url) { + source.url = source.file.url + '#L' + source.line; + } + }); + } + } + }; + __decorate([ + component_1.Option({ + name: 'gitRevision', + help: 'Use specified revision instead of the last revision for linking to GitHub source files.', + type: declaration_1.ParameterType.String + }) + ], GitHubPlugin.prototype, "gitRevision", void 0); + GitHubPlugin = __decorate([ + components_1.Component({ name: 'git-hub' }) + ], GitHubPlugin); + return GitHubPlugin; +}(components_1.ConverterComponent)); +exports.GitHubPlugin = GitHubPlugin; +//# sourceMappingURL=GitHubPlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/GitHubPlugin.js.map b/dist/lib/converter/plugins/GitHubPlugin.js.map new file mode 100644 index 000000000..a31786820 --- /dev/null +++ b/dist/lib/converter/plugins/GitHubPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GitHubPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/GitHubPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAAmC;AACnC,2BAA6B;AAG7B,4CAA8D;AAC9D,gDAA8C;AAC9C,0CAAyC;AAEzC,mDAA+C;AAC/C,+DAAgE;AAKhE;IA+BI,oBAAY,IAAY,EAAE,WAAmB;QAA7C,iBAuCC;QAxDD,UAAK,GAAa,EAAE,CAAC;QAkBjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,WAAW,IAAI,QAAQ,CAAC;QAC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["import * as ShellJS from 'shelljs';\nimport * as Path from 'path';\n\nimport { SourceReference } from '../../models/sources/file';\nimport { Component, ConverterComponent } from '../components';\nimport { BasePath } from '../utils/base-path';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { Option } from '../../utils/component';\nimport { ParameterType } from '../../utils/options/declaration';\n\n/**\n * Stores data of a repository.\n */\nclass Repository {\n /**\n * The root path of this repository.\n */\n path: string;\n\n /**\n * The name of the branch this repository is on right now.\n */\n branch: string;\n\n /**\n * A list of all files tracked by the repository.\n */\n files: string[] = [];\n\n /**\n * The user/organisation name of this repository on GitHub.\n */\n gitHubUser: string;\n\n /**\n * The project name of this repository on GitHub.\n */\n gitHubProject: string;\n\n /**\n * Create a new Repository instance.\n *\n * @param path The root path of the repository.\n */\n constructor(path: string, gitRevision: string) {\n this.path = path;\n this.branch = gitRevision || 'master';\n ShellJS.pushd(path);\n\n let out = ShellJS.exec('git ls-remote --get-url', {silent: true});\n if (out.code === 0) {\n let url: RegExpExecArray;\n const remotes = out.stdout.split('\\n');\n for (let i = 0, c = remotes.length; i < c; i++) {\n url = /github\\.com[:\\/]([^\\/]+)\\/(.*)/.exec(remotes[i]);\n if (url) {\n this.gitHubUser = url[1];\n this.gitHubProject = url[2];\n if (this.gitHubProject.substr(-4) === '.git') {\n this.gitHubProject = this.gitHubProject.substr(0, this.gitHubProject.length - 4);\n }\n break;\n }\n }\n }\n\n out = ShellJS.exec('git ls-files', {silent: true});\n if (out.code === 0) {\n out.stdout.split('\\n').forEach((file) => {\n if (file !== '') {\n this.files.push(BasePath.normalize(path + '/' + file));\n }\n });\n }\n\n if (!gitRevision) {\n out = ShellJS.exec('git rev-parse --short HEAD', {silent: true});\n if (out.code === 0) {\n this.branch = out.stdout.replace('\\n', '');\n }\n }\n\n ShellJS.popd();\n }\n\n /**\n * Check whether the given file is tracked by this repository.\n *\n * @param fileName The name of the file to test for.\n * @returns TRUE when the file is part of the repository, otherwise FALSE.\n */\n contains(fileName: string): boolean {\n return this.files.indexOf(fileName) !== -1;\n }\n\n /**\n * Get the URL of the given file on GitHub.\n *\n * @param fileName The file whose GitHub URL should be determined.\n * @returns An url pointing to the web preview of the given file or NULL.\n */\n getGitHubURL(fileName: string): string {\n if (!this.gitHubUser || !this.gitHubProject || !this.contains(fileName)) {\n return null;\n }\n\n return [\n 'https://github.com',\n this.gitHubUser,\n this.gitHubProject,\n 'blob',\n this.branch,\n fileName.substr(this.path.length + 1)\n ].join('/');\n }\n\n /**\n * Try to create a new repository instance.\n *\n * Checks whether the given path is the root of a valid repository and if so\n * creates a new instance of [[Repository]].\n *\n * @param path The potential repository root.\n * @returns A new instance of [[Repository]] or NULL.\n */\n static tryCreateRepository(path: string, gitRevision: string): Repository {\n ShellJS.pushd(path);\n const out = ShellJS.exec('git rev-parse --show-toplevel', {silent: true});\n ShellJS.popd();\n\n if (!out || out.code !== 0) {\n return null;\n }\n return new Repository(BasePath.normalize(out.stdout.replace('\\n', '')), gitRevision);\n }\n}\n\n/**\n * A handler that watches for repositories with GitHub origin and links\n * their source files to the related GitHub pages.\n */\n@Component({name: 'git-hub'})\nexport class GitHubPlugin extends ConverterComponent {\n /**\n * List of known repositories.\n */\n private repositories: {[path: string]: Repository} = {};\n\n /**\n * List of paths known to be not under git control.\n */\n private ignoredPaths: string[] = [];\n\n @Option({\n name: 'gitRevision',\n help: 'Use specified revision instead of the last revision for linking to GitHub source files.',\n type: ParameterType.String\n })\n gitRevision: string;\n\n /**\n * Create a new GitHubHandler instance.\n *\n * @param converter The converter this plugin should be attached to.\n */\n initialize() {\n ShellJS.config.silent = true;\n if (ShellJS.which('git')) {\n this.listenTo(this.owner, Converter.EVENT_RESOLVE_END, this.onEndResolve);\n }\n }\n\n /**\n * Check whether the given file is placed inside a repository.\n *\n * @param fileName The name of the file a repository should be looked for.\n * @returns The found repository info or NULL.\n */\n private getRepository(fileName: string): Repository {\n // Check for known non-repositories\n const dirName = Path.dirname(fileName);\n for (let i = 0, c = this.ignoredPaths.length; i < c; i++) {\n if (this.ignoredPaths[i] === dirName) {\n return null;\n }\n }\n\n // Check for known repositories\n for (let path in this.repositories) {\n if (!this.repositories.hasOwnProperty(path)) {\n continue;\n }\n if (fileName.substr(0, path.length) === path) {\n return this.repositories[path];\n }\n }\n\n // Try to create a new repository\n const repository = Repository.tryCreateRepository(dirName, this.gitRevision);\n if (repository) {\n this.repositories[repository.path] = repository;\n return repository;\n }\n\n // No repository found, add path to ignored paths\n const segments = dirName.split('/');\n for (let i = segments.length; i > 0; i--) {\n this.ignoredPaths.push(segments.slice(0, i).join('/'));\n }\n\n return null;\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onEndResolve(context: Context) {\n const project = context.project;\n project.files.forEach((sourceFile) => {\n const repository = this.getRepository(sourceFile.fullFileName);\n if (repository) {\n sourceFile.url = repository.getGitHubURL(sourceFile.fullFileName);\n }\n });\n\n for (let key in project.reflections) {\n const reflection = project.reflections[key];\n if (reflection.sources) {\n reflection.sources.forEach((source: SourceReference) => {\n if (source.file && source.file.url) {\n source.url = source.file.url + '#L' + source.line;\n }\n });\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/GroupPlugin.d.ts b/dist/lib/converter/plugins/GroupPlugin.d.ts new file mode 100644 index 000000000..7e5c6bb03 --- /dev/null +++ b/dist/lib/converter/plugins/GroupPlugin.d.ts @@ -0,0 +1,16 @@ +import { Reflection, ReflectionKind } from '../../models/reflections/index'; +import { ReflectionGroup } from '../../models/ReflectionGroup'; +import { ConverterComponent } from '../components'; +export declare class GroupPlugin extends ConverterComponent { + static WEIGHTS: ReflectionKind[]; + static SINGULARS: {}; + static PLURALS: {}; + initialize(): void; + private onResolve(context, reflection); + private onEndResolve(context); + static getReflectionGroups(reflections: Reflection[]): ReflectionGroup[]; + private static getKindString(kind); + static getKindSingular(kind: ReflectionKind): string; + static getKindPlural(kind: ReflectionKind): string; + static sortCallback(a: Reflection, b: Reflection): number; +} diff --git a/dist/lib/converter/plugins/GroupPlugin.js b/dist/lib/converter/plugins/GroupPlugin.js new file mode 100644 index 000000000..6ecc07810 --- /dev/null +++ b/dist/lib/converter/plugins/GroupPlugin.js @@ -0,0 +1,191 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/reflections/index"); +var ReflectionGroup_1 = require("../../models/ReflectionGroup"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var GroupPlugin = (function (_super) { + __extends(GroupPlugin, _super); + function GroupPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + GroupPlugin_1 = GroupPlugin; + GroupPlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[converter_1.Converter.EVENT_RESOLVE] = this.onResolve, + _a[converter_1.Converter.EVENT_RESOLVE_END] = this.onEndResolve, + _a)); + var _a; + }; + GroupPlugin.prototype.onResolve = function (context, reflection) { + reflection.kindString = GroupPlugin_1.getKindSingular(reflection.kind); + if (reflection instanceof index_1.ContainerReflection) { + var container = reflection; + if (container.children && container.children.length > 0) { + container.children.sort(GroupPlugin_1.sortCallback); + container.groups = GroupPlugin_1.getReflectionGroups(container.children); + } + } + }; + GroupPlugin.prototype.onEndResolve = function (context) { + function walkDirectory(directory) { + directory.groups = GroupPlugin_1.getReflectionGroups(directory.getAllReflections()); + for (var key in directory.directories) { + if (!directory.directories.hasOwnProperty(key)) { + continue; + } + walkDirectory(directory.directories[key]); + } + } + var project = context.project; + if (project.children && project.children.length > 0) { + project.children.sort(GroupPlugin_1.sortCallback); + project.groups = GroupPlugin_1.getReflectionGroups(project.children); + } + walkDirectory(project.directory); + project.files.forEach(function (file) { + file.groups = GroupPlugin_1.getReflectionGroups(file.reflections); + }); + }; + GroupPlugin.getReflectionGroups = function (reflections) { + var groups = []; + reflections.forEach(function (child) { + for (var i = 0; i < groups.length; i++) { + var group_1 = groups[i]; + if (group_1.kind !== child.kind) { + continue; + } + group_1.children.push(child); + return; + } + var group = new ReflectionGroup_1.ReflectionGroup(GroupPlugin_1.getKindPlural(child.kind), child.kind); + group.children.push(child); + groups.push(group); + }); + groups.forEach(function (group) { + var someExported = false, allInherited = true, allPrivate = true, allProtected = true, allExternal = true; + group.children.forEach(function (child) { + someExported = child.flags.isExported || someExported; + allPrivate = child.flags.isPrivate && allPrivate; + allProtected = (child.flags.isPrivate || child.flags.isProtected) && allProtected; + allExternal = child.flags.isExternal && allExternal; + if (child instanceof index_1.DeclarationReflection) { + allInherited = child.inheritedFrom && allInherited; + } + else { + allInherited = false; + } + }); + group.someChildrenAreExported = someExported; + group.allChildrenAreInherited = allInherited; + group.allChildrenArePrivate = allPrivate; + group.allChildrenAreProtectedOrPrivate = allProtected; + group.allChildrenAreExternal = allExternal; + }); + return groups; + }; + GroupPlugin.getKindString = function (kind) { + var str = index_1.ReflectionKind[kind]; + str = str.replace(/(.)([A-Z])/g, function (m, a, b) { return a + ' ' + b.toLowerCase(); }); + return str; + }; + GroupPlugin.getKindSingular = function (kind) { + if (GroupPlugin_1.SINGULARS[kind]) { + return GroupPlugin_1.SINGULARS[kind]; + } + else { + return GroupPlugin_1.getKindString(kind); + } + }; + GroupPlugin.getKindPlural = function (kind) { + if (GroupPlugin_1.PLURALS[kind]) { + return GroupPlugin_1.PLURALS[kind]; + } + else { + return this.getKindString(kind) + 's'; + } + }; + GroupPlugin.sortCallback = function (a, b) { + var aWeight = GroupPlugin_1.WEIGHTS.indexOf(a.kind); + var bWeight = GroupPlugin_1.WEIGHTS.indexOf(b.kind); + if (aWeight === bWeight) { + if (a.flags.isStatic && !b.flags.isStatic) { + return 1; + } + if (!a.flags.isStatic && b.flags.isStatic) { + return -1; + } + if (a.name === b.name) { + return 0; + } + return a.name > b.name ? 1 : -1; + } + else { + return aWeight - bWeight; + } + }; + GroupPlugin.WEIGHTS = [ + index_1.ReflectionKind.Global, + index_1.ReflectionKind.ExternalModule, + index_1.ReflectionKind.Module, + index_1.ReflectionKind.Enum, + index_1.ReflectionKind.EnumMember, + index_1.ReflectionKind.Class, + index_1.ReflectionKind.Interface, + index_1.ReflectionKind.TypeAlias, + index_1.ReflectionKind.Constructor, + index_1.ReflectionKind.Event, + index_1.ReflectionKind.Property, + index_1.ReflectionKind.Variable, + index_1.ReflectionKind.Function, + index_1.ReflectionKind.Accessor, + index_1.ReflectionKind.Method, + index_1.ReflectionKind.ObjectLiteral, + index_1.ReflectionKind.Parameter, + index_1.ReflectionKind.TypeParameter, + index_1.ReflectionKind.TypeLiteral, + index_1.ReflectionKind.CallSignature, + index_1.ReflectionKind.ConstructorSignature, + index_1.ReflectionKind.IndexSignature, + index_1.ReflectionKind.GetSignature, + index_1.ReflectionKind.SetSignature + ]; + GroupPlugin.SINGULARS = (function () { + var singulars = {}; + singulars[index_1.ReflectionKind.Enum] = 'Enumeration'; + singulars[index_1.ReflectionKind.EnumMember] = 'Enumeration member'; + return singulars; + })(); + GroupPlugin.PLURALS = (function () { + var plurals = {}; + plurals[index_1.ReflectionKind.Class] = 'Classes'; + plurals[index_1.ReflectionKind.Property] = 'Properties'; + plurals[index_1.ReflectionKind.Enum] = 'Enumerations'; + plurals[index_1.ReflectionKind.EnumMember] = 'Enumeration members'; + plurals[index_1.ReflectionKind.TypeAlias] = 'Type aliases'; + return plurals; + })(); + GroupPlugin = GroupPlugin_1 = __decorate([ + components_1.Component({ name: 'group' }) + ], GroupPlugin); + return GroupPlugin; + var GroupPlugin_1; +}(components_1.ConverterComponent)); +exports.GroupPlugin = GroupPlugin; +//# sourceMappingURL=GroupPlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/GroupPlugin.js.map b/dist/lib/converter/plugins/GroupPlugin.js.map new file mode 100644 index 000000000..1440e1990 --- /dev/null +++ b/dist/lib/converter/plugins/GroupPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GroupPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/GroupPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,wDAAwH;AACxH,gEAA+D;AAE/D,4CAA8D;AAC9D,0CAAyC;AASzC;IAAiC,+BAAkB;IAAnD;;IAqOA,CAAC;oBArOY,WAAW;IA2DpB,gCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,qBAAS,CAAC,aAAa,IAAO,IAAI,CAAC,SAAS;YAC7C,GAAC,qBAAS,CAAC,iBAAiB,IAAG,IAAI,CAAC,YAAY;gBAClD,CAAC;;IACP,CAAC;IAQO,+BAAS,GAAjB,UAAkB,OAAgB,EAAE,UAAsB;QACtD,UAAU,CAAC,UAAU,GAAG,aAAW,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAErE,EAAE,CAAC,CAAC,UAAU,YAAY,2BAAmB,CAAC,CAAC,CAAC;YAC5C,IAAM,SAAS,GAAyB,UAAU,CAAC;YACnD,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;gBACtD,SAAS,CAAC,QAAQ,CAAC,IAAI,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C;IACnB,CAAC,CAAC,EAAE,CAAC;IAtDI,WAAW;QADvB,sBAAS,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;OACd,WAAW,CAqOvB;IAAD,kBAAC;;CAAA,AArOD,CAAiC,+BAAkB,GAqOlD;AArOY,kCAAW","sourcesContent":["import { Reflection, ReflectionKind, ContainerReflection, DeclarationReflection } from '../../models/reflections/index';\nimport { ReflectionGroup } from '../../models/ReflectionGroup';\nimport { SourceDirectory } from '../../models/sources/directory';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A handler that sorts and groups the found reflections in the resolving phase.\n *\n * The handler sets the ´groups´ property of all reflections.\n */\n@Component({name: 'group'})\nexport class GroupPlugin extends ConverterComponent {\n /**\n * Define the sort order of reflections.\n */\n static WEIGHTS = [\n ReflectionKind.Global,\n ReflectionKind.ExternalModule,\n ReflectionKind.Module,\n ReflectionKind.Enum,\n ReflectionKind.EnumMember,\n ReflectionKind.Class,\n ReflectionKind.Interface,\n ReflectionKind.TypeAlias,\n\n ReflectionKind.Constructor,\n ReflectionKind.Event,\n ReflectionKind.Property,\n ReflectionKind.Variable,\n ReflectionKind.Function,\n ReflectionKind.Accessor,\n ReflectionKind.Method,\n ReflectionKind.ObjectLiteral,\n\n ReflectionKind.Parameter,\n ReflectionKind.TypeParameter,\n ReflectionKind.TypeLiteral,\n ReflectionKind.CallSignature,\n ReflectionKind.ConstructorSignature,\n ReflectionKind.IndexSignature,\n ReflectionKind.GetSignature,\n ReflectionKind.SetSignature\n ];\n\n /**\n * Define the singular name of individual reflection kinds.\n */\n static SINGULARS = (function() {\n const singulars = {};\n singulars[ReflectionKind.Enum] = 'Enumeration';\n singulars[ReflectionKind.EnumMember] = 'Enumeration member';\n return singulars;\n })();\n\n /**\n * Define the plural name of individual reflection kinds.\n */\n static PLURALS = (function() {\n const plurals = {};\n plurals[ReflectionKind.Class] = 'Classes';\n plurals[ReflectionKind.Property] = 'Properties';\n plurals[ReflectionKind.Enum] = 'Enumerations';\n plurals[ReflectionKind.EnumMember] = 'Enumeration members';\n plurals[ReflectionKind.TypeAlias] = 'Type aliases';\n return plurals;\n })();\n\n /**\n * Create a new GroupPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [Converter.EVENT_RESOLVE]: this.onResolve,\n [Converter.EVENT_RESOLVE_END]: this.onEndResolve\n });\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: Reflection) {\n reflection.kindString = GroupPlugin.getKindSingular(reflection.kind);\n\n if (reflection instanceof ContainerReflection) {\n const container = reflection;\n if (container.children && container.children.length > 0) {\n container.children.sort(GroupPlugin.sortCallback);\n container.groups = GroupPlugin.getReflectionGroups(container.children);\n }\n }\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onEndResolve(context: Context) {\n function walkDirectory(directory: SourceDirectory) {\n directory.groups = GroupPlugin.getReflectionGroups(directory.getAllReflections());\n\n for (let key in directory.directories) {\n if (!directory.directories.hasOwnProperty(key)) {\n continue;\n }\n walkDirectory(directory.directories[key]);\n }\n }\n\n const project = context.project;\n if (project.children && project.children.length > 0) {\n project.children.sort(GroupPlugin.sortCallback);\n project.groups = GroupPlugin.getReflectionGroups(project.children);\n }\n\n walkDirectory(project.directory);\n project.files.forEach((file) => {\n file.groups = GroupPlugin.getReflectionGroups(file.reflections);\n });\n }\n\n /**\n * Create a grouped representation of the given list of reflections.\n *\n * Reflections are grouped by kind and sorted by weight and name.\n *\n * @param reflections The reflections that should be grouped.\n * @returns An array containing all children of the given reflection grouped by their kind.\n */\n static getReflectionGroups(reflections: Reflection[]): ReflectionGroup[] {\n const groups: ReflectionGroup[] = [];\n reflections.forEach((child) => {\n for (let i = 0; i < groups.length; i++) {\n const group = groups[i];\n if (group.kind !== child.kind) {\n continue;\n }\n\n group.children.push(child);\n return;\n }\n\n const group = new ReflectionGroup(GroupPlugin.getKindPlural(child.kind), child.kind);\n group.children.push(child);\n groups.push(group);\n });\n\n groups.forEach((group) => {\n let someExported = false, allInherited = true, allPrivate = true, allProtected = true, allExternal = true;\n group.children.forEach((child) => {\n someExported = child.flags.isExported || someExported;\n allPrivate = child.flags.isPrivate && allPrivate;\n allProtected = (child.flags.isPrivate || child.flags.isProtected) && allProtected;\n allExternal = child.flags.isExternal && allExternal;\n\n if (child instanceof DeclarationReflection) {\n allInherited = child.inheritedFrom && allInherited;\n } else {\n allInherited = false;\n }\n });\n\n group.someChildrenAreExported = someExported;\n group.allChildrenAreInherited = allInherited;\n group.allChildrenArePrivate = allPrivate;\n group.allChildrenAreProtectedOrPrivate = allProtected;\n group.allChildrenAreExternal = allExternal;\n });\n\n return groups;\n }\n\n /**\n * Transform the internal typescript kind identifier into a human readable version.\n *\n * @param kind The original typescript kind identifier.\n * @returns A human readable version of the given typescript kind identifier.\n */\n private static getKindString(kind: ReflectionKind): string {\n let str = ReflectionKind[kind];\n str = str.replace(/(.)([A-Z])/g, (m, a, b) => a + ' ' + b.toLowerCase());\n return str;\n }\n\n /**\n * Return the singular name of a internal typescript kind identifier.\n *\n * @param kind The original internal typescript kind identifier.\n * @returns The singular name of the given internal typescript kind identifier\n */\n static getKindSingular(kind: ReflectionKind): string {\n if (GroupPlugin.SINGULARS[kind]) {\n return GroupPlugin.SINGULARS[kind];\n } else {\n return GroupPlugin.getKindString(kind);\n }\n }\n\n /**\n * Return the plural name of a internal typescript kind identifier.\n *\n * @param kind The original internal typescript kind identifier.\n * @returns The plural name of the given internal typescript kind identifier\n */\n static getKindPlural(kind: ReflectionKind): string {\n if (GroupPlugin.PLURALS[kind]) {\n return GroupPlugin.PLURALS[kind];\n } else {\n return this.getKindString(kind) + 's';\n }\n }\n\n /**\n * Callback used to sort reflections by weight defined by ´GroupPlugin.WEIGHTS´ and name.\n *\n * @param a The left reflection to sort.\n * @param b The right reflection to sort.\n * @returns The sorting weight.\n */\n static sortCallback(a: Reflection, b: Reflection): number {\n const aWeight = GroupPlugin.WEIGHTS.indexOf(a.kind);\n const bWeight = GroupPlugin.WEIGHTS.indexOf(b.kind);\n if (aWeight === bWeight) {\n if (a.flags.isStatic && !b.flags.isStatic) {\n return 1;\n }\n if (!a.flags.isStatic && b.flags.isStatic) {\n return -1;\n }\n if (a.name === b.name) {\n return 0;\n }\n return a.name > b.name ? 1 : -1;\n } else {\n return aWeight - bWeight;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/ImplementsPlugin.d.ts b/dist/lib/converter/plugins/ImplementsPlugin.d.ts new file mode 100644 index 000000000..d019db17c --- /dev/null +++ b/dist/lib/converter/plugins/ImplementsPlugin.d.ts @@ -0,0 +1,7 @@ +import { ConverterComponent } from '../components'; +export declare class ImplementsPlugin extends ConverterComponent { + initialize(): void; + private analyzeClass(context, classReflection, interfaceReflection); + private copyComment(target, source); + private onResolve(context, reflection); +} diff --git a/dist/lib/converter/plugins/ImplementsPlugin.js b/dist/lib/converter/plugins/ImplementsPlugin.js new file mode 100644 index 000000000..0802bd63c --- /dev/null +++ b/dist/lib/converter/plugins/ImplementsPlugin.js @@ -0,0 +1,107 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/reflections/index"); +var index_2 = require("../../models/types/index"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var ImplementsPlugin = (function (_super) { + __extends(ImplementsPlugin, _super); + function ImplementsPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + ImplementsPlugin.prototype.initialize = function () { + this.listenTo(this.owner, converter_1.Converter.EVENT_RESOLVE, this.onResolve, -10); + }; + ImplementsPlugin.prototype.analyzeClass = function (context, classReflection, interfaceReflection) { + var _this = this; + if (!interfaceReflection.children) { + return; + } + interfaceReflection.children.forEach(function (interfaceMember) { + if (!(interfaceMember instanceof index_1.DeclarationReflection)) { + return; + } + var classMember; + if (!classReflection.children) { + return; + } + for (var index = 0, count = classReflection.children.length; index < count; index++) { + var child = classReflection.children[index]; + if (child.name !== interfaceMember.name) { + continue; + } + if (child.flags.isStatic !== interfaceMember.flags.isStatic) { + continue; + } + classMember = child; + break; + } + if (!classMember) { + return; + } + var interfaceMemberName = interfaceReflection.name + '.' + interfaceMember.name; + classMember.implementationOf = new index_2.ReferenceType(interfaceMemberName, index_2.ReferenceType.SYMBOL_ID_RESOLVED, interfaceMember); + _this.copyComment(classMember, interfaceMember); + if (interfaceMember.kindOf(index_1.ReflectionKind.FunctionOrMethod) && interfaceMember.signatures && classMember.signatures) { + interfaceMember.signatures.forEach(function (interfaceSignature) { + var interfaceParameters = interfaceSignature.getParameterTypes(); + classMember.signatures.forEach(function (classSignature) { + if (index_2.Type.isTypeListEqual(interfaceParameters, classSignature.getParameterTypes())) { + classSignature.implementationOf = new index_2.ReferenceType(interfaceMemberName, index_2.ReferenceType.SYMBOL_ID_RESOLVED, interfaceSignature); + _this.copyComment(classSignature, interfaceSignature); + } + }); + }); + } + }); + }; + ImplementsPlugin.prototype.copyComment = function (target, source) { + if (target.comment && source.comment && target.comment.hasTag('inheritdoc')) { + target.comment.copyFrom(source.comment); + if (target instanceof index_1.SignatureReflection && target.parameters && + source instanceof index_1.SignatureReflection && source.parameters) { + for (var index = 0, count = target.parameters.length; index < count; index++) { + if (target.parameters[index].comment) { + target.parameters[index].comment.copyFrom(source.parameters[index].comment); + } + } + } + } + }; + ImplementsPlugin.prototype.onResolve = function (context, reflection) { + var _this = this; + if (reflection.kindOf(index_1.ReflectionKind.Class) && reflection.implementedTypes) { + reflection.implementedTypes.forEach(function (type) { + if (!(type instanceof index_2.ReferenceType)) { + return; + } + var source = type.reflection; + if (source && source.kindOf(index_1.ReflectionKind.Interface)) { + _this.analyzeClass(context, reflection, source); + } + }); + } + }; + ImplementsPlugin = __decorate([ + components_1.Component({ name: 'implements' }) + ], ImplementsPlugin); + return ImplementsPlugin; +}(components_1.ConverterComponent)); +exports.ImplementsPlugin = ImplementsPlugin; +//# sourceMappingURL=ImplementsPlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/ImplementsPlugin.js.map b/dist/lib/converter/plugins/ImplementsPlugin.js.map new file mode 100644 index 000000000..6b2b30636 --- /dev/null +++ b/dist/lib/converter/plugins/ImplementsPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ImplementsPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/ImplementsPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,wDAAwH;AACxH,kDAA+D;AAC/D,4CAA8D;AAC9D,0CAAyC;AAQzC;IAAsC,oCAAkB;IAAxD;;IA2GA,CAAC;IAvGG,qCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,qBAAS,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IASO,uCAAY,GAApB,UAAqB,OAAgB,EAAE,eAAsC,EAAE,mBAA0C;QAAzH,iBAiDC;QAhDG,EAAE,CA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UAAU,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;oBAC3E,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;wBACnC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;oBAChF,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAQO,oCAAS,GAAjB,UAAkB,OAAgB,EAAE,UAAiC;QAArE,iBAaC;QAZG,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,sBAAc,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC;YACzE,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAC,IAAU;gBAC3C,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,qBAAa,CAAC,CAAC,CAAC,CAAC;oBACnC,MAAM,CAAC;gBACX,CAAC;gBAED,IAAM,MAAM,GAA4C,IAAK,CAAC,UAAU,CAAC;gBACzE,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;oBACpD,KAAI,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;gBACnD,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IA1GQ,gBAAgB;QAD5B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,gBAAgB,CA2G5B;IAAD,uBAAC;CAAA,AA3GD,CAAsC,+BAAkB,GA2GvD;AA3GY,4CAAgB","sourcesContent":["import { Reflection, ReflectionKind, DeclarationReflection, SignatureReflection } from '../../models/reflections/index';\nimport { Type, ReferenceType } from '../../models/types/index';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A plugin that detects interface implementations of functions and\n * properties on classes and links them.\n */\n@Component({name: 'implements'})\nexport class ImplementsPlugin extends ConverterComponent {\n /**\n * Create a new ImplementsPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, Converter.EVENT_RESOLVE, this.onResolve, -10);\n }\n\n /**\n * Mark all members of the given class to be the implementation of the matching interface member.\n *\n * @param context The context object describing the current state the converter is in.\n * @param classReflection The reflection of the classReflection class.\n * @param interfaceReflection The reflection of the interfaceReflection interface.\n */\n private analyzeClass(context: Context, classReflection: DeclarationReflection, interfaceReflection: DeclarationReflection) {\n if (!interfaceReflection.children) {\n return;\n }\n\n interfaceReflection.children.forEach((interfaceMember: DeclarationReflection) => {\n if (!(interfaceMember instanceof DeclarationReflection)) {\n return;\n }\n\n let classMember: DeclarationReflection;\n\n if (!classReflection.children) {\n return;\n }\n\n for (let index = 0, count = classReflection.children.length; index < count; index++) {\n const child = classReflection.children[index];\n if (child.name !== interfaceMember.name) {\n continue;\n }\n if (child.flags.isStatic !== interfaceMember.flags.isStatic) {\n continue;\n }\n\n classMember = child;\n break;\n }\n\n if (!classMember) {\n return;\n }\n\n const interfaceMemberName = interfaceReflection.name + '.' + interfaceMember.name;\n classMember.implementationOf = new ReferenceType(interfaceMemberName, ReferenceType.SYMBOL_ID_RESOLVED, interfaceMember);\n this.copyComment(classMember, interfaceMember);\n\n if (interfaceMember.kindOf(ReflectionKind.FunctionOrMethod) && interfaceMember.signatures && classMember.signatures) {\n interfaceMember.signatures.forEach((interfaceSignature: SignatureReflection) => {\n const interfaceParameters = interfaceSignature.getParameterTypes();\n classMember.signatures.forEach((classSignature: SignatureReflection) => {\n if (Type.isTypeListEqual(interfaceParameters, classSignature.getParameterTypes())) {\n classSignature.implementationOf = new ReferenceType(interfaceMemberName, ReferenceType.SYMBOL_ID_RESOLVED, interfaceSignature);\n this.copyComment(classSignature, interfaceSignature);\n }\n });\n });\n }\n });\n }\n\n /**\n * Copy the comment of the source reflection to the target reflection.\n *\n * @param target\n * @param source\n */\n private copyComment(target: Reflection, source: Reflection) {\n if (target.comment && source.comment && target.comment.hasTag('inheritdoc')) {\n target.comment.copyFrom(source.comment);\n\n if (target instanceof SignatureReflection && target.parameters &&\n source instanceof SignatureReflection && source.parameters) {\n for (let index = 0, count = target.parameters.length; index < count; index++) {\n if (target.parameters[index].comment) {\n target.parameters[index].comment.copyFrom(source.parameters[index].comment);\n }\n }\n }\n }\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: DeclarationReflection) {\n if (reflection.kindOf(ReflectionKind.Class) && reflection.implementedTypes) {\n reflection.implementedTypes.forEach((type: Type) => {\n if (!(type instanceof ReferenceType)) {\n return;\n }\n\n const source = ( type).reflection;\n if (source && source.kindOf(ReflectionKind.Interface)) {\n this.analyzeClass(context, reflection, source);\n }\n });\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/PackagePlugin.d.ts b/dist/lib/converter/plugins/PackagePlugin.d.ts new file mode 100644 index 000000000..a07989b98 --- /dev/null +++ b/dist/lib/converter/plugins/PackagePlugin.d.ts @@ -0,0 +1,12 @@ +import { ConverterComponent } from '../components'; +export declare class PackagePlugin extends ConverterComponent { + readme: string; + private readmeFile; + private packageFile; + private visited; + private noReadmeFile; + initialize(): void; + private onBegin(context); + private onBeginDocument(context, reflection, node?); + private onBeginResolve(context); +} diff --git a/dist/lib/converter/plugins/PackagePlugin.js b/dist/lib/converter/plugins/PackagePlugin.js new file mode 100644 index 000000000..6e8bfada3 --- /dev/null +++ b/dist/lib/converter/plugins/PackagePlugin.js @@ -0,0 +1,102 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var FS = require("fs"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var component_1 = require("../../utils/component"); +var PackagePlugin = (function (_super) { + __extends(PackagePlugin, _super); + function PackagePlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + PackagePlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[converter_1.Converter.EVENT_BEGIN] = this.onBegin, + _a[converter_1.Converter.EVENT_FILE_BEGIN] = this.onBeginDocument, + _a[converter_1.Converter.EVENT_RESOLVE_BEGIN] = this.onBeginResolve, + _a)); + var _a; + }; + PackagePlugin.prototype.onBegin = function (context) { + this.readmeFile = null; + this.packageFile = null; + this.visited = []; + var readme = this.readme; + this.noReadmeFile = (readme === 'none'); + if (!this.noReadmeFile && readme) { + readme = Path.resolve(readme); + if (FS.existsSync(readme)) { + this.readmeFile = readme; + } + } + }; + PackagePlugin.prototype.onBeginDocument = function (context, reflection, node) { + var _this = this; + if (!node) { + return; + } + if (this.readmeFile && this.packageFile) { + return; + } + var fileName = node.fileName; + var dirName, parentDir = Path.resolve(Path.dirname(fileName)); + do { + dirName = parentDir; + if (this.visited.indexOf(dirName) !== -1) { + break; + } + FS.readdirSync(dirName).forEach(function (file) { + var lfile = file.toLowerCase(); + if (!_this.noReadmeFile && !_this.readmeFile && lfile === 'readme.md') { + _this.readmeFile = Path.join(dirName, file); + } + if (!_this.packageFile && lfile === 'package.json') { + _this.packageFile = Path.join(dirName, file); + } + }); + this.visited.push(dirName); + parentDir = Path.resolve(Path.join(dirName, '..')); + } while (dirName !== parentDir); + }; + PackagePlugin.prototype.onBeginResolve = function (context) { + var project = context.project; + if (this.readmeFile) { + project.readme = FS.readFileSync(this.readmeFile, 'utf-8'); + } + if (this.packageFile) { + project.packageInfo = JSON.parse(FS.readFileSync(this.packageFile, 'utf-8')); + if (!project.name) { + project.name = project.packageInfo.name; + } + } + }; + __decorate([ + component_1.Option({ + name: 'readme', + 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.' + }) + ], PackagePlugin.prototype, "readme", void 0); + PackagePlugin = __decorate([ + components_1.Component({ name: 'package' }) + ], PackagePlugin); + return PackagePlugin; +}(components_1.ConverterComponent)); +exports.PackagePlugin = PackagePlugin; +//# sourceMappingURL=PackagePlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/PackagePlugin.js.map b/dist/lib/converter/plugins/PackagePlugin.js.map new file mode 100644 index 000000000..2137d644e --- /dev/null +++ b/dist/lib/converter/plugins/PackagePlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PackagePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/PackagePlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAC7B,uBAAyB;AAIzB,4CAA8D;AAC9D,0CAAyC;AAEzC,mDAA+C;AAW/C;IAAmC,iCAAkB;IAArD;;IAmHA,CAAC;IArFG,kCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,qBAAS,CAAC,WAAW,IAAW,IAAI,CAAC,OAAO;YAC7C,GAAC,qBAAS,CAAC,gBAAgB,IAAM,IAAI,CA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AAW,EAAE,OAAO,CAAC,CAAC,CAAC;YAC7E,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;gBAChB,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;YAC5C,CAAC;QACL,CAAC;IACL,CAAC;IA7GD;QAJC,kBAAM,CAAC;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,4JAA4J;SACrK,CAAC;iDACa;IALN,aAAa;QADzB,sBAAS,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;OAChB,aAAa,CAmHzB;IAAD,oBAAC;CAAA,AAnHD,CAAmC,+BAAkB,GAmHpD;AAnHY,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 = null;\n this.packageFile = null;\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 if (!node) {\n return;\n }\n if (this.readmeFile && this.packageFile) {\n return;\n }\n\n const fileName = node.fileName;\n let dirName: string, parentDir = Path.resolve(Path.dirname(fileName));\n do {\n dirName = parentDir;\n if (this.visited.indexOf(dirName) !== -1) {\n break;\n }\n\n FS.readdirSync(dirName).forEach((file) => {\n const lfile = file.toLowerCase();\n if (!this.noReadmeFile && !this.readmeFile && lfile === 'readme.md') {\n this.readmeFile = Path.join(dirName, file);\n }\n\n if (!this.packageFile && lfile === 'package.json') {\n this.packageFile = Path.join(dirName, file);\n }\n });\n\n this.visited.push(dirName);\n parentDir = Path.resolve(Path.join(dirName, '..'));\n } while (dirName !== parentDir);\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"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/SourcePlugin.d.ts b/dist/lib/converter/plugins/SourcePlugin.d.ts new file mode 100644 index 000000000..6498953ce --- /dev/null +++ b/dist/lib/converter/plugins/SourcePlugin.d.ts @@ -0,0 +1,13 @@ +import { ConverterComponent } from '../components'; +export declare class SourcePlugin extends ConverterComponent { + private basePath; + private fileMappings; + initialize(): void; + private getSourceFile(fileName, project); + private onBegin(); + private onBeginDocument(context, reflection, node?); + private onDeclaration(context, reflection, node?); + private onBeginResolve(context); + private onResolve(context, reflection); + private onEndResolve(context); +} diff --git a/dist/lib/converter/plugins/SourcePlugin.js b/dist/lib/converter/plugins/SourcePlugin.js new file mode 100644 index 000000000..3d2c51b72 --- /dev/null +++ b/dist/lib/converter/plugins/SourcePlugin.js @@ -0,0 +1,139 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/reflections/index"); +var index_2 = require("../../models/sources/index"); +var components_1 = require("../components"); +var base_path_1 = require("../utils/base-path"); +var converter_1 = require("../converter"); +var SourcePlugin = (function (_super) { + __extends(SourcePlugin, _super); + function SourcePlugin() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.basePath = new base_path_1.BasePath(); + _this.fileMappings = {}; + return _this; + } + SourcePlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[converter_1.Converter.EVENT_BEGIN] = this.onBegin, + _a[converter_1.Converter.EVENT_FILE_BEGIN] = this.onBeginDocument, + _a[converter_1.Converter.EVENT_CREATE_DECLARATION] = this.onDeclaration, + _a[converter_1.Converter.EVENT_CREATE_SIGNATURE] = this.onDeclaration, + _a[converter_1.Converter.EVENT_RESOLVE_BEGIN] = this.onBeginResolve, + _a[converter_1.Converter.EVENT_RESOLVE] = this.onResolve, + _a[converter_1.Converter.EVENT_RESOLVE_END] = this.onEndResolve, + _a)); + var _a; + }; + SourcePlugin.prototype.getSourceFile = function (fileName, project) { + if (!this.fileMappings[fileName]) { + var file = new index_2.SourceFile(fileName); + this.fileMappings[fileName] = file; + project.files.push(file); + } + return this.fileMappings[fileName]; + }; + SourcePlugin.prototype.onBegin = function () { + this.basePath.reset(); + this.fileMappings = {}; + }; + SourcePlugin.prototype.onBeginDocument = function (context, reflection, node) { + if (!node) { + return; + } + var fileName = node.fileName; + this.basePath.add(fileName); + this.getSourceFile(fileName, context.project); + }; + SourcePlugin.prototype.onDeclaration = function (context, reflection, node) { + if (!node) { + return; + } + var sourceFile = _ts.getSourceFileOfNode(node); + var fileName = sourceFile.fileName; + var file = this.getSourceFile(fileName, context.project); + var position; + if (node['name'] && node['name'].end) { + position = ts.getLineAndCharacterOfPosition(sourceFile, node['name'].end); + } + else { + position = ts.getLineAndCharacterOfPosition(sourceFile, node.pos); + } + if (!reflection.sources) { + reflection.sources = []; + } + if (reflection instanceof index_1.DeclarationReflection) { + file.reflections.push(reflection); + } + reflection.sources.push({ + file: file, + fileName: fileName, + line: position.line + 1, + character: position.character + }); + }; + SourcePlugin.prototype.onBeginResolve = function (context) { + var _this = this; + context.project.files.forEach(function (file) { + var fileName = file.fileName = _this.basePath.trim(file.fileName); + _this.fileMappings[fileName] = file; + }); + }; + SourcePlugin.prototype.onResolve = function (context, reflection) { + var _this = this; + if (!reflection.sources) { + return; + } + reflection.sources.forEach(function (source) { + source.fileName = _this.basePath.trim(source.fileName); + }); + }; + SourcePlugin.prototype.onEndResolve = function (context) { + var project = context.project; + var home = project.directory; + project.files.forEach(function (file) { + var reflections = []; + file.reflections.forEach(function (reflection) { + reflections.push(reflection); + }); + var directory = home; + var path = Path.dirname(file.fileName); + if (path !== '.') { + path.split('/').forEach(function (pathPiece) { + if (!Object.prototype.hasOwnProperty.call(directory.directories, pathPiece)) { + directory.directories[pathPiece] = new index_2.SourceDirectory(pathPiece, directory); + } + directory = directory.directories[pathPiece]; + }); + } + directory.files.push(file); + file.parent = directory; + file.reflections = reflections; + }); + }; + SourcePlugin = __decorate([ + components_1.Component({ name: 'source' }) + ], SourcePlugin); + return SourcePlugin; +}(components_1.ConverterComponent)); +exports.SourcePlugin = SourcePlugin; +//# sourceMappingURL=SourcePlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/SourcePlugin.js.map b/dist/lib/converter/plugins/SourcePlugin.js.map new file mode 100644 index 000000000..3be74f9af --- /dev/null +++ b/dist/lib/converter/plugins/SourcePlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SourcePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/SourcePlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAC7B,+BAAiC;AACjC,uCAAyC;AAEzC,wDAAsG;AACtG,oDAAyE;AACzE,4CAA8D;AAC9D,gDAA8C;AAC9C,0CAAyC;AAOzC;IAAkC,gCAAkB;IADpD;QAAA,qEAkKC;QA7JW,cAAQ,GAAG,IAAI,oBAAQ,EAAE,CAAC;QAK1B,kBAAY,GAAiC,EAAE,CAAC;;IAwJ5D,CAAC;IAnJG,iCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,qBAAS,CAAC,WAAW,IAAgB,IAAI,CAAC,OAAO;YAClD,GAAC,qBAAS,CAAC,gBAAgB,IAAW,IAAI,CAAC,eAAe;Y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SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;wBAC1E,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI,uBAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;oBACjF,CAAC;oBACD,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBACjD,CAAC,CAAC,CAAC;YACP,CAAC;YAED,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE3B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;YACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC;IAhKQ,YAAY;QADxB,sBAAS,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;OACf,YAAY,CAiKxB;IAAD,mBAAC;CAAA,AAjKD,CAAkC,+BAAkB,GAiKnD;AAjKY,oCAAY","sourcesContent":["import * as Path from 'path';\nimport * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection, ProjectReflection, DeclarationReflection } from '../../models/reflections/index';\nimport { SourceDirectory, SourceFile } from '../../models/sources/index';\nimport { Component, ConverterComponent } from '../components';\nimport { BasePath } from '../utils/base-path';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A handler that attaches source file information to reflections.\n */\n@Component({name: 'source'})\nexport class SourcePlugin extends ConverterComponent {\n /**\n * Helper for resolving the base path of all source files.\n */\n private basePath = new BasePath();\n\n /**\n * A map of all generated [[SourceFile]] instances.\n */\n private fileMappings: {[name: string]: SourceFile} = {};\n\n /**\n * Create a new SourceHandler instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [Converter.EVENT_BEGIN]: this.onBegin,\n [Converter.EVENT_FILE_BEGIN]: this.onBeginDocument,\n [Converter.EVENT_CREATE_DECLARATION]: this.onDeclaration,\n [Converter.EVENT_CREATE_SIGNATURE]: this.onDeclaration,\n [Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,\n [Converter.EVENT_RESOLVE]: this.onResolve,\n [Converter.EVENT_RESOLVE_END]: this.onEndResolve\n });\n }\n\n private getSourceFile(fileName: string, project: ProjectReflection): SourceFile {\n if (!this.fileMappings[fileName]) {\n const file = new SourceFile(fileName);\n this.fileMappings[fileName] = file;\n project.files.push(file);\n }\n\n return this.fileMappings[fileName];\n }\n\n /**\n * Triggered once per project before the dispatcher invokes the compiler.\n *\n * @param event An event object containing the related project and compiler instance.\n */\n private onBegin() {\n this.basePath.reset();\n this.fileMappings = {};\n }\n\n /**\n * Triggered when the converter begins converting a source file.\n *\n * Create a new [[SourceFile]] instance for all TypeScript files.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onBeginDocument(context: Context, reflection: Reflection, node?: ts.SourceFile) {\n if (!node) {\n return;\n }\n const fileName = node.fileName;\n this.basePath.add(fileName);\n this.getSourceFile(fileName, context.project);\n }\n\n /**\n * Triggered when the converter has created a declaration reflection.\n *\n * Attach the current source file to the [[DeclarationReflection.sources]] array.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently processed.\n * @param node The node that is currently processed if available.\n */\n private onDeclaration(context: Context, reflection: Reflection, node?: ts.Node) {\n if (!node) {\n return;\n }\n const sourceFile = _ts.getSourceFileOfNode(node);\n const fileName = sourceFile.fileName;\n const file: SourceFile = this.getSourceFile(fileName, context.project);\n\n let position: ts.LineAndCharacter;\n if (node['name'] && node['name'].end) {\n position = ts.getLineAndCharacterOfPosition(sourceFile, node['name'].end);\n } else {\n position = ts.getLineAndCharacterOfPosition(sourceFile, node.pos);\n }\n\n if (!reflection.sources) {\n reflection.sources = [];\n }\n if (reflection instanceof DeclarationReflection) {\n file.reflections.push(reflection);\n }\n\n reflection.sources.push({\n file: file,\n fileName: fileName,\n line: position.line + 1,\n character: position.character\n });\n }\n\n /**\n * Triggered when the converter begins resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onBeginResolve(context: Context) {\n context.project.files.forEach((file) => {\n const fileName = file.fileName = this.basePath.trim(file.fileName);\n this.fileMappings[fileName] = file;\n });\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: Reflection) {\n if (!reflection.sources) {\n return;\n }\n reflection.sources.forEach((source) => {\n source.fileName = this.basePath.trim(source.fileName);\n });\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onEndResolve(context: Context) {\n const project = context.project;\n const home = project.directory;\n project.files.forEach((file) => {\n const reflections: Reflection[] = [];\n file.reflections.forEach((reflection) => {\n reflections.push(reflection);\n });\n\n let directory = home;\n const path = Path.dirname(file.fileName);\n if (path !== '.') {\n path.split('/').forEach((pathPiece) => {\n if (!Object.prototype.hasOwnProperty.call(directory.directories, pathPiece)) {\n directory.directories[pathPiece] = new SourceDirectory(pathPiece, directory);\n }\n directory = directory.directories[pathPiece];\n });\n }\n\n directory.files.push(file);\n // reflections.sort(GroupHandler.sortCallback);\n file.parent = directory;\n file.reflections = reflections;\n });\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/TypePlugin.d.ts b/dist/lib/converter/plugins/TypePlugin.d.ts new file mode 100644 index 000000000..b1bc6a72f --- /dev/null +++ b/dist/lib/converter/plugins/TypePlugin.d.ts @@ -0,0 +1,9 @@ +import { DeclarationReflection } from '../../models/reflections/index'; +import { ConverterComponent } from '../components'; +export declare class TypePlugin extends ConverterComponent { + reflections: DeclarationReflection[]; + initialize(): void; + private onResolve(context, reflection); + private postpone(reflection); + private onResolveEnd(context); +} diff --git a/dist/lib/converter/plugins/TypePlugin.js b/dist/lib/converter/plugins/TypePlugin.js new file mode 100644 index 000000000..6d4f6c23b --- /dev/null +++ b/dist/lib/converter/plugins/TypePlugin.js @@ -0,0 +1,168 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/reflections/index"); +var index_2 = require("../../models/types/index"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var TypePlugin = (function (_super) { + __extends(TypePlugin, _super); + function TypePlugin() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.reflections = []; + return _this; + } + TypePlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[converter_1.Converter.EVENT_RESOLVE] = this.onResolve, + _a[converter_1.Converter.EVENT_RESOLVE_END] = this.onResolveEnd, + _a)); + var _a; + }; + TypePlugin.prototype.onResolve = function (context, reflection) { + var _this = this; + var project = context.project; + resolveType(reflection, reflection.type); + resolveType(reflection, reflection.inheritedFrom); + resolveType(reflection, reflection.overwrites); + resolveTypes(reflection, reflection.extendedTypes); + resolveTypes(reflection, reflection.extendedBy); + resolveTypes(reflection, reflection.implementedTypes); + if (reflection.decorators) { + reflection.decorators.forEach(function (decorator) { + if (decorator.type) { + resolveType(reflection, decorator.type); + } + }); + } + if (reflection.kindOf(index_1.ReflectionKind.ClassOrInterface)) { + this.postpone(reflection); + walk(reflection.implementedTypes, function (target) { + _this.postpone(target); + if (!target.implementedBy) { + target.implementedBy = []; + } + target.implementedBy.push(new index_2.ReferenceType(reflection.name, index_2.ReferenceType.SYMBOL_ID_RESOLVED, reflection)); + }); + walk(reflection.extendedTypes, function (target) { + _this.postpone(target); + if (!target.extendedBy) { + target.extendedBy = []; + } + target.extendedBy.push(new index_2.ReferenceType(reflection.name, index_2.ReferenceType.SYMBOL_ID_RESOLVED, reflection)); + }); + } + function walk(types, callback) { + if (!types) { + return; + } + types.forEach(function (type) { + if (!(type instanceof index_2.ReferenceType)) { + return; + } + if (!type.reflection || !(type.reflection instanceof index_1.DeclarationReflection)) { + return; + } + callback(type.reflection); + }); + } + function resolveTypes(reflection, types) { + if (!types) { + return; + } + for (var i = 0, c = types.length; i < c; i++) { + resolveType(reflection, types[i]); + } + } + function resolveType(reflection, type) { + if (type instanceof index_2.ReferenceType) { + var referenceType = type; + if (referenceType.symbolID === index_2.ReferenceType.SYMBOL_ID_RESOLVE_BY_NAME) { + referenceType.reflection = reflection.findReflectionByName(referenceType.name); + } + else if (!referenceType.reflection && referenceType.symbolID !== index_2.ReferenceType.SYMBOL_ID_RESOLVED) { + referenceType.reflection = project.reflections[project.symbolMapping[referenceType.symbolID]]; + } + if (referenceType.typeArguments) { + referenceType.typeArguments.forEach(function (typeArgument) { + resolveType(reflection, typeArgument); + }); + } + } + else if (type instanceof index_2.TupleType) { + var tupleType = type; + for (var index = 0, count = tupleType.elements.length; index < count; index++) { + resolveType(reflection, tupleType.elements[index]); + } + } + else if (type instanceof index_2.UnionType || type instanceof index_2.IntersectionType) { + var unionOrIntersectionType = type; + for (var index = 0, count = unionOrIntersectionType.types.length; index < count; index++) { + resolveType(reflection, unionOrIntersectionType.types[index]); + } + } + else if (type instanceof index_2.ArrayType) { + resolveType(reflection, type.elementType); + } + } + }; + TypePlugin.prototype.postpone = function (reflection) { + if (this.reflections.indexOf(reflection) === -1) { + this.reflections.push(reflection); + } + }; + TypePlugin.prototype.onResolveEnd = function (context) { + this.reflections.forEach(function (reflection) { + if (reflection.implementedBy) { + reflection.implementedBy.sort(function (a, b) { + if (a['name'] === b['name']) { + return 0; + } + return a['name'] > b['name'] ? 1 : -1; + }); + } + var root; + var hierarchy; + function push(types) { + var level = { types: types }; + if (hierarchy) { + hierarchy.next = level; + hierarchy = level; + } + else { + root = hierarchy = level; + } + } + if (reflection.extendedTypes) { + push(reflection.extendedTypes); + } + push([new index_2.ReferenceType(reflection.name, index_2.ReferenceType.SYMBOL_ID_RESOLVED, reflection)]); + hierarchy.isTarget = true; + if (reflection.extendedBy) { + push(reflection.extendedBy); + } + reflection.typeHierarchy = root; + }); + }; + TypePlugin = __decorate([ + components_1.Component({ name: 'type' }) + ], TypePlugin); + return TypePlugin; +}(components_1.ConverterComponent)); +exports.TypePlugin = TypePlugin; +//# sourceMappingURL=TypePlugin.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/TypePlugin.js.map b/dist/lib/converter/plugins/TypePlugin.js.map new file mode 100644 index 000000000..d66917568 --- /dev/null +++ b/dist/lib/converter/plugins/TypePlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TypePlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/TypePlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,wDAAoI;AACpI,kDAAkH;AAClH,4CAA8D;AAC9D,0CAAyC;AAOzC;IAAgC,8BAAkB;IADlD;QAAA,qEAgKC;QA9JG,iBAAW,GAA4B,EAAE,CAAC;;IA8J9C,CAAC;IAzJG,+BAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,qBAAS,CAAC,aAAa,IAAO,IAAI,CAAC,SAAS;YAC7C,GAAC,qBAAS,CAAC,iBAAiB,IAAG,IAAI,CAAC,YAAY;gBAClD,CAAC;;IACP,CAAC;IAQO,8BAAS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C,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1C,CAAC,CAAC,CAAC;YACP,CAAC;YAED,IAAI,IAA0B,CAAC;YAC/B,IAAI,SAA+B,CAAC;YACpC,cAAc,KAAa;gBACvB,IAAM,KAAK,GAAyB,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC;gBACnD,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;oBACZ,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC;oBACvB,SAAS,GAAG,KAAK,CAAC;gBACtB,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACJ,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC;gBAC7B,CAAC;YACL,CAAC;YAED,EAAE,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACnC,CAAC;YAED,IAAI,CAAC,CAAC,IAAI,qBAAa,CAAC,UAAU,CAAC,IAAI,EAAE,qBAAa,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YACzF,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;YAE1B,EAAE,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;gBACxB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAChC,CAAC;YAED,UAAU,CAAC,aAAa,GAAG,IAAI,CAAC;QACpC,CAAC,CAAC,CAAC;IACP,CAAC;IA9JQ,UAAU;QADtB,sBAAS,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;OACb,UAAU,CA+JtB;IAAD,iBAAC;CAAA,AA/JD,CAAgC,+BAAkB,GA+JjD;AA/JY,gCAAU","sourcesContent":["import { Reflection, ReflectionKind, Decorator, DeclarationReflection, DeclarationHierarchy } from '../../models/reflections/index';\nimport { Type, ReferenceType, TupleType, UnionType, IntersectionType, ArrayType } from '../../models/types/index';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A handler that converts all instances of [[LateResolvingType]] to their renderable equivalents.\n */\n@Component({name: 'type'})\nexport class TypePlugin extends ConverterComponent {\n reflections: DeclarationReflection[] = [];\n\n /**\n * Create a new TypeHandler instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [Converter.EVENT_RESOLVE]: this.onResolve,\n [Converter.EVENT_RESOLVE_END]: this.onResolveEnd\n });\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: DeclarationReflection) {\n const project = context.project;\n\n resolveType(reflection, reflection.type);\n resolveType(reflection, reflection.inheritedFrom);\n resolveType(reflection, reflection.overwrites);\n resolveTypes(reflection, reflection.extendedTypes);\n resolveTypes(reflection, reflection.extendedBy);\n resolveTypes(reflection, reflection.implementedTypes);\n\n if (reflection.decorators) {\n reflection.decorators.forEach((decorator: Decorator) => {\n if (decorator.type) {\n resolveType(reflection, decorator.type);\n }\n });\n }\n\n if (reflection.kindOf(ReflectionKind.ClassOrInterface)) {\n this.postpone(reflection);\n\n walk(reflection.implementedTypes, (target) => {\n this.postpone(target);\n if (!target.implementedBy) {\n target.implementedBy = [];\n }\n target.implementedBy.push(new ReferenceType(reflection.name, ReferenceType.SYMBOL_ID_RESOLVED, reflection));\n });\n\n walk(reflection.extendedTypes, (target) => {\n this.postpone(target);\n if (!target.extendedBy) {\n target.extendedBy = [];\n }\n target.extendedBy.push(new ReferenceType(reflection.name, ReferenceType.SYMBOL_ID_RESOLVED, reflection));\n });\n }\n\n function walk(types: Type[], callback: {(declaration: DeclarationReflection): void}) {\n if (!types) {\n return;\n }\n types.forEach((type: ReferenceType) => {\n if (!(type instanceof ReferenceType)) {\n return;\n }\n if (!type.reflection || !(type.reflection instanceof DeclarationReflection)) {\n return;\n }\n callback( type.reflection);\n });\n }\n\n function resolveTypes(reflection: Reflection, types: Type[]) {\n if (!types) {\n return;\n }\n for (let i = 0, c = types.length; i < c; i++) {\n resolveType(reflection, types[i]);\n }\n }\n\n function resolveType(reflection: Reflection, type: Type) {\n if (type instanceof ReferenceType) {\n const referenceType: ReferenceType = type;\n if (referenceType.symbolID === ReferenceType.SYMBOL_ID_RESOLVE_BY_NAME) {\n referenceType.reflection = reflection.findReflectionByName(referenceType.name);\n } else if (!referenceType.reflection && referenceType.symbolID !== ReferenceType.SYMBOL_ID_RESOLVED) {\n referenceType.reflection = project.reflections[project.symbolMapping[referenceType.symbolID]];\n }\n\n if (referenceType.typeArguments) {\n referenceType.typeArguments.forEach((typeArgument: Type) => {\n resolveType(reflection, typeArgument);\n });\n }\n } else if (type instanceof TupleType) {\n const tupleType: TupleType = type;\n for (let index = 0, count = tupleType.elements.length; index < count; index++) {\n resolveType(reflection, tupleType.elements[index]);\n }\n } else if (type instanceof UnionType || type instanceof IntersectionType) {\n const unionOrIntersectionType: UnionType | IntersectionType = type;\n for (let index = 0, count = unionOrIntersectionType.types.length; index < count; index++) {\n resolveType(reflection, unionOrIntersectionType.types[index]);\n }\n } else if (type instanceof ArrayType) {\n resolveType(reflection, type.elementType);\n }\n }\n }\n\n private postpone(reflection: DeclarationReflection) {\n if (this.reflections.indexOf(reflection) === -1) {\n this.reflections.push(reflection);\n }\n }\n\n /**\n * Triggered when the converter has finished resolving a project.\n *\n * @param context The context object describing the current state the converter is in.\n */\n private onResolveEnd(context: Context) {\n this.reflections.forEach((reflection) => {\n if (reflection.implementedBy) {\n reflection.implementedBy.sort((a: Type, b: Type): number => {\n if (a['name'] === b['name']) {\n return 0;\n }\n return a['name'] > b['name'] ? 1 : -1;\n });\n }\n\n let root: DeclarationHierarchy;\n let hierarchy: DeclarationHierarchy;\n function push(types: Type[]) {\n const level: DeclarationHierarchy = {types: types};\n if (hierarchy) {\n hierarchy.next = level;\n hierarchy = level;\n } else {\n root = hierarchy = level;\n }\n }\n\n if (reflection.extendedTypes) {\n push(reflection.extendedTypes);\n }\n\n push([new ReferenceType(reflection.name, ReferenceType.SYMBOL_ID_RESOLVED, reflection)]);\n hierarchy.isTarget = true;\n\n if (reflection.extendedBy) {\n push(reflection.extendedBy);\n }\n\n reflection.typeHierarchy = root;\n });\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/plugins/index.d.ts b/dist/lib/converter/plugins/index.d.ts new file mode 100644 index 000000000..4642ac8f9 --- /dev/null +++ b/dist/lib/converter/plugins/index.d.ts @@ -0,0 +1,11 @@ +export { CategoryPlugin } from './CategoryPlugin'; +export { CommentPlugin } from './CommentPlugin'; +export { DecoratorPlugin } from './DecoratorPlugin'; +export { DeepCommentPlugin } from './DeepCommentPlugin'; +export { DynamicModulePlugin } from './DynamicModulePlugin'; +export { GitHubPlugin } from './GitHubPlugin'; +export { GroupPlugin } from './GroupPlugin'; +export { ImplementsPlugin } from './ImplementsPlugin'; +export { PackagePlugin } from './PackagePlugin'; +export { SourcePlugin } from './SourcePlugin'; +export { TypePlugin } from './TypePlugin'; diff --git a/dist/lib/converter/plugins/index.js b/dist/lib/converter/plugins/index.js new file mode 100644 index 000000000..b45588531 --- /dev/null +++ b/dist/lib/converter/plugins/index.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var CategoryPlugin_1 = require("./CategoryPlugin"); +exports.CategoryPlugin = CategoryPlugin_1.CategoryPlugin; +var CommentPlugin_1 = require("./CommentPlugin"); +exports.CommentPlugin = CommentPlugin_1.CommentPlugin; +var DecoratorPlugin_1 = require("./DecoratorPlugin"); +exports.DecoratorPlugin = DecoratorPlugin_1.DecoratorPlugin; +var DeepCommentPlugin_1 = require("./DeepCommentPlugin"); +exports.DeepCommentPlugin = DeepCommentPlugin_1.DeepCommentPlugin; +var DynamicModulePlugin_1 = require("./DynamicModulePlugin"); +exports.DynamicModulePlugin = DynamicModulePlugin_1.DynamicModulePlugin; +var GitHubPlugin_1 = require("./GitHubPlugin"); +exports.GitHubPlugin = GitHubPlugin_1.GitHubPlugin; +var GroupPlugin_1 = require("./GroupPlugin"); +exports.GroupPlugin = GroupPlugin_1.GroupPlugin; +var ImplementsPlugin_1 = require("./ImplementsPlugin"); +exports.ImplementsPlugin = ImplementsPlugin_1.ImplementsPlugin; +var PackagePlugin_1 = require("./PackagePlugin"); +exports.PackagePlugin = PackagePlugin_1.PackagePlugin; +var SourcePlugin_1 = require("./SourcePlugin"); +exports.SourcePlugin = SourcePlugin_1.SourcePlugin; +var TypePlugin_1 = require("./TypePlugin"); +exports.TypePlugin = TypePlugin_1.TypePlugin; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/converter/plugins/index.js.map b/dist/lib/converter/plugins/index.js.map new file mode 100644 index 000000000..592974ba4 --- /dev/null +++ b/dist/lib/converter/plugins/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/index.ts"],"names":[],"mappings":";;AAAA,mDAAkD;AAAzC,0CAAA,cAAc,CAAA;AACvB,iDAAgD;AAAvC,wCAAA,aAAa,CAAA;AACtB,qDAAoD;AAA3C,4CAAA,eAAe,CAAA;AACxB,yDAAwD;AAA/C,gDAAA,iBAAiB,CAAA;AAC1B,6DAA4D;AAAnD,oDAAA,mBAAmB,CAAA;AAC5B,+CAA8C;AAArC,sCAAA,YAAY,CAAA;AACrB,6CAA4C;AAAnC,oCAAA,WAAW,CAAA;AACpB,uDAAsD;AAA7C,8CAAA,gBAAgB,CAAA;AACzB,iDAAgD;AAAvC,wCAAA,aAAa,CAAA;AACtB,+CAA8C;AAArC,sCAAA,YAAY,CAAA;AACrB,2CAA0C;AAAjC,kCAAA,UAAU,CAAA","sourcesContent":["export { CategoryPlugin } from './CategoryPlugin';\nexport { CommentPlugin } from './CommentPlugin';\nexport { DecoratorPlugin } from './DecoratorPlugin';\nexport { DeepCommentPlugin } from './DeepCommentPlugin';\nexport { DynamicModulePlugin } from './DynamicModulePlugin';\nexport { GitHubPlugin } from './GitHubPlugin';\nexport { GroupPlugin } from './GroupPlugin';\nexport { ImplementsPlugin } from './ImplementsPlugin';\nexport { PackagePlugin } from './PackagePlugin';\nexport { SourcePlugin } from './SourcePlugin';\nexport { TypePlugin } from './TypePlugin';\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/alias.d.ts b/dist/lib/converter/types/alias.d.ts new file mode 100644 index 000000000..7c1604bd6 --- /dev/null +++ b/dist/lib/converter/types/alias.d.ts @@ -0,0 +1,9 @@ +import * as ts from 'typescript'; +import { ReferenceType } from '../../models/index'; +import { ConverterTypeComponent, TypeNodeConverter } from '../components'; +import { Context } from '../context'; +export declare class AliasConverter extends ConverterTypeComponent implements TypeNodeConverter { + priority: number; + supportsNode(context: Context, node: ts.TypeReferenceNode, type: ts.Type): boolean; + convertNode(context: Context, node: ts.TypeReferenceNode): ReferenceType; +} diff --git a/dist/lib/converter/types/alias.js b/dist/lib/converter/types/alias.js new file mode 100644 index 000000000..8b1229ab0 --- /dev/null +++ b/dist/lib/converter/types/alias.js @@ -0,0 +1,68 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/index"); +var components_1 = require("../components"); +var AliasConverter = (function (_super) { + __extends(AliasConverter, _super); + function AliasConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.priority = 100; + return _this; + } + AliasConverter.prototype.supportsNode = function (context, node, type) { + if (!type || !node || !node.typeName) { + return false; + } + if (!type.symbol) { + return true; + } + var checker = context.checker; + var symbolName = checker.getFullyQualifiedName(type.symbol).split('.'); + if (!symbolName.length) { + return false; + } + if (symbolName[0].substr(0, 1) === '"') { + symbolName.shift(); + } + var nodeName = _ts.getTextOfNode(node.typeName).split('.'); + if (!nodeName.length) { + return false; + } + var common = Math.min(symbolName.length, nodeName.length); + symbolName = symbolName.slice(-common); + nodeName = nodeName.slice(-common); + return nodeName.join('.') !== symbolName.join('.'); + }; + AliasConverter.prototype.convertNode = function (context, node) { + var _this = this; + var name = _ts.getTextOfNode(node.typeName); + var result = new index_1.ReferenceType(name, index_1.ReferenceType.SYMBOL_ID_RESOLVE_BY_NAME); + if (node.typeArguments) { + result.typeArguments = node.typeArguments.map(function (n) { return _this.owner.convertType(context, n); }); + } + return result; + }; + AliasConverter = __decorate([ + components_1.Component({ name: 'type:alias' }) + ], AliasConverter); + return AliasConverter; +}(components_1.ConverterTypeComponent)); +exports.AliasConverter = AliasConverter; +//# sourceMappingURL=alias.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/alias.js.map b/dist/lib/converter/types/alias.js.map new file mode 100644 index 000000000..d8cba0d55 --- /dev/null +++ b/dist/lib/converter/types/alias.js.map @@ -0,0 +1 @@ +{"version":3,"file":"alias.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/alias.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,uCAAyC;AAEzC,4CAAmD;AACnD,4CAAqF;AAIrF;IAAoC,kCAAsB;IAD1D;QAAA,qEA2EC;QArEG,cAAQ,GAAG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QAEnC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IAkBD,oCAAW,GAAX,UAAY,OAAgB,EAAE,IAA0B;QAAxD,iBASC;QARG,IAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAM,MAAM,GAAG,IAAI,qBAAa,CAAC,IAAI,EAAE,qBAAa,CAAC,yBAAyB,CAAC,CAAC;QAEhF,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YACrB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC,EAAlC,CAAkC,CAAC,CAAC;QAC3F,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAzEQ,cAAc;QAD1B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,cAAc,CA0E1B;IAAD,qBAAC;CAAA,AA1ED,CAAoC,mCAAsB,GA0EzD;AA1EY,wCAAc","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { ReferenceType } from '../../models/index';\nimport { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:alias'})\nexport class AliasConverter extends ConverterTypeComponent implements TypeNodeConverter {\n /**\n * The priority this converter should be executed with.\n * A higher priority means the converter will be applied earlier.\n */\n priority = 100;\n\n /**\n * Test whether the given node and type definitions represent a type alias.\n *\n * The compiler resolves type aliases pretty early and there is no field telling us\n * whether the given node was a type alias or not. So we have to compare the type name of the\n * node with the type name of the type symbol.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The node that should be tested.\n * @param type The type of the node that should be tested.\n * @returns TRUE when the given node and type look like a type alias, otherwise FALSE.\n */\n supportsNode(context: Context, node: ts.TypeReferenceNode, type: ts.Type): boolean {\n if (!type || !node || !node.typeName) {\n return false;\n }\n if (!type.symbol) {\n return true;\n }\n\n const checker = context.checker;\n let symbolName = checker.getFullyQualifiedName(type.symbol).split('.');\n if (!symbolName.length) {\n return false;\n }\n if (symbolName[0].substr(0, 1) === '\"') {\n symbolName.shift();\n }\n\n let nodeName = _ts.getTextOfNode(node.typeName).split('.');\n if (!nodeName.length) {\n return false;\n }\n\n let common = Math.min(symbolName.length, nodeName.length);\n symbolName = symbolName.slice(-common);\n nodeName = nodeName.slice(-common);\n\n return nodeName.join('.') !== symbolName.join('.');\n }\n\n /**\n * Create a reflection for the given type alias node.\n *\n * This is a node based converter with no type equivalent.\n *\n * Use [[isTypeAlias]] beforehand to test whether a given type/node combination is\n * pointing to a type alias.\n *\n * ```\n * type MyNumber = number;\n * let someValue: MyNumber;\n * ```\n *\n * @param node The node whose type should be reflected.\n * @returns A type reference pointing to the type alias definition.\n */\n convertNode(context: Context, node: ts.TypeReferenceNode): ReferenceType {\n const name = _ts.getTextOfNode(node.typeName);\n const result = new ReferenceType(name, ReferenceType.SYMBOL_ID_RESOLVE_BY_NAME);\n\n if (node.typeArguments) {\n result.typeArguments = node.typeArguments.map(n => this.owner.convertType(context, n));\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/array.d.ts b/dist/lib/converter/types/array.d.ts new file mode 100644 index 000000000..d8bfbd8a7 --- /dev/null +++ b/dist/lib/converter/types/array.d.ts @@ -0,0 +1,10 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/index'; +import { ConverterTypeComponent, TypeConverter } from '../components'; +import { Context } from '../context'; +export declare class ArrayConverter extends ConverterTypeComponent implements TypeConverter { + supportsNode(context: Context, node: ts.ArrayTypeNode): boolean; + supportsType(context: Context, type: ts.TypeReference): boolean; + convertNode(context: Context, node: ts.ArrayTypeNode): Type; + convertType(context: Context, type: ts.TypeReference): Type; +} diff --git a/dist/lib/converter/types/array.js b/dist/lib/converter/types/array.js new file mode 100644 index 000000000..a61eeddfe --- /dev/null +++ b/dist/lib/converter/types/array.js @@ -0,0 +1,52 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var components_1 = require("../components"); +var ArrayConverter = (function (_super) { + __extends(ArrayConverter, _super); + function ArrayConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + ArrayConverter.prototype.supportsNode = function (context, node) { + return node.kind === ts.SyntaxKind.ArrayType; + }; + ArrayConverter.prototype.supportsType = function (context, type) { + return !!(type.flags & ts.TypeFlags.Object) + && !!type.symbol + && type.symbol.name === 'Array' + && !type.symbol.parent + && !!type.typeArguments + && type.typeArguments.length === 1; + }; + ArrayConverter.prototype.convertNode = function (context, node) { + var result = this.owner.convertType(context, node.elementType); + return new index_1.ArrayType(result); + }; + ArrayConverter.prototype.convertType = function (context, type) { + var result = this.owner.convertType(context, null, type.typeArguments[0]); + return new index_1.ArrayType(result); + }; + ArrayConverter = __decorate([ + components_1.Component({ name: 'type:array' }) + ], ArrayConverter); + return ArrayConverter; +}(components_1.ConverterTypeComponent)); +exports.ArrayConverter = ArrayConverter; +//# sourceMappingURL=array.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/array.js.map b/dist/lib/converter/types/array.js.map new file mode 100644 index 000000000..d3b768c4c --- /dev/null +++ b/dist/lib/converter/types/array.js.map @@ -0,0 +1 @@ +{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/array.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAqD;AACrD,4CAAiF;AAIjF;IAAoC,kCAAsB;IAA1D;;IA2DA,CAAC;IAvDG,qCAAY,GAAZ,UAAa,OAAgB,EAAE,IAAsB;QACjD,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;IACjD,CAAC;IAKD,qCAAY,GAAZ,UAAa,OAAgB,EAAE,IAAsB;QAEjD,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC;eACtC,CAAC,CAAC,IAAI,CAAC,MAAM;eACb,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO;eAC5B,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;eACnB,CAAC,CAAC,IAAI,CAAC,aAAa;eACpB,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;IACzC,CAAC;IAeD,oCAAW,GAAX,UAAY,OAAgB,EAAE,IAAsB;QAChD,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAEjE,MAAM,CAAC,IAAI,iBAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAgBD,oCAAW,GAAX,UAAY,OAAgB,EAAE,IAAsB;QAChD,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5E,MAAM,CAAC,IAAI,iBAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IA1DQ,cAAc;QAD1B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,cAAc,CA2D1B;IAAD,qBAAC;CAAA,AA3DD,CAAoC,mCAAsB,GA2DzD;AA3DY,wCAAc","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, ArrayType } from '../../models/index';\nimport { Component, ConverterTypeComponent, TypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:array'})\nexport class ArrayConverter extends ConverterTypeComponent implements TypeConverter {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.ArrayTypeNode): boolean {\n return node.kind === ts.SyntaxKind.ArrayType;\n }\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.TypeReference): boolean {\n // Is there a better way to detect the {\"type\":\"reference\",\"name\":\"Array\",\"typeArguments\":{...}} types that are in fact arrays?\n return !!(type.flags & ts.TypeFlags.Object)\n && !!type.symbol\n && type.symbol.name === 'Array'\n && !type.symbol.parent\n && !!type.typeArguments\n && type.typeArguments.length === 1;\n }\n\n /**\n * Convert the given array type node to its type reflection.\n *\n * This is a node based converter with no type equivalent.\n *\n * ```\n * let someValue: number[];\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The array type node that should be converted.\n * @returns The type reflection representing the given array type node.\n */\n convertNode(context: Context, node: ts.ArrayTypeNode): Type {\n const result = this.owner.convertType(context, node.elementType);\n\n return new ArrayType(result);\n }\n\n /**\n * Convert the given type reference to its type reflection.\n *\n * This is a type based converter, see [[convertTypeReference]] for the node equivalent.\n *\n * ```\n * class SomeClass { }\n * let someValue: SomeClass;\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The type reference that should be converted.\n * @returns The type reflection representing the given type reference.\n */\n convertType(context: Context, type: ts.TypeReference): Type {\n const result = this.owner.convertType(context, null, type.typeArguments[0]);\n\n return new ArrayType(result);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/binding-array.d.ts b/dist/lib/converter/types/binding-array.d.ts new file mode 100644 index 000000000..8f90814f8 --- /dev/null +++ b/dist/lib/converter/types/binding-array.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/index'; +import { ConverterTypeComponent, TypeNodeConverter } from '../components'; +import { Context } from '../context'; +export declare class BindingArrayConverter extends ConverterTypeComponent implements TypeNodeConverter { + supportsNode(context: Context, node: ts.BindingPattern): boolean; + convertNode(context: Context, node: ts.BindingPattern): Type; +} diff --git a/dist/lib/converter/types/binding-array.js b/dist/lib/converter/types/binding-array.js new file mode 100644 index 000000000..a01064676 --- /dev/null +++ b/dist/lib/converter/types/binding-array.js @@ -0,0 +1,44 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var components_1 = require("../components"); +var BindingArrayConverter = (function (_super) { + __extends(BindingArrayConverter, _super); + function BindingArrayConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + BindingArrayConverter.prototype.supportsNode = function (context, node) { + return node.kind === ts.SyntaxKind.ArrayBindingPattern; + }; + BindingArrayConverter.prototype.convertNode = function (context, node) { + var _this = this; + var types = []; + node.elements.forEach(function (element) { + types.push(_this.owner.convertType(context, element)); + }); + return new index_1.TupleType(types); + }; + BindingArrayConverter = __decorate([ + components_1.Component({ name: 'type:binding-array' }) + ], BindingArrayConverter); + return BindingArrayConverter; +}(components_1.ConverterTypeComponent)); +exports.BindingArrayConverter = BindingArrayConverter; +//# sourceMappingURL=binding-array.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/binding-array.js.map b/dist/lib/converter/types/binding-array.js.map new file mode 100644 index 000000000..2ad04bdb9 --- /dev/null +++ b/dist/lib/converter/types/binding-array.js.map @@ -0,0 +1 @@ +{"version":3,"file":"binding-array.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/binding-array.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAqD;AACrD,4CAAqF;AAIrF;IAA2C,yCAAsB;IAAjE;;IAwBA,CAAC;IApBG,4CAAY,GAAZ,UAAa,OAAgB,EAAE,IAAuB;QAClD,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC;IAC3D,CAAC;IASD,2CAAW,GAAX,UAAY,OAAgB,EAAE,IAAuB;QAArD,iBAQC;QAPG,IAAM,KAAK,GAAW,EAAE,CAAC;QAExB,IAAI,CAAC,QAA4C,CAAC,OAAO,CAAC,UAAC,OAAO;YAC/D,KAAK,CAAC,IAAI,CAAC,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,iBAAS,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAvBQ,qBAAqB;QADjC,sBAAS,CAAC,EAAC,IAAI,EAAE,oBAAoB,EAAC,CAAC;OAC3B,qBAAqB,CAwBjC;IAAD,4BAAC;CAAA,AAxBD,CAA2C,mCAAsB,GAwBhE;AAxBY,sDAAqB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, TupleType } from '../../models/index';\nimport { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:binding-array'})\nexport class BindingArrayConverter extends ConverterTypeComponent implements TypeNodeConverter {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.BindingPattern): boolean {\n return node.kind === ts.SyntaxKind.ArrayBindingPattern;\n }\n\n /**\n * Convert the given binding pattern to its type reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The binding pattern that should be converted.\n * @returns The type reflection representing the given binding pattern.\n */\n convertNode(context: Context, node: ts.BindingPattern): Type {\n const types: Type[] = [];\n\n (node.elements as ts.NodeArray).forEach((element) => {\n types.push(this.owner.convertType(context, element));\n });\n\n return new TupleType(types);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/binding-object.d.ts b/dist/lib/converter/types/binding-object.d.ts new file mode 100644 index 000000000..d9c638307 --- /dev/null +++ b/dist/lib/converter/types/binding-object.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/index'; +import { ConverterTypeComponent, TypeNodeConverter } from '../components'; +import { Context } from '../context'; +export declare class BindingObjectConverter extends ConverterTypeComponent implements TypeNodeConverter { + supportsNode(context: Context, node: ts.BindingPattern): boolean; + convertNode(context: Context, node: ts.BindingPattern): Type; +} diff --git a/dist/lib/converter/types/binding-object.js b/dist/lib/converter/types/binding-object.js new file mode 100644 index 000000000..aa6dcbd09 --- /dev/null +++ b/dist/lib/converter/types/binding-object.js @@ -0,0 +1,52 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var BindingObjectConverter = (function (_super) { + __extends(BindingObjectConverter, _super); + function BindingObjectConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + BindingObjectConverter.prototype.supportsNode = function (context, node) { + return node.kind === ts.SyntaxKind.ObjectBindingPattern; + }; + BindingObjectConverter.prototype.convertNode = function (context, node) { + var _this = this; + var declaration = new index_1.DeclarationReflection(); + declaration.kind = index_1.ReflectionKind.TypeLiteral; + declaration.name = '__type'; + declaration.parent = context.scope; + context.registerReflection(declaration, null); + context.trigger(converter_1.Converter.EVENT_CREATE_DECLARATION, declaration, node); + context.withScope(declaration, function () { + node.elements.forEach(function (element) { + _this.owner.convertNode(context, element); + }); + }); + return new index_1.ReflectionType(declaration); + }; + BindingObjectConverter = __decorate([ + components_1.Component({ name: 'type:binding-object' }) + ], BindingObjectConverter); + return BindingObjectConverter; +}(components_1.ConverterTypeComponent)); +exports.BindingObjectConverter = BindingObjectConverter; +//# sourceMappingURL=binding-object.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/binding-object.js.map b/dist/lib/converter/types/binding-object.js.map new file mode 100644 index 000000000..d916ba660 --- /dev/null +++ b/dist/lib/converter/types/binding-object.js.map @@ -0,0 +1 @@ +{"version":3,"file":"binding-object.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/binding-object.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAiG;AACjG,4CAAqF;AAErF,0CAAyC;AAGzC;IAA4C,0CAAsB;IAAlE;;IA+BA,CAAC;IA3BG,6CAAY,GAAZ,UAAa,OAAgB,EAAE,IAAuB;QAClD,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC;IAC5D,CAAC;IASD,4CAAW,GAAX,UAAY,OAAgB,EAAE,IAAuB;QAArD,iBAeC;QAdG,IAAM,WAAW,GAAG,IAAI,6BAAqB,EAAE,CAAC;QAChD,WAAW,CAAC,IAAI,GAAG,sBAAc,CAAC,WAAW,CAAC;QAC9C,WAAW,CAAC,IAAI,GAAG,QAAQ,CAAC;QAC5B,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAEnC,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,OAAO,CAAC,qBAAS,CAAC,wBAAwB,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QACvE,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE;YAC1B,IAAI,CAAC,QAA4C,CAAC,OAAO,CAAC,UAAC,OAAO;gBAC/D,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,sBAAc,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IA9BQ,sBAAsB;QADlC,sBAAS,CAAC,EAAC,IAAI,EAAE,qBAAqB,EAAC,CAAC;OAC5B,sBAAsB,CA+BlC;IAAD,6BAAC;CAAA,AA/BD,CAA4C,mCAAsB,GA+BjE;AA/BY,wDAAsB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, ReflectionKind, DeclarationReflection, ReflectionType } from '../../models/index';\nimport { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\n\n@Component({name: 'type:binding-object'})\nexport class BindingObjectConverter extends ConverterTypeComponent implements TypeNodeConverter {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.BindingPattern): boolean {\n return node.kind === ts.SyntaxKind.ObjectBindingPattern;\n }\n\n /**\n * Convert the given binding pattern to its type reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The binding pattern that should be converted.\n * @returns The type reflection representing the given binding pattern.\n */\n convertNode(context: Context, node: ts.BindingPattern): Type {\n const declaration = new DeclarationReflection();\n declaration.kind = ReflectionKind.TypeLiteral;\n declaration.name = '__type';\n declaration.parent = context.scope;\n\n context.registerReflection(declaration, null);\n context.trigger(Converter.EVENT_CREATE_DECLARATION, declaration, node);\n context.withScope(declaration, () => {\n (node.elements as ts.NodeArray).forEach((element) => {\n this.owner.convertNode(context, element);\n });\n });\n\n return new ReflectionType(declaration);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/enum.d.ts b/dist/lib/converter/types/enum.d.ts new file mode 100644 index 000000000..f1816210e --- /dev/null +++ b/dist/lib/converter/types/enum.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/index'; +import { ConverterTypeComponent, TypeTypeConverter } from '../components'; +import { Context } from '../context'; +export declare class EnumConverter extends ConverterTypeComponent implements TypeTypeConverter { + supportsType(context: Context, type: ts.Type): boolean; + convertType(context: Context, type: ts.Type): Type; +} diff --git a/dist/lib/converter/types/enum.js b/dist/lib/converter/types/enum.js new file mode 100644 index 000000000..de8ad1bd5 --- /dev/null +++ b/dist/lib/converter/types/enum.js @@ -0,0 +1,39 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../factories/index"); +var components_1 = require("../components"); +var EnumConverter = (function (_super) { + __extends(EnumConverter, _super); + function EnumConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + EnumConverter.prototype.supportsType = function (context, type) { + return !!(type.flags & ts.TypeFlags.EnumLike); + }; + EnumConverter.prototype.convertType = function (context, type) { + return index_1.createReferenceType(context, type.symbol); + }; + EnumConverter = __decorate([ + components_1.Component({ name: 'type:enum' }) + ], EnumConverter); + return EnumConverter; +}(components_1.ConverterTypeComponent)); +exports.EnumConverter = EnumConverter; +//# sourceMappingURL=enum.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/enum.js.map b/dist/lib/converter/types/enum.js.map new file mode 100644 index 000000000..2ef19ff22 --- /dev/null +++ b/dist/lib/converter/types/enum.js.map @@ -0,0 +1 @@ +{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/enum.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAGjC,4CAAyD;AACzD,4CAAqF;AAIrF;IAAmC,iCAAsB;IAAzD;;IAyBA,CAAC;IArBG,oCAAY,GAAZ,UAAa,OAAgB,EAAE,IAAa;QACxC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IAgBD,mCAAW,GAAX,UAAY,OAAgB,EAAE,IAAa;QACvC,MAAM,CAAC,2BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAxBQ,aAAa;QADzB,sBAAS,CAAC,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC;OAClB,aAAa,CAyBzB;IAAD,oBAAC;CAAA,AAzBD,CAAmC,mCAAsB,GAyBxD;AAzBY,sCAAa","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type } from '../../models/index';\nimport { createReferenceType } from '../factories/index';\nimport { Component, ConverterTypeComponent, TypeTypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:enum'})\nexport class EnumConverter extends ConverterTypeComponent implements TypeTypeConverter {\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.Type): boolean {\n return !!(type.flags & ts.TypeFlags.EnumLike);\n }\n\n /**\n * Convert the given enumeration type to its type reflection.\n *\n * This is a type based converter with no node based equivalent.\n *\n * ```\n * enum MyEnum { One, Two, Three }\n * let someValue: MyEnum;\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The enumeration type that should be converted.\n * @returns The type reflection representing the given enumeration type.\n */\n convertType(context: Context, type: ts.Type): Type {\n return createReferenceType(context, type.symbol);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/index.d.ts b/dist/lib/converter/types/index.d.ts new file mode 100644 index 000000000..599bede9c --- /dev/null +++ b/dist/lib/converter/types/index.d.ts @@ -0,0 +1,14 @@ +export { AliasConverter } from './alias'; +export { ArrayConverter } from './array'; +export { BindingArrayConverter } from './binding-array'; +export { BindingObjectConverter } from './binding-object'; +export { EnumConverter } from './enum'; +export { IntrinsicConverter } from './intrinsic'; +export { StringLiteralConverter } from './string-literal'; +export { ReferenceConverter } from './reference'; +export { ThisConverter } from './this'; +export { TupleConverter } from './tuple'; +export { TypeParameterConverter } from './type-parameter'; +export { TypeOperatorConverter } from './type-operator'; +export { UnionOrIntersectionConverter } from './union-or-intersection'; +export { UnknownConverter } from './unknown'; diff --git a/dist/lib/converter/types/index.js b/dist/lib/converter/types/index.js new file mode 100644 index 000000000..ac9daa08b --- /dev/null +++ b/dist/lib/converter/types/index.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var alias_1 = require("./alias"); +exports.AliasConverter = alias_1.AliasConverter; +var array_1 = require("./array"); +exports.ArrayConverter = array_1.ArrayConverter; +var binding_array_1 = require("./binding-array"); +exports.BindingArrayConverter = binding_array_1.BindingArrayConverter; +var binding_object_1 = require("./binding-object"); +exports.BindingObjectConverter = binding_object_1.BindingObjectConverter; +var enum_1 = require("./enum"); +exports.EnumConverter = enum_1.EnumConverter; +var intrinsic_1 = require("./intrinsic"); +exports.IntrinsicConverter = intrinsic_1.IntrinsicConverter; +var string_literal_1 = require("./string-literal"); +exports.StringLiteralConverter = string_literal_1.StringLiteralConverter; +var reference_1 = require("./reference"); +exports.ReferenceConverter = reference_1.ReferenceConverter; +var this_1 = require("./this"); +exports.ThisConverter = this_1.ThisConverter; +var tuple_1 = require("./tuple"); +exports.TupleConverter = tuple_1.TupleConverter; +var type_parameter_1 = require("./type-parameter"); +exports.TypeParameterConverter = type_parameter_1.TypeParameterConverter; +var type_operator_1 = require("./type-operator"); +exports.TypeOperatorConverter = type_operator_1.TypeOperatorConverter; +var union_or_intersection_1 = require("./union-or-intersection"); +exports.UnionOrIntersectionConverter = union_or_intersection_1.UnionOrIntersectionConverter; +var unknown_1 = require("./unknown"); +exports.UnknownConverter = unknown_1.UnknownConverter; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/index.js.map b/dist/lib/converter/types/index.js.map new file mode 100644 index 000000000..8e5cacf78 --- /dev/null +++ b/dist/lib/converter/types/index.js.map @@ -0,0 +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,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 { 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"]} \ No newline at end of file diff --git a/dist/lib/converter/types/intrinsic.d.ts b/dist/lib/converter/types/intrinsic.d.ts new file mode 100644 index 000000000..38d848eb0 --- /dev/null +++ b/dist/lib/converter/types/intrinsic.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { IntrinsicType } from '../../models/index'; +import { ConverterTypeComponent, TypeTypeConverter } from '../components'; +import { Context } from '../context'; +export declare class IntrinsicConverter extends ConverterTypeComponent implements TypeTypeConverter { + supportsType(context: Context, type: ts.Type): boolean; + convertType(context: Context, type: ts.Type): IntrinsicType; +} diff --git a/dist/lib/converter/types/intrinsic.js b/dist/lib/converter/types/intrinsic.js new file mode 100644 index 000000000..8c6de83c0 --- /dev/null +++ b/dist/lib/converter/types/intrinsic.js @@ -0,0 +1,44 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/index"); +var components_1 = require("../components"); +var IntrinsicTypeFlags = ts.TypeFlags.Intrinsic; +if (IntrinsicTypeFlags === undefined) { + throw new Error('Internal TypeScript API missing: TypeFlags.Intrinsic'); +} +var IntrinsicConverter = (function (_super) { + __extends(IntrinsicConverter, _super); + function IntrinsicConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + IntrinsicConverter.prototype.supportsType = function (context, type) { + return !!(type.flags & IntrinsicTypeFlags); + }; + IntrinsicConverter.prototype.convertType = function (context, type) { + var intrinsicName = context.program.getTypeChecker().typeToString(type); + return new index_1.IntrinsicType(intrinsicName); + }; + IntrinsicConverter = __decorate([ + components_1.Component({ name: 'type:intrinsic' }) + ], IntrinsicConverter); + return IntrinsicConverter; +}(components_1.ConverterTypeComponent)); +exports.IntrinsicConverter = IntrinsicConverter; +//# sourceMappingURL=intrinsic.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/intrinsic.js.map b/dist/lib/converter/types/intrinsic.js.map new file mode 100644 index 000000000..c548a9b81 --- /dev/null +++ b/dist/lib/converter/types/intrinsic.js.map @@ -0,0 +1 @@ +{"version":3,"file":"intrinsic.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/intrinsic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,4CAAmD;AACnD,4CAAqF;AAOrF,IAAM,kBAAkB,GAAI,EAAE,CAAC,SAAiB,CAAC,SAAS,CAAC;AAC3D,EAAE,CAAC,CAAC,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC;IACnC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;AAC5E,CAAC;AAGD;IAAwC,sCAAsB;IAA9D;;IAwBA,CAAC;IApBG,yCAAY,GAAZ,UAAa,OAAgB,EAAE,IAAa;QACxC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,kBAAkB,CAAC,CAAC;IAC/C,CAAC;IAcD,wCAAW,GAAX,UAAY,OAAgB,EAAE,IAAa;QACvC,IAAI,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACxE,MAAM,CAAC,IAAI,qBAAa,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAvBQ,kBAAkB;QAD9B,sBAAS,CAAC,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC;OACvB,kBAAkB,CAwB9B;IAAD,yBAAC;CAAA,AAxBD,CAAwC,mCAAsB,GAwB7D;AAxBY,gDAAkB","sourcesContent":["import * as ts from 'typescript';\n\nimport { IntrinsicType } from '../../models/index';\nimport { Component, ConverterTypeComponent, TypeTypeConverter } from '../components';\nimport { Context } from '../context';\n\n// TypeScript has an @internal enum set for the intrinsic types:\n// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2297-L2298\n// It is not included in the typescript typings, so the enum is cast as `any` to access the `Intrinsic` set.\n// tslint:disable-next-line:variable-name\nconst IntrinsicTypeFlags = (ts.TypeFlags as any).Intrinsic;\nif (IntrinsicTypeFlags === undefined) {\n throw new Error('Internal TypeScript API missing: TypeFlags.Intrinsic');\n}\n\n@Component({name: 'type:intrinsic'})\nexport class IntrinsicConverter extends ConverterTypeComponent implements TypeTypeConverter {\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.Type): boolean {\n return !!(type.flags & IntrinsicTypeFlags);\n }\n\n /**\n * Convert the given intrinsic type to its type reflection.\n *\n * This is a type based converter with no node based equivalent.\n *\n * ```\n * let someValue: string;\n * ```\n *\n * @param type The intrinsic type that should be converted.\n * @returns The type reflection representing the given intrinsic type.\n */\n convertType(context: Context, type: ts.Type): IntrinsicType {\n let intrinsicName = context.program.getTypeChecker().typeToString(type);\n return new IntrinsicType(intrinsicName);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/reference.d.ts b/dist/lib/converter/types/reference.d.ts new file mode 100644 index 000000000..e7166991f --- /dev/null +++ b/dist/lib/converter/types/reference.d.ts @@ -0,0 +1,12 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/types/index'; +import { ConverterTypeComponent, TypeNodeConverter } from '../components'; +import { Context } from '../context'; +export declare class ReferenceConverter extends ConverterTypeComponent implements TypeNodeConverter { + priority: number; + supportsNode(context: Context, node: ts.TypeReferenceNode, type: ts.TypeReference): boolean; + supportsType(context: Context, type: ts.TypeReference): boolean; + convertNode(context: Context, node: ts.TypeReferenceNode, type: ts.TypeReference): Type; + convertType(context: Context, type: ts.TypeReference): Type; + private convertLiteral(context, symbol, node?); +} diff --git a/dist/lib/converter/types/reference.js b/dist/lib/converter/types/reference.js new file mode 100644 index 000000000..b8eb4d959 --- /dev/null +++ b/dist/lib/converter/types/reference.js @@ -0,0 +1,99 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/types/index"); +var index_2 = require("../../models/reflections/index"); +var index_3 = require("../factories/index"); +var components_1 = require("../components"); +var converter_1 = require("../converter"); +var ReferenceConverter = (function (_super) { + __extends(ReferenceConverter, _super); + function ReferenceConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.priority = -50; + return _this; + } + ReferenceConverter.prototype.supportsNode = function (context, node, type) { + return !!(type.flags & ts.TypeFlags.Object); + }; + ReferenceConverter.prototype.supportsType = function (context, type) { + return !!(type.flags & ts.TypeFlags.Object); + }; + ReferenceConverter.prototype.convertNode = function (context, node, type) { + var _this = this; + if (!type.symbol) { + return new index_1.IntrinsicType('Object'); + } + else if (type.symbol.declarations && (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral)) { + return this.convertLiteral(context, type.symbol, node); + } + var result = index_3.createReferenceType(context, type.symbol); + if (node.typeArguments) { + result.typeArguments = node.typeArguments.map(function (n) { return _this.owner.convertType(context, n); }); + } + return result; + }; + ReferenceConverter.prototype.convertType = function (context, type) { + var _this = this; + if (!type.symbol) { + return new index_1.IntrinsicType('Object'); + } + else if (type.symbol.declarations && (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral)) { + return this.convertLiteral(context, type.symbol); + } + var result = index_3.createReferenceType(context, type.symbol); + if (type.typeArguments) { + result.typeArguments = type.typeArguments.map(function (t) { return _this.owner.convertType(context, null, t); }); + } + return result; + }; + ReferenceConverter.prototype.convertLiteral = function (context, symbol, node) { + var _this = this; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration_1 = _a[_i]; + if (context.visitStack.indexOf(declaration_1) !== -1) { + if (declaration_1.kind === ts.SyntaxKind.TypeLiteral || + declaration_1.kind === ts.SyntaxKind.ObjectLiteralExpression) { + return index_3.createReferenceType(context, declaration_1.parent.symbol); + } + else { + return index_3.createReferenceType(context, declaration_1.symbol); + } + } + } + var declaration = new index_2.DeclarationReflection(); + declaration.kind = index_2.ReflectionKind.TypeLiteral; + declaration.name = '__type'; + declaration.parent = context.scope; + context.registerReflection(declaration, null, symbol); + context.trigger(converter_1.Converter.EVENT_CREATE_DECLARATION, declaration, node); + context.withScope(declaration, function () { + symbol.declarations.forEach(function (node) { + _this.owner.convertNode(context, node); + }); + }); + return new index_1.ReflectionType(declaration); + }; + ReferenceConverter = __decorate([ + components_1.Component({ name: 'type:reference' }) + ], ReferenceConverter); + return ReferenceConverter; +}(components_1.ConverterTypeComponent)); +exports.ReferenceConverter = ReferenceConverter; +//# sourceMappingURL=reference.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/reference.js.map b/dist/lib/converter/types/reference.js.map new file mode 100644 index 000000000..a8218c9f5 --- /dev/null +++ b/dist/lib/converter/types/reference.js.map @@ -0,0 +1 @@ +{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/reference.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,kDAA+E;AAC/E,wDAAuF;AACvF,4CAAyD;AACzD,4CAAqF;AAErF,0CAAyC;AAGzC;IAAwC,sCAAsB;IAD9D;QAAA,qEAkIC;QA5HG,cAAQ,GAAG,CAAC,EAAE,CAAC;;IA4HnB,CAAC;IAvHG,yCAAY,GAAZ,UAAa,OAAgB,EAAE,IAA0B,EAAE,IAAsB;QAC7E,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAKD,yCAAY,GAAZ,UAAa,OAAgB,EAAE,IAAsB;QACjD,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAiBD,wCAAW,GAAX,UAAY,OAAgB,EAAE,IAA0B,EAAE,IAAsB;QAAhF,iBAaC;QAZG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YACf,MAAM,CAAC,IAAI,qBAAa,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,WAAW,IAAI,IAAI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D,OAAO,CAAC,OAAO,CAAC,qBAAS,CAAC,wBAAwB,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QACvE,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE;YAC3B,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAC,IAAI;gBAC7B,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,sBAAc,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAhIQ,kBAAkB;QAD9B,sBAAS,CAAC,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC;OACvB,kBAAkB,CAiI9B;IAAD,yBAAC;CAAA,AAjID,CAAwC,mCAAsB,GAiI7D;AAjIY,gDAAkB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, IntrinsicType, ReflectionType } from '../../models/types/index';\nimport { ReflectionKind, DeclarationReflection } from '../../models/reflections/index';\nimport { createReferenceType } from '../factories/index';\nimport { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\n\n@Component({name: 'type:reference'})\nexport class ReferenceConverter extends ConverterTypeComponent implements TypeNodeConverter {\n /**\n * The priority this converter should be executed with.\n * A higher priority means the converter will be applied earlier.\n */\n priority = -50;\n\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.TypeReferenceNode, type: ts.TypeReference): boolean {\n return !!(type.flags & ts.TypeFlags.Object);\n }\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.TypeReference): boolean {\n return !!(type.flags & ts.TypeFlags.Object);\n }\n\n /**\n * Convert the type reference node to its type reflection.\n *\n * This is a node based converter, see [[convertTypeReferenceType]] for the type equivalent.\n *\n * ```\n * class SomeClass { }\n * let someValue: SomeClass;\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The type reference node that should be converted.\n * @param type The type of the type reference node.\n * @returns The type reflection representing the given reference node.\n */\n convertNode(context: Context, node: ts.TypeReferenceNode, type: ts.TypeReference): Type {\n if (!type.symbol) {\n return new IntrinsicType('Object');\n } else if (type.symbol.declarations && (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral)) {\n return this.convertLiteral(context, type.symbol, node);\n }\n\n const result = createReferenceType(context, type.symbol);\n if (node.typeArguments) {\n result.typeArguments = node.typeArguments.map((n) => this.owner.convertType(context, n));\n }\n\n return result;\n }\n\n /**\n * Convert the given type reference to its type reflection.\n *\n * This is a type based converter, see [[convertTypeReference]] for the node equivalent.\n *\n * ```\n * class SomeClass { }\n * let someValue: SomeClass;\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The type reference that should be converted.\n * @returns The type reflection representing the given type reference.\n */\n convertType(context: Context, type: ts.TypeReference): Type {\n if (!type.symbol) {\n return new IntrinsicType('Object');\n } else if (type.symbol.declarations && (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral)) {\n return this.convertLiteral(context, type.symbol);\n }\n\n const result = createReferenceType(context, type.symbol);\n if (type.typeArguments) {\n result.typeArguments = type.typeArguments.map((t) => this.owner.convertType(context, null, t));\n }\n\n return result;\n }\n\n /**\n * Create a type literal reflection.\n *\n * This is a utility function used by [[convertTypeReferenceNode]] and\n * [[convertTypeReferenceType]] when encountering an object or type literal.\n *\n * A type literal is explicitly set:\n * ```\n * let someValue: {a: string; b: number;};\n * ```\n *\n * An object literal types are usually reflected by the TypeScript compiler:\n * ```\n * function someFunction() { return {a: 'Test', b: 1024}; }\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param symbol The symbol describing the type literal.\n * @param node If known the node which produced the type literal. Type literals that are\n * implicitly generated by TypeScript won't have a corresponding node.\n * @returns A type reflection representing the given type literal.\n */\n private convertLiteral(context: Context, symbol: ts.Symbol, node?: ts.Node): Type {\n for (let declaration of symbol.declarations) {\n if (context.visitStack.indexOf(declaration) !== -1) {\n if (declaration.kind === ts.SyntaxKind.TypeLiteral ||\n declaration.kind === ts.SyntaxKind.ObjectLiteralExpression) {\n return createReferenceType(context, declaration.parent.symbol);\n } else {\n return createReferenceType(context, declaration.symbol);\n }\n }\n }\n\n const declaration = new DeclarationReflection();\n declaration.kind = ReflectionKind.TypeLiteral;\n declaration.name = '__type';\n declaration.parent = context.scope;\n\n context.registerReflection(declaration, null, symbol);\n context.trigger(Converter.EVENT_CREATE_DECLARATION, declaration, node);\n context.withScope(declaration, () => {\n symbol.declarations.forEach((node) => {\n this.owner.convertNode(context, node);\n });\n });\n\n return new ReflectionType(declaration);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/string-literal.d.ts b/dist/lib/converter/types/string-literal.d.ts new file mode 100644 index 000000000..b09fe3e5e --- /dev/null +++ b/dist/lib/converter/types/string-literal.d.ts @@ -0,0 +1,10 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/types/index'; +import { ConverterTypeComponent, TypeConverter } from '../components'; +import { Context } from '../context'; +export declare class StringLiteralConverter extends ConverterTypeComponent implements TypeConverter { + supportsNode(context: Context, node: ts.StringLiteral): boolean; + supportsType(context: Context, type: ts.LiteralType): boolean; + convertNode(context: Context, node: ts.StringLiteral): Type; + convertType(context: Context, type: ts.LiteralType): Type; +} diff --git a/dist/lib/converter/types/string-literal.js b/dist/lib/converter/types/string-literal.js new file mode 100644 index 000000000..01875f19d --- /dev/null +++ b/dist/lib/converter/types/string-literal.js @@ -0,0 +1,45 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/types/index"); +var components_1 = require("../components"); +var StringLiteralConverter = (function (_super) { + __extends(StringLiteralConverter, _super); + function StringLiteralConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + StringLiteralConverter.prototype.supportsNode = function (context, node) { + return node.kind === ts.SyntaxKind.StringLiteral; + }; + StringLiteralConverter.prototype.supportsType = function (context, type) { + return !!(type.flags & ts.TypeFlags.StringLiteral); + }; + StringLiteralConverter.prototype.convertNode = function (context, node) { + return new index_1.StringLiteralType(node.text); + }; + StringLiteralConverter.prototype.convertType = function (context, type) { + return new index_1.StringLiteralType(type.value); + }; + StringLiteralConverter = __decorate([ + components_1.Component({ name: 'type:string-literal' }) + ], StringLiteralConverter); + return StringLiteralConverter; +}(components_1.ConverterTypeComponent)); +exports.StringLiteralConverter = StringLiteralConverter; +//# sourceMappingURL=string-literal.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/string-literal.js.map b/dist/lib/converter/types/string-literal.js.map new file mode 100644 index 000000000..b750f4513 --- /dev/null +++ b/dist/lib/converter/types/string-literal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"string-literal.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/string-literal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,kDAAmE;AACnE,4CAAiF;AAIjF;IAA4C,0CAAsB;IAAlE;;IA8CA,CAAC;IA1CG,6CAAY,GAAZ,UAAa,OAAgB,EAAE,IAAsB;QACjD,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;IACrD,CAAC;IAKD,6CAAY,GAAZ,UAAa,OAAgB,EAAE,IAAoB;QAC/C,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACvD,CAAC;IAcD,4CAAW,GAAX,UAAY,OAAgB,EAAE,IAAsB;QAChD,MAAM,CAAC,IAAI,yBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAcD,4CAAW,GAAX,UAAY,OAAgB,EAAE,IAAoB;QAC9C,MAAM,CAAC,IAAI,yBAAiB,CAAU,IAAI,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IA7CQ,sBAAsB;QADlC,sBAAS,CAAC,EAAC,IAAI,EAAE,qBAAqB,EAAC,CAAC;OAC5B,sBAAsB,CA8ClC;IAAD,6BAAC;CAAA,AA9CD,CAA4C,mCAAsB,GA8CjE;AA9CY,wDAAsB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, StringLiteralType } from '../../models/types/index';\nimport { Component, ConverterTypeComponent, TypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:string-literal'})\nexport class StringLiteralConverter extends ConverterTypeComponent implements TypeConverter {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.StringLiteral): boolean {\n return node.kind === ts.SyntaxKind.StringLiteral;\n }\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.LiteralType): boolean {\n return !!(type.flags & ts.TypeFlags.StringLiteral);\n }\n\n /**\n * Convert the given string literal expression node to its type reflection.\n *\n * This is a node based converter, see [[convertStringLiteralType]] for the type equivalent.\n *\n * ```\n * createElement(tagName: \"a\"): HTMLAnchorElement;\n * ```\n *\n * @param node The string literal node that should be converted.\n * @returns The type reflection representing the given string literal node.\n */\n convertNode(context: Context, node: ts.StringLiteral): Type {\n return new StringLiteralType(node.text);\n }\n\n /**\n * Convert the given string literal type to its type reflection.\n *\n * This is a type based converter, see [[convertStringLiteralExpression]] for the node equivalent.\n *\n * ```\n * createElement(tagName: \"a\"): HTMLAnchorElement;\n * ```\n *\n * @param type The intrinsic type that should be converted.\n * @returns The type reflection representing the given string literal type.\n */\n convertType(context: Context, type: ts.LiteralType): Type {\n return new StringLiteralType( type.value);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/this.d.ts b/dist/lib/converter/types/this.d.ts new file mode 100644 index 000000000..890df43ec --- /dev/null +++ b/dist/lib/converter/types/this.d.ts @@ -0,0 +1,8 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/types/index'; +import { ConverterTypeComponent, TypeNodeConverter } from '../components'; +import { Context } from '../context'; +export declare class ThisConverter extends ConverterTypeComponent implements TypeNodeConverter { + supportsNode(context: Context, node: ts.ThisTypeNode, type: ts.Type): boolean; + convertNode(context: Context, node: ts.ThisTypeNode, type: ts.Type): Type; +} diff --git a/dist/lib/converter/types/this.js b/dist/lib/converter/types/this.js new file mode 100644 index 000000000..873e2286a --- /dev/null +++ b/dist/lib/converter/types/this.js @@ -0,0 +1,39 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/types/index"); +var components_1 = require("../components"); +var ThisConverter = (function (_super) { + __extends(ThisConverter, _super); + function ThisConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + ThisConverter.prototype.supportsNode = function (context, node, type) { + return node.kind === ts.SyntaxKind.ThisType; + }; + ThisConverter.prototype.convertNode = function (context, node, type) { + return new index_1.IntrinsicType('this'); + }; + ThisConverter = __decorate([ + components_1.Component({ name: 'type:this' }) + ], ThisConverter); + return ThisConverter; +}(components_1.ConverterTypeComponent)); +exports.ThisConverter = ThisConverter; +//# sourceMappingURL=this.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/this.js.map b/dist/lib/converter/types/this.js.map new file mode 100644 index 000000000..62465798c --- /dev/null +++ b/dist/lib/converter/types/this.js.map @@ -0,0 +1 @@ +{"version":3,"file":"this.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/this.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,kDAA+D;AAC/D,4CAAqF;AAIrF;IAAmC,iCAAsB;IAAzD;;IA0BA,CAAC;IAtBU,oCAAY,GAAnB,UAAoB,OAAgB,EAAE,IAAqB,EAAE,IAAa;QACtE,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IAChD,CAAC;IAiBM,mCAAW,GAAlB,UAAmB,OAAgB,EAAE,IAAqB,EAAE,IAAa;QACrE,MAAM,CAAC,IAAI,qBAAa,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAzBQ,aAAa;QADzB,sBAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;OACpB,aAAa,CA0BzB;IAAD,oBAAC;CAAA,AA1BD,CAAmC,mCAAsB,GA0BxD;AA1BY,sCAAa","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, IntrinsicType } from '../../models/types/index';\nimport { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({ name: 'type:this' })\nexport class ThisConverter extends ConverterTypeComponent implements TypeNodeConverter {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n public supportsNode(context: Context, node: ts.ThisTypeNode, type: ts.Type): boolean {\n return node.kind === ts.SyntaxKind.ThisType;\n }\n\n /**\n * Convert the type reference node to its type reflection.\n *\n * This is a node based converter, see [[convertTypeReferenceType]] for the type equivalent.\n *\n * ```\n * class SomeClass { }\n * var someValue:SomeClass;\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The type reference node that should be converted.\n * @param type The type of the type reference node.\n * @returns The type reflection representing the given reference node.\n */\n public convertNode(context: Context, node: ts.ThisTypeNode, type: ts.Type): Type {\n return new IntrinsicType('this');\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/tuple.d.ts b/dist/lib/converter/types/tuple.d.ts new file mode 100644 index 000000000..c531cdb45 --- /dev/null +++ b/dist/lib/converter/types/tuple.d.ts @@ -0,0 +1,10 @@ +import * as ts from 'typescript'; +import { TupleType } from '../../models/types/index'; +import { ConverterTypeComponent, TypeConverter } from '../components'; +import { Context } from '../context'; +export declare class TupleConverter extends ConverterTypeComponent implements TypeConverter { + supportsNode(context: Context, node: ts.TupleTypeNode): boolean; + supportsType(context: Context, type: ts.TypeReference): boolean; + convertNode(context: Context, node: ts.TupleTypeNode): TupleType; + convertType(context: Context, type: ts.TypeReference): TupleType; +} diff --git a/dist/lib/converter/types/tuple.js b/dist/lib/converter/types/tuple.js new file mode 100644 index 000000000..86e335b3e --- /dev/null +++ b/dist/lib/converter/types/tuple.js @@ -0,0 +1,61 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/types/index"); +var components_1 = require("../components"); +var TupleConverter = (function (_super) { + __extends(TupleConverter, _super); + function TupleConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + TupleConverter.prototype.supportsNode = function (context, node) { + return node.kind === ts.SyntaxKind.TupleType; + }; + TupleConverter.prototype.supportsType = function (context, type) { + return !!(type.objectFlags & ts.ObjectFlags.Tuple); + }; + TupleConverter.prototype.convertNode = function (context, node) { + var _this = this; + var elements; + if (node.elementTypes) { + elements = node.elementTypes.map(function (n) { return _this.owner.convertType(context, n); }); + } + else { + elements = []; + } + return new index_1.TupleType(elements); + }; + TupleConverter.prototype.convertType = function (context, type) { + var _this = this; + var elements; + if (type.typeArguments) { + elements = type.typeArguments.map(function (t) { return _this.owner.convertType(context, null, t); }); + } + else { + elements = []; + } + return new index_1.TupleType(elements); + }; + TupleConverter = __decorate([ + components_1.Component({ name: 'type:tuple' }) + ], TupleConverter); + return TupleConverter; +}(components_1.ConverterTypeComponent)); +exports.TupleConverter = TupleConverter; +//# sourceMappingURL=tuple.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/tuple.js.map b/dist/lib/converter/types/tuple.js.map new file mode 100644 index 000000000..7c0482681 --- /dev/null +++ b/dist/lib/converter/types/tuple.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/tuple.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,kDAA2D;AAC3D,4CAAiF;AAIjF;IAAoC,kCAAsB;IAA1D;;IA8DA,CAAC;IA1DG,qCAAY,GAAZ,UAAa,OAAgB,EAAE,IAAsB;QACjD,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;IACjD,CAAC;IAKD,qCAAY,GAAZ,UAAa,OAAgB,EAAE,IAAsB;QACjD,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IAeD,oCAAW,GAAX,UAAY,OAAgB,EAAE,IAAsB;QAApD,iBASC;QARG,IAAI,QAAgB,CAAC;QACrB,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;YACpB,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC,EAAlC,CAAkC,CAAC,CAAC;QAChF,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,QAAQ,GAAG,EAAE,CAAC;QAClB,CAAC;QAED,MAAM,CAAC,IAAI,iBAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAeD,oCAAW,GAAX,UAAY,OAAgB,EAAE,IAAsB;QAApD,iBASC;QARG,IAAI,QAAgB,CAAC;QACrB,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YACrB,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAxC,CAAwC,CAAC,CAAC;QACvF,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,QAAQ,GAAG,EAAE,CAAC;QAClB,CAAC;QAED,MAAM,CAAC,IAAI,iBAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IA7DQ,cAAc;QAD1B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,cAAc,CA8D1B;IAAD,qBAAC;CAAA,AA9DD,CAAoC,mCAAsB,GA8DzD;AA9DY,wCAAc","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, TupleType } from '../../models/types/index';\nimport { Component, ConverterTypeComponent, TypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:tuple'})\nexport class TupleConverter extends ConverterTypeComponent implements TypeConverter {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.TupleTypeNode): boolean {\n return node.kind === ts.SyntaxKind.TupleType;\n }\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.TypeReference): boolean {\n return !!(type.objectFlags & ts.ObjectFlags.Tuple);\n }\n\n /**\n * Convert the given tuple type node to its type reflection.\n *\n * This is a node based converter, see [[convertTupleType]] for the type equivalent.\n *\n * ```\n * let someValue: [string,number];\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The tuple type node that should be converted.\n * @returns The type reflection representing the given tuple type node.\n */\n convertNode(context: Context, node: ts.TupleTypeNode): TupleType {\n let elements: Type[];\n if (node.elementTypes) {\n elements = node.elementTypes.map((n) => this.owner.convertType(context, n));\n } else {\n elements = [];\n }\n\n return new TupleType(elements);\n }\n\n /**\n * Convert the given tuple type to its type reflection.\n *\n * This is a type based converter, see [[convertTupleTypeNode]] for the node equivalent.\n *\n * ```\n * let someValue: [string,number];\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The tuple type that should be converted.\n * @returns The type reflection representing the given tuple type.\n */\n convertType(context: Context, type: ts.TypeReference): TupleType {\n let elements: Type[];\n if (type.typeArguments) {\n elements = type.typeArguments.map((t) => this.owner.convertType(context, null, t));\n } else {\n elements = [];\n }\n\n return new TupleType(elements);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/type-operator.d.ts b/dist/lib/converter/types/type-operator.d.ts new file mode 100644 index 000000000..d9fb60ef0 --- /dev/null +++ b/dist/lib/converter/types/type-operator.d.ts @@ -0,0 +1,9 @@ +import * as ts from 'typescript'; +import { TypeOperatorType } from '../../models/types/index'; +import { ConverterTypeComponent, TypeNodeConverter } from '../components'; +import { Context } from '../context'; +export declare class TypeOperatorConverter extends ConverterTypeComponent implements TypeNodeConverter { + priority: number; + supportsNode(context: Context, node: ts.TypeOperatorNode, type: ts.Type): boolean; + convertNode(context: Context, node: ts.TypeOperatorNode): TypeOperatorType; +} diff --git a/dist/lib/converter/types/type-operator.js b/dist/lib/converter/types/type-operator.js new file mode 100644 index 000000000..46bc024c2 --- /dev/null +++ b/dist/lib/converter/types/type-operator.js @@ -0,0 +1,42 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/types/index"); +var components_1 = require("../components"); +var TypeOperatorConverter = (function (_super) { + __extends(TypeOperatorConverter, _super); + function TypeOperatorConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.priority = 50; + return _this; + } + TypeOperatorConverter.prototype.supportsNode = function (context, node, type) { + return !!(node.kind === ts.SyntaxKind.TypeOperator); + }; + TypeOperatorConverter.prototype.convertNode = function (context, node) { + var target = this.owner.convertType(context, node.type); + return new index_1.TypeOperatorType(target); + }; + TypeOperatorConverter = __decorate([ + components_1.Component({ name: 'type:type-operator' }) + ], TypeOperatorConverter); + return TypeOperatorConverter; +}(components_1.ConverterTypeComponent)); +exports.TypeOperatorConverter = TypeOperatorConverter; +//# sourceMappingURL=type-operator.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/type-operator.js.map b/dist/lib/converter/types/type-operator.js.map new file mode 100644 index 000000000..bbc19b690 --- /dev/null +++ b/dist/lib/converter/types/type-operator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"type-operator.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/type-operator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,kDAA4D;AAC5D,4CAAqF;AAIrF;IAA2C,yCAAsB;IADjE;QAAA,qEAyBC;QApBG,cAAQ,GAAG,EAAE,CAAC;;IAoBlB,CAAC;IAfG,4CAAY,GAAZ,UAAa,OAAgB,EAAE,IAAyB,EAAE,IAAa;QACnE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACxD,CAAC;IASD,2CAAW,GAAX,UAAY,OAAgB,EAAE,IAAyB;QACnD,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,CAAC,IAAI,wBAAgB,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAvBQ,qBAAqB;QADjC,sBAAS,CAAC,EAAC,IAAI,EAAE,oBAAoB,EAAC,CAAC;OAC3B,qBAAqB,CAwBjC;IAAD,4BAAC;CAAA,AAxBD,CAA2C,mCAAsB,GAwBhE;AAxBY,sDAAqB","sourcesContent":["import * as ts from 'typescript';\n\nimport { TypeOperatorType } from '../../models/types/index';\nimport { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:type-operator'})\nexport class TypeOperatorConverter extends ConverterTypeComponent implements TypeNodeConverter {\n /**\n * we want to run before union\n */\n priority = 50;\n\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.TypeOperatorNode, type: ts.Type): boolean {\n return !!(node.kind === ts.SyntaxKind.TypeOperator);\n }\n\n /**\n * Interpret the given type operator node and convert it into a type representing keys of a type\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The type operator node representing keys of a type.\n * @returns The type representing keys of a type.\n */\n convertNode(context: Context, node: ts.TypeOperatorNode): TypeOperatorType {\n const target = this.owner.convertType(context, node.type);\n return new TypeOperatorType(target);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/type-parameter.d.ts b/dist/lib/converter/types/type-parameter.d.ts new file mode 100644 index 000000000..2fcbbd4aa --- /dev/null +++ b/dist/lib/converter/types/type-parameter.d.ts @@ -0,0 +1,9 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/types/index'; +import { ConverterTypeComponent, TypeNodeConverter } from '../components'; +import { Context } from '../context'; +export declare class TypeParameterConverter extends ConverterTypeComponent implements TypeNodeConverter { + priority: number; + supportsNode(context: Context, node: ts.TypeReferenceNode, type: ts.Type): boolean; + convertNode(context: Context, node: ts.TypeReferenceNode): Type; +} diff --git a/dist/lib/converter/types/type-parameter.js b/dist/lib/converter/types/type-parameter.js new file mode 100644 index 000000000..18ac7d926 --- /dev/null +++ b/dist/lib/converter/types/type-parameter.js @@ -0,0 +1,50 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var index_1 = require("../../models/types/index"); +var components_1 = require("../components"); +var TypeParameterConverter = (function (_super) { + __extends(TypeParameterConverter, _super); + function TypeParameterConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.priority = -50; + return _this; + } + TypeParameterConverter.prototype.supportsNode = function (context, node, type) { + return !!(type.flags & ts.TypeFlags.TypeParameter); + }; + TypeParameterConverter.prototype.convertNode = function (context, node) { + if (node.typeName) { + var name_1 = _ts.getTextOfNode(node.typeName); + if (context.typeParameters && context.typeParameters[name_1]) { + return context.typeParameters[name_1].clone(); + } + var result = new index_1.TypeParameterType(); + result.name = name_1; + return result; + } + }; + TypeParameterConverter = __decorate([ + components_1.Component({ name: 'type:type-parameter' }) + ], TypeParameterConverter); + return TypeParameterConverter; +}(components_1.ConverterTypeComponent)); +exports.TypeParameterConverter = TypeParameterConverter; +//# sourceMappingURL=type-parameter.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/type-parameter.js.map b/dist/lib/converter/types/type-parameter.js.map new file mode 100644 index 000000000..cd300a079 --- /dev/null +++ b/dist/lib/converter/types/type-parameter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"type-parameter.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/type-parameter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,uCAAyC;AAEzC,kDAAmE;AACnE,4CAAqF;AAIrF;IAA4C,0CAAsB;IADlE;QAAA,qEA0CC;QApCG,cAAQ,GAAG,CAAC,EAAE,CAAC;;IAoCnB,CAAC;IA/BG,6CAAY,GAAZ,UAAa,OAAgB,EAAE,IAA0B,EAAE,IAAa;QACpE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACvD,CAAC;IAiBD,4CAAW,GAAX,UAAY,OAAgB,EAAE,IAA0B;QACpD,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChB,IAAM,MAAI,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9C,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,MAAI,CAAC,CAAC,CAAC,CAAC;gBACzD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,MAAI,CAAC,CAAC,KAAK,EAAE,CAAC;YAChD,CAAC;YAED,IAAM,MAAM,GAAG,IAAI,yBAAiB,EAAE,CAAC;YACvC,MAAM,CAAC,IAAI,GAAG,MAAI,CAAC;YACnB,MAAM,CAAC,MAAM,CAAC;QAClB,CAAC;IACL,CAAC;IAxCQ,sBAAsB;QADlC,sBAAS,CAAC,EAAC,IAAI,EAAE,qBAAqB,EAAC,CAAC;OAC5B,sBAAsB,CAyClC;IAAD,6BAAC;CAAA,AAzCD,CAA4C,mCAAsB,GAyCjE;AAzCY,wDAAsB","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Type, TypeParameterType } from '../../models/types/index';\nimport { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:type-parameter'})\nexport class TypeParameterConverter extends ConverterTypeComponent implements TypeNodeConverter {\n /**\n * The priority this converter should be executed with.\n * A higher priority means the converter will be applied earlier.\n */\n priority = -50;\n\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.TypeReferenceNode, type: ts.Type): boolean {\n return !!(type.flags & ts.TypeFlags.TypeParameter);\n }\n\n /**\n * Interpret the given type reference node as a type parameter and convert it to its type reflection.\n *\n * This is a node based converter with no type equivalent.\n *\n * ```\n * class SomeClass {\n * public someValue: T;\n * }\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The type reference node representing a type parameter.\n * @returns The type reflection representing the given type parameter.\n */\n convertNode(context: Context, node: ts.TypeReferenceNode): Type {\n if (node.typeName) {\n const name = _ts.getTextOfNode(node.typeName);\n if (context.typeParameters && context.typeParameters[name]) {\n return context.typeParameters[name].clone();\n }\n\n const result = new TypeParameterType();\n result.name = name;\n return result;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/union-or-intersection.d.ts b/dist/lib/converter/types/union-or-intersection.d.ts new file mode 100644 index 000000000..e24a205a2 --- /dev/null +++ b/dist/lib/converter/types/union-or-intersection.d.ts @@ -0,0 +1,10 @@ +import * as ts from 'typescript'; +import { UnionType, IntersectionType } from '../../models/types/index'; +import { ConverterTypeComponent, TypeConverter } from '../components'; +import { Context } from '../context'; +export declare class UnionOrIntersectionConverter extends ConverterTypeComponent implements TypeConverter { + supportsNode(context: Context, node: ts.UnionOrIntersectionTypeNode): boolean; + supportsType(context: Context, type: ts.UnionOrIntersectionType): boolean; + convertNode(context: Context, node: ts.UnionOrIntersectionTypeNode): UnionType | IntersectionType; + convertType(context: Context, type: ts.UnionOrIntersectionType): UnionType | IntersectionType; +} diff --git a/dist/lib/converter/types/union-or-intersection.js b/dist/lib/converter/types/union-or-intersection.js new file mode 100644 index 000000000..996337c6e --- /dev/null +++ b/dist/lib/converter/types/union-or-intersection.js @@ -0,0 +1,61 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var index_1 = require("../../models/types/index"); +var components_1 = require("../components"); +var UnionOrIntersectionConverter = (function (_super) { + __extends(UnionOrIntersectionConverter, _super); + function UnionOrIntersectionConverter() { + return _super !== null && _super.apply(this, arguments) || this; + } + UnionOrIntersectionConverter.prototype.supportsNode = function (context, node) { + return node.kind === ts.SyntaxKind.UnionType || node.kind === ts.SyntaxKind.IntersectionType; + }; + UnionOrIntersectionConverter.prototype.supportsType = function (context, type) { + return !!(type.flags & ts.TypeFlags.UnionOrIntersection) && !(type.flags & ts.TypeFlags.EnumLiteral); + }; + UnionOrIntersectionConverter.prototype.convertNode = function (context, node) { + var _this = this; + var types = []; + if (node.types) { + types = node.types.map(function (n) { return _this.owner.convertType(context, n); }); + } + else { + types = []; + } + return node.kind === ts.SyntaxKind.IntersectionType ? new index_1.IntersectionType(types) : new index_1.UnionType(types); + }; + UnionOrIntersectionConverter.prototype.convertType = function (context, type) { + var _this = this; + var types; + if (type && type.types) { + types = type.types.map(function (t) { return _this.owner.convertType(context, null, t); }); + } + else { + types = []; + } + return !!(type.flags & ts.TypeFlags.Intersection) ? new index_1.IntersectionType(types) : new index_1.UnionType(types); + }; + UnionOrIntersectionConverter = __decorate([ + components_1.Component({ name: 'type:union-or-intersection' }) + ], UnionOrIntersectionConverter); + return UnionOrIntersectionConverter; +}(components_1.ConverterTypeComponent)); +exports.UnionOrIntersectionConverter = UnionOrIntersectionConverter; +//# sourceMappingURL=union-or-intersection.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/union-or-intersection.js.map b/dist/lib/converter/types/union-or-intersection.js.map new file mode 100644 index 000000000..4b4341e22 --- /dev/null +++ b/dist/lib/converter/types/union-or-intersection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"union-or-intersection.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/union-or-intersection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,kDAA6E;AAC7E,4CAAiF;AAIjF;IAAkD,gDAAsB;IAAxE;;IA8DA,CAAC;IA1DG,mDAAY,GAAZ,UAAa,OAAgB,EAAE,IAAoC;QAC/D,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;IACjG,CAAC;IAKD,mDAAY,GAAZ,UAAa,OAAgB,EAAE,IAAgC;QAC3D,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC,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CAAC,CAAC,IAAI,iBAAS,CAAC,KAAK,CAAC,CAAC;IAC3G,CAAC;IA7DQ,4BAA4B;QADxC,sBAAS,CAAC,EAAC,IAAI,EAAE,4BAA4B,EAAC,CAAC;OACnC,4BAA4B,CA8DxC;IAAD,mCAAC;CAAA,AA9DD,CAAkD,mCAAsB,GA8DvE;AA9DY,oEAA4B","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, UnionType, IntersectionType } from '../../models/types/index';\nimport { Component, ConverterTypeComponent, TypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:union-or-intersection'})\nexport class UnionOrIntersectionConverter extends ConverterTypeComponent implements TypeConverter {\n /**\n * Test whether this converter can handle the given TypeScript node.\n */\n supportsNode(context: Context, node: ts.UnionOrIntersectionTypeNode): boolean {\n return node.kind === ts.SyntaxKind.UnionType || node.kind === ts.SyntaxKind.IntersectionType;\n }\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.UnionOrIntersectionType): boolean {\n return !!(type.flags & ts.TypeFlags.UnionOrIntersection) && !(type.flags & ts.TypeFlags.EnumLiteral);\n }\n\n /**\n * Convert the given union type node to its type reflection.\n *\n * This is a node based converter, see [[convertType]] for the type equivalent.\n *\n * ```\n * let someValue: string|number;\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The union or intersection type node that should be converted.\n * @returns The type reflection representing the given union type node.\n */\n convertNode(context: Context, node: ts.UnionOrIntersectionTypeNode): UnionType | IntersectionType {\n let types: Type[] = [];\n if (node.types) {\n types = node.types.map((n) => this.owner.convertType(context, n));\n } else {\n types = [];\n }\n\n return node.kind === ts.SyntaxKind.IntersectionType ? new IntersectionType(types) : new UnionType(types);\n }\n\n /**\n * Convert the given union type to its type reflection.\n *\n * This is a type based converter, see [[convertUnionTypeNode]] for the node equivalent.\n *\n * ```\n * let someValue: string|number;\n * ```\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The union type that should be converted.\n * @returns The type reflection representing the given union type.\n */\n convertType(context: Context, type: ts.UnionOrIntersectionType): UnionType | IntersectionType {\n let types: Type[];\n if (type && type.types) {\n types = type.types.map((t) => this.owner.convertType(context, null, t));\n } else {\n types = [];\n }\n\n return !!(type.flags & ts.TypeFlags.Intersection) ? new IntersectionType(types) : new UnionType(types);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/types/unknown.d.ts b/dist/lib/converter/types/unknown.d.ts new file mode 100644 index 000000000..a4534fa0c --- /dev/null +++ b/dist/lib/converter/types/unknown.d.ts @@ -0,0 +1,9 @@ +import * as ts from 'typescript'; +import { Type } from '../../models/types/index'; +import { ConverterTypeComponent, TypeTypeConverter } from '../components'; +import { Context } from '../context'; +export declare class UnknownConverter extends ConverterTypeComponent implements TypeTypeConverter { + priority: number; + supportsType(context: Context, type: ts.Type): boolean; + convertType(context: Context, type: ts.Type): Type; +} diff --git a/dist/lib/converter/types/unknown.js b/dist/lib/converter/types/unknown.js new file mode 100644 index 000000000..6e32befde --- /dev/null +++ b/dist/lib/converter/types/unknown.js @@ -0,0 +1,41 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../../models/types/index"); +var components_1 = require("../components"); +var UnknownConverter = (function (_super) { + __extends(UnknownConverter, _super); + function UnknownConverter() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.priority = -100; + return _this; + } + UnknownConverter.prototype.supportsType = function (context, type) { + return true; + }; + UnknownConverter.prototype.convertType = function (context, type) { + var name = context.checker.typeToString(type); + return new index_1.UnknownType(name); + }; + UnknownConverter = __decorate([ + components_1.Component({ name: 'type:unknown' }) + ], UnknownConverter); + return UnknownConverter; +}(components_1.ConverterTypeComponent)); +exports.UnknownConverter = UnknownConverter; +//# sourceMappingURL=unknown.js.map \ No newline at end of file diff --git a/dist/lib/converter/types/unknown.js.map b/dist/lib/converter/types/unknown.js.map new file mode 100644 index 000000000..22a77edb9 --- /dev/null +++ b/dist/lib/converter/types/unknown.js.map @@ -0,0 +1 @@ +{"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/unknown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,kDAA6D;AAC7D,4CAAqF;AAIrF;IAAsC,oCAAsB;IAD5D;QAAA,qEAgCC;QA1BG,cAAQ,GAAG,CAAC,GAAG,CAAC;;IA0BpB,CAAC;IArBG,uCAAY,GAAZ,UAAa,OAAgB,EAAE,IAAa;QACxC,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAeD,sCAAW,GAAX,UAAY,OAAgB,EAAE,IAAa;QACvC,IAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,CAAC,IAAI,mBAAW,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IA9BQ,gBAAgB;QAD5B,sBAAS,CAAC,EAAC,IAAI,EAAE,cAAc,EAAC,CAAC;OACrB,gBAAgB,CA+B5B;IAAD,uBAAC;CAAA,AA/BD,CAAsC,mCAAsB,GA+B3D;AA/BY,4CAAgB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Type, UnknownType } from '../../models/types/index';\nimport { Component, ConverterTypeComponent, TypeTypeConverter } from '../components';\nimport { Context } from '../context';\n\n@Component({name: 'type:unknown'})\nexport class UnknownConverter extends ConverterTypeComponent implements TypeTypeConverter {\n /**\n * The priority this converter should be executed with.\n * A higher priority means the converter will be applied earlier.\n */\n priority = -100;\n\n /**\n * Test whether this converter can handle the given TypeScript type.\n */\n supportsType(context: Context, type: ts.Type): boolean {\n return true;\n }\n\n /**\n * Convert the given type to its type reflection.\n *\n * This is a type based converter with no node based equivalent.\n *\n * If no other converter is able to reflect a type, this converter will produce a\n * reflection by utilising ts.typeToString() to generate a string representation of the\n * given type.\n *\n * @param context The context object describing the current state the converter is in.\n * @param type The type that should be converted.\n * @returns The type reflection representing the given type.\n */\n convertType(context: Context, type: ts.Type): Type {\n const name = context.checker.typeToString(type);\n return new UnknownType(name);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/utils/base-path.d.ts b/dist/lib/converter/utils/base-path.d.ts new file mode 100644 index 000000000..6628bc1cb --- /dev/null +++ b/dist/lib/converter/utils/base-path.d.ts @@ -0,0 +1,7 @@ +export declare class BasePath { + private basePaths; + add(fileName: string): void; + trim(fileName: string): string; + reset(): void; + static normalize(path: string): string; +} diff --git a/dist/lib/converter/utils/base-path.js b/dist/lib/converter/utils/base-path.js new file mode 100644 index 000000000..605bc19ca --- /dev/null +++ b/dist/lib/converter/utils/base-path.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var BasePath = (function () { + function BasePath() { + this.basePaths = []; + } + BasePath.prototype.add = function (fileName) { + var fileDir = Path.dirname(BasePath.normalize(fileName)); + var filePath = fileDir.split('/'); + basePaths: for (var n = 0, c = this.basePaths.length; n < c; n++) { + var basePath = this.basePaths[n].split('/'); + var mMax = Math.min(basePath.length, filePath.length); + for (var m = 0; m < mMax; m++) { + if (basePath[m] === filePath[m]) { + continue; + } + if (m < 1) { + continue basePaths; + } + else { + if (m < basePath.length) { + this.basePaths[n] = basePath.slice(0, m).join('/'); + } + return; + } + } + this.basePaths[n] = basePath.splice(0, mMax).join('/'); + return; + } + this.basePaths.push(fileDir); + }; + BasePath.prototype.trim = function (fileName) { + fileName = BasePath.normalize(fileName); + for (var n = 0, c = this.basePaths.length; n < c; n++) { + var basePath = this.basePaths[n]; + if (fileName.substr(0, basePath.length) === basePath) { + return fileName.substr(basePath.length + 1); + } + } + return fileName; + }; + BasePath.prototype.reset = function () { + this.basePaths = []; + }; + BasePath.normalize = function (path) { + path = path.replace(/\\/g, '/'); + path = path.replace(/^["']+|["']+$/g, ''); + return path.replace(/^([^\:]+)\:\//, function (m, m1) { return m1.toUpperCase() + ':/'; }); + }; + return BasePath; +}()); +exports.BasePath = BasePath; +//# sourceMappingURL=base-path.js.map \ No newline at end of file diff --git a/dist/lib/converter/utils/base-path.js.map b/dist/lib/converter/utils/base-path.js.map new file mode 100644 index 000000000..8de1df95f --- /dev/null +++ b/dist/lib/converter/utils/base-path.js.map @@ -0,0 +1 @@ +{"version":3,"file":"base-path.js","sourceRoot":"","sources":["../../../../src/lib/converter/utils/base-path.ts"],"names":[],"mappings":";;AAAA,2BAA6B;AAQ7B;IAAA;QAIY,cAAS,GAAa,EAAE,CAAC;IAiFrC,CAAC;IA1EG,sBAAG,GAAH,UAAI,QAAgB;QAChB,IAAM,OAAO,GAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC5D,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEpC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/D,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,C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CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACpD,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACnC,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACnD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAChD,CAAC;QACL,CAAC;QAED,MAAM,CAAC,QAAQ,CAAC;IACpB,CAAC;IAKD,wBAAK,GAAL;QACI,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACxB,CAAC;IAQM,kBAAS,GAAhB,UAAiB,IAAY;QAEzB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAGhC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAG1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,UAAC,CAAC,EAAE,EAAE,IAAK,OAAA,EAAE,CAAC,WAAW,EAAE,GAAG,IAAI,EAAvB,CAAuB,CAAC,CAAC;IAC7E,CAAC;IACL,eAAC;AAAD,CAAC,AArFD,IAqFC;AArFY,4BAAQ","sourcesContent":["import * as Path from 'path';\n\n/**\n * Helper class that determines the common base path of a set of files.\n *\n * In the first step all files must be passed to [[add]]. Afterwards [[trim]]\n * can be used to retrieve the shortest path relative to the determined base path.\n */\nexport class BasePath {\n /**\n * List of known base paths.\n */\n private basePaths: string[] = [];\n\n /**\n * Add the given file path to this set of base paths.\n *\n * @param fileName The absolute filename that should be added to the base path.\n */\n add(fileName: string) {\n const fileDir = Path.dirname(BasePath.normalize(fileName));\n const filePath = fileDir.split('/');\n\n basePaths: for (let n = 0, c = this.basePaths.length; n < c; n++) {\n const basePath = this.basePaths[n].split('/');\n const mMax = Math.min(basePath.length, filePath.length);\n for (let m = 0; m < mMax; m++) {\n if (basePath[m] === filePath[m]) {\n continue;\n }\n\n if (m < 1) {\n // No match at all, try next known base path\n continue basePaths;\n } else {\n // Partial match, trim the known base path\n if (m < basePath.length) {\n this.basePaths[n] = basePath.slice(0, m).join('/');\n }\n return;\n }\n }\n\n // Complete match, exit\n this.basePaths[n] = basePath.splice(0, mMax).join('/');\n return;\n }\n\n // Unknown base path, add it\n this.basePaths.push(fileDir);\n }\n\n /**\n * Trim the given filename by the determined base paths.\n *\n * @param fileName The absolute filename that should be trimmed.\n * @returns The trimmed version of the filename.\n */\n trim(fileName: string): string {\n fileName = BasePath.normalize(fileName);\n for (let n = 0, c = this.basePaths.length; n < c; n++) {\n const basePath = this.basePaths[n];\n if (fileName.substr(0, basePath.length) === basePath) {\n return fileName.substr(basePath.length + 1);\n }\n }\n\n return fileName;\n }\n\n /**\n * Reset this instance, ignore all paths already passed to [[add]].\n */\n reset() {\n this.basePaths = [];\n }\n\n /**\n * Normalize the given path.\n *\n * @param path The path that should be normalized.\n * @returns Normalized version of the given path.\n */\n static normalize(path: string): string {\n // Ensure forward slashes\n path = path.replace(/\\\\/g, '/');\n\n // Remove all surrounding quotes\n path = path.replace(/^[\"']+|[\"']+$/g, '');\n\n // Make Windows drive letters lower case\n return path.replace(/^([^\\:]+)\\:\\//, (m, m1) => m1.toUpperCase() + ':/');\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/converter/utils/compiler-host.d.ts b/dist/lib/converter/utils/compiler-host.d.ts new file mode 100644 index 000000000..993629ee7 --- /dev/null +++ b/dist/lib/converter/utils/compiler-host.d.ts @@ -0,0 +1,16 @@ +import * as ts from 'typescript'; +import { ConverterComponent } from '../components'; +export declare class CompilerHost extends ConverterComponent implements ts.CompilerHost { + private currentDirectory; + getSourceFile(filename: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void): ts.SourceFile; + getDefaultLibFileName(options: ts.CompilerOptions): string; + getDirectories(path: string): string[]; + getCurrentDirectory(): string; + useCaseSensitiveFileNames(): boolean; + fileExists(fileName: string): boolean; + directoryExists(directoryName: string): boolean; + readFile(fileName: string): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; +} diff --git a/dist/lib/converter/utils/compiler-host.js b/dist/lib/converter/utils/compiler-host.js new file mode 100644 index 000000000..c59c38cd7 --- /dev/null +++ b/dist/lib/converter/utils/compiler-host.js @@ -0,0 +1,67 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var ts = require("typescript"); +var _ts = require("../../ts-internal"); +var components_1 = require("../components"); +var ERROR_UNSUPPORTED_FILE_ENCODING = -2147024809; +var CompilerHost = (function (_super) { + __extends(CompilerHost, _super); + function CompilerHost() { + return _super !== null && _super.apply(this, arguments) || this; + } + CompilerHost.prototype.getSourceFile = function (filename, languageVersion, onError) { + var text; + try { + text = ts.sys.readFile(filename, this.application.options.getCompilerOptions().charset); + } + catch (e) { + if (onError) { + onError(e.number === ERROR_UNSUPPORTED_FILE_ENCODING ? 'Unsupported file encoding' : e.message); + } + text = ''; + } + return text !== undefined ? ts.createSourceFile(filename, text, languageVersion) : undefined; + }; + CompilerHost.prototype.getDefaultLibFileName = function (options) { + var libLocation = _ts.getDirectoryPath(_ts.normalizePath(ts.sys.getExecutingFilePath())); + return _ts.combinePaths(libLocation, ts.getDefaultLibFileName(options)); + }; + CompilerHost.prototype.getDirectories = function (path) { + return ts.sys.getDirectories(path); + }; + CompilerHost.prototype.getCurrentDirectory = function () { + return this.currentDirectory || (this.currentDirectory = ts.sys.getCurrentDirectory()); + }; + CompilerHost.prototype.useCaseSensitiveFileNames = function () { + return ts.sys.useCaseSensitiveFileNames; + }; + CompilerHost.prototype.fileExists = function (fileName) { + return ts.sys.fileExists(fileName); + }; + CompilerHost.prototype.directoryExists = function (directoryName) { + return ts.sys.directoryExists(directoryName); + }; + CompilerHost.prototype.readFile = function (fileName) { + return ts.sys.readFile(fileName); + }; + CompilerHost.prototype.getCanonicalFileName = function (fileName) { + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + }; + CompilerHost.prototype.getNewLine = function () { + return ts.sys.newLine; + }; + CompilerHost.prototype.writeFile = function (fileName, data, writeByteOrderMark, onError) { }; + return CompilerHost; +}(components_1.ConverterComponent)); +exports.CompilerHost = CompilerHost; +//# sourceMappingURL=compiler-host.js.map \ No newline at end of file diff --git a/dist/lib/converter/utils/compiler-host.js.map b/dist/lib/converter/utils/compiler-host.js.map new file mode 100644 index 000000000..6e527ef8b --- /dev/null +++ b/dist/lib/converter/utils/compiler-host.js.map @@ -0,0 +1 @@ +{"version":3,"file":"compiler-host.js","sourceRoot":"","sources":["../../../../src/lib/converter/utils/compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAiC;AACjC,uCAAyC;AAEzC,4CAAmD;AAKnD,IAAM,+BAA+B,GAAG,CAAC,UAAU,CAAC;AAKpD;IAAkC,gCAAkB;IAApD;;IA6IA,CAAC;IA5HG,oCAAa,GAAb,UAAc,QAAgB,EAAE,eAAgC,EAAE,OAAmC;QACjG,IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACD,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,OAAO,CAAC,CAAC;QAC5F,CAAC;QAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACT,EAAE,CAAC,CAAC,OAA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D,CAAC;IAUD,+BAAQ,GAAR,UAAS,QAAgB;QACrB,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAUD,2CAAoB,GAApB,UAAqB,QAAgB;QACjC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IAChF,CAAC;IASD,iCAAU,GAAV;QACI,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;IAC1B,CAAC;IAcD,gCAAS,GAAT,UAAU,QAAgB,EAAE,IAAY,EAAE,kBAA2B,EAAE,OAAmC,IAAI,CAAC;IACnH,mBAAC;AAAD,CAAC,AA7ID,CAAkC,+BAAkB,GA6InD;AA7IY,oCAAY","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { ConverterComponent } from '../components';\n\n/**\n * Return code of ts.sys.readFile when the file encoding is unsupported.\n */\nconst ERROR_UNSUPPORTED_FILE_ENCODING = -2147024809;\n\n/**\n * CompilerHost implementation\n */\nexport class CompilerHost extends ConverterComponent implements ts.CompilerHost {\n\n /**\n * The full path of the current directory. Result cache of [[getCurrentDirectory]].\n */\n private currentDirectory: string;\n\n /**\n * Return an instance of ts.SourceFile representing the given file.\n *\n * Implementation of ts.CompilerHost.getSourceFile()\n *\n * @param filename The path and name of the file that should be loaded.\n * @param languageVersion The script target the file should be interpreted with.\n * @param onError A callback that will be invoked if an error occurs.\n * @returns An instance of ts.SourceFile representing the given file.\n */\n getSourceFile(filename: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void): ts.SourceFile {\n let text: string;\n try {\n text = ts.sys.readFile(filename, this.application.options.getCompilerOptions().charset);\n } catch (e) {\n if (onError) {\n onError(e.number === ERROR_UNSUPPORTED_FILE_ENCODING ? 'Unsupported file encoding' : e.message);\n }\n text = '';\n }\n\n return text !== undefined ? ts.createSourceFile(filename, text, languageVersion) : undefined;\n }\n\n /**\n * Return the full path of the default library that should be used.\n *\n * Implementation of ts.CompilerHost.getDefaultLibFilename()\n *\n * @returns The full path of the default library.\n */\n getDefaultLibFileName(options: ts.CompilerOptions): string {\n const libLocation = _ts.getDirectoryPath(_ts.normalizePath(ts.sys.getExecutingFilePath()));\n return _ts.combinePaths(libLocation, ts.getDefaultLibFileName(options));\n }\n\n getDirectories(path: string): string[] {\n return ts.sys.getDirectories(path);\n }\n\n /**\n * Return the full path of the current directory.\n *\n * Implementation of ts.CompilerHost.getCurrentDirectory()\n *\n * @returns The full path of the current directory.\n */\n getCurrentDirectory(): string {\n return this.currentDirectory || (this.currentDirectory = ts.sys.getCurrentDirectory());\n }\n\n /**\n * Return whether file names are case sensitive on the current platform or not.\n *\n * Implementation of ts.CompilerHost.useCaseSensitiveFileNames()\n *\n * @returns TRUE if file names are case sensitive on the current platform, FALSE otherwise.\n */\n useCaseSensitiveFileNames(): boolean {\n return ts.sys.useCaseSensitiveFileNames;\n }\n\n /**\n * Check whether the given file exists.\n *\n * Implementation of ts.CompilerHost.fileExists(fileName)\n *\n * @param fileName\n * @returns {boolean}\n */\n fileExists(fileName: string): boolean {\n return ts.sys.fileExists(fileName);\n }\n\n /**\n * Check whether the given directory exists.\n *\n * Implementation of ts.CompilerHost.directoryExists(directoryName)\n *\n * @param directoryName\n * @returns {boolean}\n */\n directoryExists(directoryName: string): boolean {\n return ts.sys.directoryExists(directoryName);\n }\n\n /**\n * Return the contents of the given file.\n *\n * Implementation of ts.CompilerHost.readFile(fileName)\n *\n * @param fileName\n * @returns {string}\n */\n readFile(fileName: string): string {\n return ts.sys.readFile(fileName);\n }\n\n /**\n * Return the canonical file name of the given file.\n *\n * Implementation of ts.CompilerHost.getCanonicalFileName()\n *\n * @param fileName The file name whose canonical variant should be resolved.\n * @returns The canonical file name of the given file.\n */\n getCanonicalFileName(fileName: string): string {\n return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();\n }\n\n /**\n * Return the new line char sequence of the current platform.\n *\n * Implementation of ts.CompilerHost.getNewLine()\n *\n * @returns The new line char sequence of the current platform.\n */\n getNewLine(): string {\n return ts.sys.newLine;\n }\n\n /**\n * Write a compiled javascript file to disc.\n *\n * As TypeDoc will not emit compiled javascript files this is a null operation.\n *\n * Implementation of ts.CompilerHost.writeFile()\n *\n * @param fileName The name of the file that should be written.\n * @param data The contents of the file.\n * @param writeByteOrderMark Whether the UTF-8 BOM should be written or not.\n * @param onError A callback that will be invoked if an error occurs.\n */\n writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/ReflectionCategory.d.ts b/dist/lib/models/ReflectionCategory.d.ts new file mode 100644 index 000000000..dca08adc4 --- /dev/null +++ b/dist/lib/models/ReflectionCategory.d.ts @@ -0,0 +1,9 @@ +import { Reflection } from './reflections/abstract'; +export declare class ReflectionCategory { + title: string; + children: Reflection[]; + allChildrenHaveOwnDocument: Function; + constructor(title: string); + private getAllChildrenHaveOwnDocument(); + toObject(): any; +} diff --git a/dist/lib/models/ReflectionCategory.js b/dist/lib/models/ReflectionCategory.js new file mode 100644 index 000000000..78fd1ea26 --- /dev/null +++ b/dist/lib/models/ReflectionCategory.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ReflectionCategory = (function () { + function ReflectionCategory(title) { + var _this = this; + this.children = []; + this.title = title; + this.allChildrenHaveOwnDocument = (function () { return _this.getAllChildrenHaveOwnDocument(); }); + } + ReflectionCategory.prototype.getAllChildrenHaveOwnDocument = function () { + var onlyOwnDocuments = true; + this.children.forEach(function (child) { + onlyOwnDocuments = onlyOwnDocuments && child.hasOwnDocument; + }); + return onlyOwnDocuments; + }; + ReflectionCategory.prototype.toObject = function () { + var result = { + title: this.title + }; + if (this.children) { + var children_1 = []; + this.children.forEach(function (child) { + children_1.push(child.id); + }); + result['children'] = children_1; + } + return result; + }; + return ReflectionCategory; +}()); +exports.ReflectionCategory = ReflectionCategory; +//# sourceMappingURL=ReflectionCategory.js.map \ No newline at end of file diff --git a/dist/lib/models/ReflectionCategory.js.map b/dist/lib/models/ReflectionCategory.js.map new file mode 100644 index 000000000..8c6f599dc --- /dev/null +++ b/dist/lib/models/ReflectionCategory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ReflectionCategory.js","sourceRoot":"","sources":["../../../src/lib/models/ReflectionCategory.ts"],"names":[],"mappings":";;AASA;IAwBI,4BAAY,KAAa;QAAzB,iBAIC;QAnBD,aAAQ,GAAiB,EAAE,CAAC;QAgBxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,CAAC,0BAA0B,GAAG,CAAC,cAAM,OAAA,KAAI,CAAC,6BAA6B,EAAE,EAApC,CAAoC,CAAC,CAAC;IACnF,CAAC;IAKO,0DAA6B,GAArC;QACI,IAAI,gBAAgB,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAC,KAAK;YACxB,gBAAgB,GAAG,gBAAgB,IAAI,KAAK,CAAC,cAAc,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,gBAAgB,CAAC;IAC5B,CAAC;IAMD,qCAAQ,GAAR;QACI,IAAM,MAAM,GAAG;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;SACpB,CAAC;QAEF,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChB,IAAM,UAAQ,GAAU,EAAE,CAAC;YAC3B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAC,KAAK;gBACxB,UAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,UAAU,CAAC,GAAG,UAAQ,CAAC;QAClC,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,yBAAC;AAAD,CAAC,AA9DD,IA8DC;AA9DY,gDAAkB","sourcesContent":["import { Reflection } from './reflections/abstract';\n\n/**\n * A category of reflections.\n *\n * Reflection categories are created by the ´CategoryPlugin´ in the resolving phase\n * of the dispatcher. The main purpose of categories is to be able to more easily\n * render human readable children lists in templates.\n */\nexport class ReflectionCategory {\n /**\n * The title, a string representation of this category.\n */\n title: string;\n\n /**\n * All reflections of this category.\n */\n children: Reflection[] = [];\n\n /**\n * Do all children of this category have a separate document?\n *\n * A bound representation of the ´ReflectionCategory.getAllChildrenHaveOwnDocument´\n * that can be used within templates.\n */\n allChildrenHaveOwnDocument: Function;\n\n /**\n * Create a new ReflectionCategory instance.\n *\n * @param title The title of this category.\n */\n constructor(title: string) {\n this.title = title;\n\n this.allChildrenHaveOwnDocument = (() => this.getAllChildrenHaveOwnDocument());\n }\n\n /**\n * Do all children of this category have a separate document?\n */\n private getAllChildrenHaveOwnDocument(): boolean {\n let onlyOwnDocuments = true;\n this.children.forEach((child) => {\n onlyOwnDocuments = onlyOwnDocuments && child.hasOwnDocument;\n });\n\n return onlyOwnDocuments;\n }\n\n /**\n * Return a raw object representation of this reflection category.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result = {\n title: this.title\n };\n\n if (this.children) {\n const children: any[] = [];\n this.children.forEach((child) => {\n children.push(child.id);\n });\n\n result['children'] = children;\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/ReflectionGroup.d.ts b/dist/lib/models/ReflectionGroup.d.ts new file mode 100644 index 000000000..63a830a6f --- /dev/null +++ b/dist/lib/models/ReflectionGroup.d.ts @@ -0,0 +1,16 @@ +import { Reflection, ReflectionKind } from './reflections/abstract'; +export declare class ReflectionGroup { + title: string; + kind: ReflectionKind; + children: Reflection[]; + cssClasses: string; + allChildrenHaveOwnDocument: Function; + allChildrenAreInherited: boolean; + allChildrenArePrivate: boolean; + allChildrenAreProtectedOrPrivate: boolean; + allChildrenAreExternal: boolean; + someChildrenAreExported: boolean; + constructor(title: string, kind: ReflectionKind); + private getAllChildrenHaveOwnDocument(); + toObject(): any; +} diff --git a/dist/lib/models/ReflectionGroup.js b/dist/lib/models/ReflectionGroup.js new file mode 100644 index 000000000..6f1ddb4ed --- /dev/null +++ b/dist/lib/models/ReflectionGroup.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ReflectionGroup = (function () { + function ReflectionGroup(title, kind) { + var _this = this; + this.children = []; + this.title = title; + this.kind = kind; + this.allChildrenHaveOwnDocument = (function () { return _this.getAllChildrenHaveOwnDocument(); }); + } + ReflectionGroup.prototype.getAllChildrenHaveOwnDocument = function () { + var onlyOwnDocuments = true; + this.children.forEach(function (child) { + onlyOwnDocuments = onlyOwnDocuments && child.hasOwnDocument; + }); + return onlyOwnDocuments; + }; + ReflectionGroup.prototype.toObject = function () { + var result = { + title: this.title, + kind: this.kind + }; + if (this.children) { + var children_1 = []; + this.children.forEach(function (child) { + children_1.push(child.id); + }); + result['children'] = children_1; + } + return result; + }; + return ReflectionGroup; +}()); +exports.ReflectionGroup = ReflectionGroup; +//# sourceMappingURL=ReflectionGroup.js.map \ No newline at end of file diff --git a/dist/lib/models/ReflectionGroup.js.map b/dist/lib/models/ReflectionGroup.js.map new file mode 100644 index 000000000..6b04af16b --- /dev/null +++ b/dist/lib/models/ReflectionGroup.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ReflectionGroup.js","sourceRoot":"","sources":["../../../src/lib/models/ReflectionGroup.ts"],"names":[],"mappings":";;AASA;IA6DI,yBAAY,KAAa,EAAE,IAAoB;QAA/C,iBAKC;QApDD,aAAQ,GAAiB,EAAE,CAAC;QAgDxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,0BAA0B,GAAG,CAAC,cAAM,OAAA,KAAI,CAAC,6BAA6B,EAAE,EAApC,CAAoC,CAAC,CAAC;IACnF,CAAC;IAKO,uDAA6B,GAArC;QACI,IAAI,gBAAgB,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAC,KAAK;YACxB,gBAAgB,GAAG,gBAAgB,IAAI,KAAK,CAAC,cAAc,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,gBAAgB,CAAC;IAC5B,CAAC;IAMD,kCAAQ,GAAR;QACI,IAAM,MAAM,GAAG;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAG,IAAI,CAAC,IAAI;SACnB,CAAC;QAEF,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChB,IAAM,UAAQ,GAAU,EAAE,CAAC;YAC3B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAC,KAAK;gBACxB,UAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,UAAU,CAAC,GAAG,UAAQ,CAAC;QAClC,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,sBAAC;AAAD,CAAC,AArGD,IAqGC;AArGY,0CAAe","sourcesContent":["import { Reflection, ReflectionKind } from './reflections/abstract';\n\n/**\n * A group of reflections. All reflections in a group are of the same kind.\n *\n * Reflection groups are created by the ´GroupHandler´ in the resolving phase\n * of the dispatcher. The main purpose of groups is to be able to more easily\n * render human readable children lists in templates.\n */\nexport class ReflectionGroup {\n /**\n * The title, a string representation of the typescript kind, of this group.\n */\n title: string;\n\n /**\n * The original typescript kind of the children of this group.\n */\n kind: ReflectionKind;\n\n /**\n * All reflections of this group.\n */\n children: Reflection[] = [];\n\n /**\n * A list of generated css classes that should be applied to representations of this\n * group in the generated markup.\n */\n cssClasses: string;\n\n /**\n * Do all children of this group have a separate document?\n *\n * A bound representation of the ´ReflectionGroup.getAllChildrenHaveOwnDocument´\n * that can be used within templates.\n */\n allChildrenHaveOwnDocument: Function;\n\n /**\n * Are all children inherited members?\n */\n allChildrenAreInherited: boolean;\n\n /**\n * Are all children private members?\n */\n allChildrenArePrivate: boolean;\n\n /**\n * Are all children private or protected members?\n */\n allChildrenAreProtectedOrPrivate: boolean;\n\n /**\n * Are all children external members?\n */\n allChildrenAreExternal: boolean;\n\n /**\n * Are any children exported declarations?\n */\n someChildrenAreExported: boolean;\n\n /**\n * Create a new ReflectionGroup instance.\n *\n * @param title The title of this group.\n * @param kind The original typescript kind of the children of this group.\n */\n constructor(title: string, kind: ReflectionKind) {\n this.title = title;\n this.kind = kind;\n\n this.allChildrenHaveOwnDocument = (() => this.getAllChildrenHaveOwnDocument());\n }\n\n /**\n * Do all children of this group have a separate document?\n */\n private getAllChildrenHaveOwnDocument(): boolean {\n let onlyOwnDocuments = true;\n this.children.forEach((child) => {\n onlyOwnDocuments = onlyOwnDocuments && child.hasOwnDocument;\n });\n\n return onlyOwnDocuments;\n }\n\n /**\n * Return a raw object representation of this reflection group.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result = {\n title: this.title,\n kind: this.kind\n };\n\n if (this.children) {\n const children: any[] = [];\n this.children.forEach((child) => {\n children.push(child.id);\n });\n\n result['children'] = children;\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/comments/comment.d.ts b/dist/lib/models/comments/comment.d.ts new file mode 100644 index 000000000..4430a9bd1 --- /dev/null +++ b/dist/lib/models/comments/comment.d.ts @@ -0,0 +1,13 @@ +import { CommentTag } from './tag'; +export declare class Comment { + shortText: string; + text: string; + returns: string; + tags: CommentTag[]; + constructor(shortText?: string, text?: string); + hasVisibleComponent(): boolean; + hasTag(tagName: string): boolean; + getTag(tagName: string, paramName?: string): CommentTag; + copyFrom(comment: Comment): void; + toObject(): any; +} diff --git a/dist/lib/models/comments/comment.js b/dist/lib/models/comments/comment.js new file mode 100644 index 000000000..fb7ce7eab --- /dev/null +++ b/dist/lib/models/comments/comment.js @@ -0,0 +1,61 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var tag_1 = require("./tag"); +var Comment = (function () { + function Comment(shortText, text) { + this.shortText = shortText || ''; + this.text = text || ''; + } + Comment.prototype.hasVisibleComponent = function () { + return (!!this.shortText || !!this.text || !!this.tags); + }; + Comment.prototype.hasTag = function (tagName) { + if (!this.tags) { + return false; + } + for (var i = 0, c = this.tags.length; i < c; i++) { + if (this.tags[i].tagName === tagName) { + return true; + } + } + return false; + }; + Comment.prototype.getTag = function (tagName, paramName) { + if (!this.tags) { + return null; + } + for (var i = 0, c = this.tags.length; i < c; i++) { + var tag = this.tags[i]; + if (tag.tagName === tagName && (paramName === void 0 || tag.paramName === paramName)) { + return this.tags[i]; + } + } + return null; + }; + Comment.prototype.copyFrom = function (comment) { + this.shortText = comment.shortText; + this.text = comment.text; + this.returns = comment.returns; + this.tags = comment.tags ? comment.tags.map(function (tag) { return new tag_1.CommentTag(tag.tagName, tag.paramName, tag.text); }) : null; + }; + Comment.prototype.toObject = function () { + var result = {}; + if (this.shortText) { + result.shortText = this.shortText; + } + if (this.text) { + result.text = this.text; + } + if (this.returns) { + result.returns = this.returns; + } + if (this.tags && this.tags.length) { + result.tags = []; + this.tags.forEach(function (tag) { return result.tags.push(tag.toObject()); }); + } + return result; + }; + return Comment; +}()); +exports.Comment = Comment; +//# sourceMappingURL=comment.js.map \ No newline at end of file diff --git a/dist/lib/models/comments/comment.js.map b/dist/lib/models/comments/comment.js.map new file mode 100644 index 000000000..211a01e70 --- /dev/null +++ b/dist/lib/models/comments/comment.js.map @@ -0,0 +1 @@ +{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../../src/lib/models/comments/comment.ts"],"names":[],"mappings":";;AAAA,6BAAmC;AAQnC;IAyBI,iBAAY,SAAkB,EAAE,IAAa;QACzC,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,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I,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAhC,CAAgC,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,cAAC;AAAD,CAAC,AAlHD,IAkHC;AAlHY,0BAAO","sourcesContent":["import { CommentTag } from './tag';\n\n/**\n * A model that represents a javadoc comment.\n *\n * Instances of this model are created by the [[CommentHandler]]. You can retrieve comments\n * through the [[BaseReflection.comment]] property.\n */\nexport class Comment {\n /**\n * The abstract of the comment. TypeDoc interprets the first paragraph of a comment\n * as the abstract.\n */\n shortText: string;\n\n /**\n * The full body text of the comment. Excludes the [[shortText]].\n */\n text: string;\n\n /**\n * The text of the ```@returns``` tag if present.\n */\n returns: string;\n\n /**\n * All associated javadoc tags.\n */\n tags: CommentTag[];\n\n /**\n * Creates a new Comment instance.\n */\n constructor(shortText?: string, text?: string) {\n this.shortText = shortText || '';\n this.text = text || '';\n }\n\n /**\n * Has this comment a visible component?\n *\n * @returns TRUE when this comment has a visible component.\n */\n hasVisibleComponent(): boolean {\n return (!!this.shortText || !!this.text || !!this.tags);\n }\n\n /**\n * Test whether this comment contains a tag with the given name.\n *\n * @param tagName The name of the tag to look for.\n * @returns TRUE when this comment contains a tag with the given name, otherwise FALSE.\n */\n hasTag(tagName: string): boolean {\n if (!this.tags) {\n return false;\n }\n for (let i = 0, c = this.tags.length; i < c; i++) {\n if (this.tags[i].tagName === tagName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Return the first tag with the given name.\n *\n * You can optionally pass a parameter name that should be searched to.\n *\n * @param tagName The name of the tag to look for.\n * @param paramName An optional parameter name to look for.\n * @returns The found tag or NULL.\n */\n getTag(tagName: string, paramName?: string): CommentTag {\n if (!this.tags) {\n return null;\n }\n for (let i = 0, c = this.tags.length; i < c; i++) {\n const tag = this.tags[i];\n if (tag.tagName === tagName && (paramName === void 0 || tag.paramName === paramName)) {\n return this.tags[i];\n }\n }\n return null;\n }\n\n /**\n * Copy the data of the given comment into this comment.\n *\n * @param comment\n */\n copyFrom(comment: Comment) {\n this.shortText = comment.shortText;\n this.text = comment.text;\n this.returns = comment.returns;\n this.tags = comment.tags ? comment.tags.map((tag) => new CommentTag(tag.tagName, tag.paramName, tag.text)) : null;\n }\n\n /**\n * Return a raw object representation of this comment.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = {};\n if (this.shortText) {\n result.shortText = this.shortText;\n }\n if (this.text) {\n result.text = this.text;\n }\n if (this.returns) {\n result.returns = this.returns;\n }\n\n if (this.tags && this.tags.length) {\n result.tags = [];\n this.tags.forEach((tag) => result.tags.push(tag.toObject()));\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/comments/index.d.ts b/dist/lib/models/comments/index.d.ts new file mode 100644 index 000000000..2d0d751ca --- /dev/null +++ b/dist/lib/models/comments/index.d.ts @@ -0,0 +1,2 @@ +export { Comment } from './comment'; +export { CommentTag } from './tag'; diff --git a/dist/lib/models/comments/index.js b/dist/lib/models/comments/index.js new file mode 100644 index 000000000..76a9e9c3f --- /dev/null +++ b/dist/lib/models/comments/index.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var comment_1 = require("./comment"); +exports.Comment = comment_1.Comment; +var tag_1 = require("./tag"); +exports.CommentTag = tag_1.CommentTag; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/models/comments/index.js.map b/dist/lib/models/comments/index.js.map new file mode 100644 index 000000000..aa658fd15 --- /dev/null +++ b/dist/lib/models/comments/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/models/comments/index.ts"],"names":[],"mappings":";;AAAA,qCAAoC;AAA3B,4BAAA,OAAO,CAAA;AAChB,6BAAmC;AAA1B,2BAAA,UAAU,CAAA","sourcesContent":["export { Comment } from './comment';\nexport { CommentTag } from './tag';\n"]} \ No newline at end of file diff --git a/dist/lib/models/comments/tag.d.ts b/dist/lib/models/comments/tag.d.ts new file mode 100644 index 000000000..0bfe05a2b --- /dev/null +++ b/dist/lib/models/comments/tag.d.ts @@ -0,0 +1,7 @@ +export declare class CommentTag { + tagName: string; + paramName: string; + text: string; + constructor(tagName: string, paramName?: string, text?: string); + toObject(): any; +} diff --git a/dist/lib/models/comments/tag.js b/dist/lib/models/comments/tag.js new file mode 100644 index 000000000..1569e46be --- /dev/null +++ b/dist/lib/models/comments/tag.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var CommentTag = (function () { + function CommentTag(tagName, paramName, text) { + this.tagName = tagName; + this.paramName = paramName || ''; + this.text = text || ''; + } + CommentTag.prototype.toObject = function () { + var result = { + tag: this.tagName, + text: this.text + }; + if (this.paramName) { + result.param = this.paramName; + } + return result; + }; + return CommentTag; +}()); +exports.CommentTag = CommentTag; +//# sourceMappingURL=tag.js.map \ No newline at end of file diff --git a/dist/lib/models/comments/tag.js.map b/dist/lib/models/comments/tag.js.map new file mode 100644 index 000000000..845388cf9 --- /dev/null +++ b/dist/lib/models/comments/tag.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tag.js","sourceRoot":"","sources":["../../../../src/lib/models/comments/tag.ts"],"names":[],"mappings":";;AAKA;IAmBI,oBAAY,OAAe,EAAE,SAAkB,EAAE,IAAa;QAC1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IAC3B,CAAC;IAMD,6BAAQ,GAAR;QACI,IAAM,MAAM,GAAQ;YAChB,GAAG,EAAG,IAAI,CAAC,OAAO;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;SAClB,CAAC;QAEF,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YACjB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAClC,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,iBAAC;AAAD,CAAC,AAzCD,IAyCC;AAzCY,gCAAU","sourcesContent":["/**\n * A model that represents a single javadoc comment tag.\n *\n * Tags are stored in the [[Comment.tags]] property.\n */\nexport class CommentTag {\n /**\n * The name of this tag.\n */\n tagName: string;\n\n /**\n * The name of the related parameter when this is a ```@param``` tag.\n */\n paramName: string;\n\n /**\n * The actual body text of this tag.\n */\n text: string;\n\n /**\n * Create a new CommentTag instance.\n */\n constructor(tagName: string, paramName?: string, text?: string) {\n this.tagName = tagName;\n this.paramName = paramName || '';\n this.text = text || '';\n }\n\n /**\n * Return a raw object representation of this tag.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = {\n tag: this.tagName,\n text: this.text\n };\n\n if (this.paramName) {\n result.param = this.paramName;\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/index.d.ts b/dist/lib/models/index.d.ts new file mode 100644 index 000000000..da48d254d --- /dev/null +++ b/dist/lib/models/index.d.ts @@ -0,0 +1,4 @@ +export * from './reflections/index'; +export * from './types/index'; +export * from './comments/index'; +export * from './sources/index'; diff --git a/dist/lib/models/index.js b/dist/lib/models/index.js new file mode 100644 index 000000000..c3135c6c7 --- /dev/null +++ b/dist/lib/models/index.js @@ -0,0 +1,10 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./reflections/index")); +__export(require("./types/index")); +__export(require("./comments/index")); +__export(require("./sources/index")); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/models/index.js.map b/dist/lib/models/index.js.map new file mode 100644 index 000000000..677fc03a4 --- /dev/null +++ b/dist/lib/models/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/models/index.ts"],"names":[],"mappings":";;;;;AAAA,yCAAoC;AACpC,mCAA8B;AAC9B,sCAAiC;AACjC,qCAAgC","sourcesContent":["export * from './reflections/index';\nexport * from './types/index';\nexport * from './comments/index';\nexport * from './sources/index';\n"]} \ No newline at end of file diff --git a/dist/lib/models/reflections/abstract.d.ts b/dist/lib/models/reflections/abstract.d.ts new file mode 100644 index 000000000..138ba4887 --- /dev/null +++ b/dist/lib/models/reflections/abstract.d.ts @@ -0,0 +1,131 @@ +import { SourceReference } from '../sources/file'; +import { Type } from '../types/index'; +import { Comment } from '../comments/comment'; +import { TypeParameterReflection } from './type-parameter'; +export declare function resetReflectionID(): void; +export declare enum ReflectionKind { + Global = 0, + ExternalModule = 1, + Module = 2, + Enum = 4, + EnumMember = 16, + Variable = 32, + Function = 64, + Class = 128, + Interface = 256, + Constructor = 512, + Property = 1024, + Method = 2048, + CallSignature = 4096, + IndexSignature = 8192, + ConstructorSignature = 16384, + Parameter = 32768, + TypeLiteral = 65536, + TypeParameter = 131072, + Accessor = 262144, + GetSignature = 524288, + SetSignature = 1048576, + ObjectLiteral = 2097152, + TypeAlias = 4194304, + Event = 8388608, + ClassOrInterface = 384, + VariableOrProperty = 1056, + FunctionOrMethod = 2112, + SomeSignature = 1601536, + SomeModule = 3, +} +export declare enum ReflectionFlag { + Private = 1, + Protected = 2, + Public = 4, + Static = 8, + Exported = 16, + ExportAssignment = 32, + External = 64, + Optional = 128, + DefaultValue = 256, + Rest = 512, + ConstructorProperty = 1024, + Abstract = 2048, + Const = 4096, + Let = 8192, +} +export interface ReflectionFlags extends Array { + flags?: ReflectionFlag; + isPrivate?: boolean; + isProtected?: boolean; + isPublic?: boolean; + isStatic?: boolean; + isExported?: boolean; + isExternal?: boolean; + isOptional?: boolean; + isRest?: boolean; + hasExportAssignment?: boolean; + isConstructorProperty?: boolean; + isAbstract?: boolean; + isConst?: boolean; + isLet?: boolean; +} +export interface DefaultValueContainer extends Reflection { + defaultValue: string; +} +export interface TypeContainer extends Reflection { + type: Type; +} +export interface TypeParameterContainer extends Reflection { + typeParameters: TypeParameterReflection[]; +} +export declare enum TraverseProperty { + Children = 0, + Parameters = 1, + TypeLiteral = 2, + TypeParameter = 3, + Signatures = 4, + IndexSignature = 5, + GetSignature = 6, + SetSignature = 7, +} +export interface TraverseCallback { + (reflection: Reflection, property: TraverseProperty): void; +} +export interface Decorator { + name: string; + type?: Type; + arguments?: any; +} +export declare abstract class Reflection { + id: number; + name: string; + originalName: string; + kind: ReflectionKind; + kindString: string; + flags: ReflectionFlags; + parent: Reflection; + comment: Comment; + sources: SourceReference[]; + decorators: Decorator[]; + decorates: Type[]; + url: string; + anchor: string; + hasOwnDocument: boolean; + cssClasses: string; + private _alias; + private _aliases; + constructor(parent?: Reflection, name?: string, kind?: ReflectionKind); + kindOf(kind: ReflectionKind): boolean; + kindOf(kind: ReflectionKind[]): boolean; + getFullName(separator?: string): string; + setFlag(flag: ReflectionFlag, value?: boolean): void; + getAlias(): string; + hasComment(): boolean; + hasGetterOrSetter(): boolean; + getChildByName(name: string): Reflection; + getChildByName(names: string[]): Reflection; + isProject(): boolean; + findReflectionByName(name: string): Reflection; + findReflectionByName(names: string[]): Reflection; + traverse(callback: TraverseCallback): void; + toObject(): any; + toString(): string; + toStringHierarchy(indent?: string): string; +} diff --git a/dist/lib/models/reflections/abstract.js b/dist/lib/models/reflections/abstract.js new file mode 100644 index 000000000..ff2454007 --- /dev/null +++ b/dist/lib/models/reflections/abstract.js @@ -0,0 +1,310 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var REFLECTION_ID = 0; +function resetReflectionID() { + REFLECTION_ID = 0; +} +exports.resetReflectionID = resetReflectionID; +var ReflectionKind; +(function (ReflectionKind) { + ReflectionKind[ReflectionKind["Global"] = 0] = "Global"; + ReflectionKind[ReflectionKind["ExternalModule"] = 1] = "ExternalModule"; + ReflectionKind[ReflectionKind["Module"] = 2] = "Module"; + ReflectionKind[ReflectionKind["Enum"] = 4] = "Enum"; + ReflectionKind[ReflectionKind["EnumMember"] = 16] = "EnumMember"; + ReflectionKind[ReflectionKind["Variable"] = 32] = "Variable"; + ReflectionKind[ReflectionKind["Function"] = 64] = "Function"; + ReflectionKind[ReflectionKind["Class"] = 128] = "Class"; + ReflectionKind[ReflectionKind["Interface"] = 256] = "Interface"; + ReflectionKind[ReflectionKind["Constructor"] = 512] = "Constructor"; + ReflectionKind[ReflectionKind["Property"] = 1024] = "Property"; + ReflectionKind[ReflectionKind["Method"] = 2048] = "Method"; + ReflectionKind[ReflectionKind["CallSignature"] = 4096] = "CallSignature"; + ReflectionKind[ReflectionKind["IndexSignature"] = 8192] = "IndexSignature"; + ReflectionKind[ReflectionKind["ConstructorSignature"] = 16384] = "ConstructorSignature"; + ReflectionKind[ReflectionKind["Parameter"] = 32768] = "Parameter"; + ReflectionKind[ReflectionKind["TypeLiteral"] = 65536] = "TypeLiteral"; + ReflectionKind[ReflectionKind["TypeParameter"] = 131072] = "TypeParameter"; + ReflectionKind[ReflectionKind["Accessor"] = 262144] = "Accessor"; + ReflectionKind[ReflectionKind["GetSignature"] = 524288] = "GetSignature"; + ReflectionKind[ReflectionKind["SetSignature"] = 1048576] = "SetSignature"; + ReflectionKind[ReflectionKind["ObjectLiteral"] = 2097152] = "ObjectLiteral"; + ReflectionKind[ReflectionKind["TypeAlias"] = 4194304] = "TypeAlias"; + ReflectionKind[ReflectionKind["Event"] = 8388608] = "Event"; + ReflectionKind[ReflectionKind["ClassOrInterface"] = 384] = "ClassOrInterface"; + ReflectionKind[ReflectionKind["VariableOrProperty"] = 1056] = "VariableOrProperty"; + ReflectionKind[ReflectionKind["FunctionOrMethod"] = 2112] = "FunctionOrMethod"; + ReflectionKind[ReflectionKind["SomeSignature"] = 1601536] = "SomeSignature"; + ReflectionKind[ReflectionKind["SomeModule"] = 3] = "SomeModule"; +})(ReflectionKind = exports.ReflectionKind || (exports.ReflectionKind = {})); +var ReflectionFlag; +(function (ReflectionFlag) { + ReflectionFlag[ReflectionFlag["Private"] = 1] = "Private"; + ReflectionFlag[ReflectionFlag["Protected"] = 2] = "Protected"; + ReflectionFlag[ReflectionFlag["Public"] = 4] = "Public"; + ReflectionFlag[ReflectionFlag["Static"] = 8] = "Static"; + ReflectionFlag[ReflectionFlag["Exported"] = 16] = "Exported"; + ReflectionFlag[ReflectionFlag["ExportAssignment"] = 32] = "ExportAssignment"; + ReflectionFlag[ReflectionFlag["External"] = 64] = "External"; + ReflectionFlag[ReflectionFlag["Optional"] = 128] = "Optional"; + ReflectionFlag[ReflectionFlag["DefaultValue"] = 256] = "DefaultValue"; + ReflectionFlag[ReflectionFlag["Rest"] = 512] = "Rest"; + ReflectionFlag[ReflectionFlag["ConstructorProperty"] = 1024] = "ConstructorProperty"; + ReflectionFlag[ReflectionFlag["Abstract"] = 2048] = "Abstract"; + ReflectionFlag[ReflectionFlag["Const"] = 4096] = "Const"; + ReflectionFlag[ReflectionFlag["Let"] = 8192] = "Let"; +})(ReflectionFlag = exports.ReflectionFlag || (exports.ReflectionFlag = {})); +var relevantFlags = [ + ReflectionFlag.Private, + ReflectionFlag.Protected, + ReflectionFlag.Static, + ReflectionFlag.ExportAssignment, + ReflectionFlag.Optional, + ReflectionFlag.DefaultValue, + ReflectionFlag.Rest, + ReflectionFlag.Abstract, + ReflectionFlag.Let, + ReflectionFlag.Const +]; +var TraverseProperty; +(function (TraverseProperty) { + TraverseProperty[TraverseProperty["Children"] = 0] = "Children"; + TraverseProperty[TraverseProperty["Parameters"] = 1] = "Parameters"; + TraverseProperty[TraverseProperty["TypeLiteral"] = 2] = "TypeLiteral"; + TraverseProperty[TraverseProperty["TypeParameter"] = 3] = "TypeParameter"; + TraverseProperty[TraverseProperty["Signatures"] = 4] = "Signatures"; + TraverseProperty[TraverseProperty["IndexSignature"] = 5] = "IndexSignature"; + TraverseProperty[TraverseProperty["GetSignature"] = 6] = "GetSignature"; + TraverseProperty[TraverseProperty["SetSignature"] = 7] = "SetSignature"; +})(TraverseProperty = exports.TraverseProperty || (exports.TraverseProperty = {})); +var Reflection = (function () { + function Reflection(parent, name, kind) { + this.name = ''; + this.flags = []; + this.id = REFLECTION_ID++; + this.parent = parent; + this.name = name; + this.originalName = name; + this.kind = kind; + } + Reflection.prototype.kindOf = function (kind) { + if (Array.isArray(kind)) { + for (var i = 0, c = kind.length; i < c; i++) { + if ((this.kind & kind[i]) !== 0) { + return true; + } + } + return false; + } + else { + return (this.kind & kind) !== 0; + } + }; + Reflection.prototype.getFullName = function (separator) { + if (separator === void 0) { separator = '.'; } + if (this.parent && !this.parent.isProject()) { + return this.parent.getFullName(separator) + separator + this.name; + } + else { + return this.name; + } + }; + Reflection.prototype.setFlag = function (flag, value) { + if (value === void 0) { value = true; } + var name, index; + if (relevantFlags.indexOf(flag) !== -1) { + name = ReflectionFlag[flag]; + name = name.replace(/(.)([A-Z])/g, function (m, a, b) { return a + ' ' + b.toLowerCase(); }); + index = this.flags.indexOf(name); + } + if (value) { + this.flags.flags |= flag; + if (name && index === -1) { + this.flags.push(name); + } + } + else { + this.flags.flags &= ~flag; + if (name && index !== -1) { + this.flags.splice(index, 1); + } + } + switch (flag) { + case ReflectionFlag.Private: + this.flags.isPrivate = value; + if (value) { + this.setFlag(ReflectionFlag.Protected, false); + this.setFlag(ReflectionFlag.Public, false); + } + break; + case ReflectionFlag.Protected: + this.flags.isProtected = value; + if (value) { + this.setFlag(ReflectionFlag.Private, false); + this.setFlag(ReflectionFlag.Public, false); + } + break; + case ReflectionFlag.Public: + this.flags.isPublic = value; + if (value) { + this.setFlag(ReflectionFlag.Private, false); + this.setFlag(ReflectionFlag.Protected, false); + } + break; + case ReflectionFlag.Static: + this.flags.isStatic = value; + break; + case ReflectionFlag.Exported: + this.flags.isExported = value; + break; + case ReflectionFlag.External: + this.flags.isExternal = value; + break; + case ReflectionFlag.Optional: + this.flags.isOptional = value; + break; + case ReflectionFlag.Rest: + this.flags.isRest = value; + break; + case ReflectionFlag.ExportAssignment: + this.flags.hasExportAssignment = value; + break; + case ReflectionFlag.ConstructorProperty: + this.flags.isConstructorProperty = value; + break; + case ReflectionFlag.Abstract: + this.flags.isAbstract = value; + break; + case ReflectionFlag.Let: + this.flags.isLet = value; + break; + case ReflectionFlag.Const: + this.flags.isConst = value; + break; + } + }; + Reflection.prototype.getAlias = function () { + if (!this._alias) { + var alias = this.name.replace(/[^a-z0-9]/gi, '_').toLowerCase(); + if (alias === '') { + alias = 'reflection-' + this.id; + } + var target = this; + while (target.parent && !target.parent.isProject() && !target.hasOwnDocument) { + target = target.parent; + } + if (!target._aliases) { + target._aliases = []; + } + var suffix = '', index = 0; + while (target._aliases.indexOf(alias + suffix) !== -1) { + suffix = '-' + (++index).toString(); + } + alias += suffix; + target._aliases.push(alias); + this._alias = alias; + } + return this._alias; + }; + Reflection.prototype.hasComment = function () { + return (this.comment && this.comment.hasVisibleComponent()); + }; + Reflection.prototype.hasGetterOrSetter = function () { + return false; + }; + Reflection.prototype.getChildByName = function (arg) { + var names = Array.isArray(arg) ? arg : arg.split('.'); + var name = names[0]; + var result = null; + this.traverse(function (child) { + if (child.name === name) { + if (names.length <= 1) { + result = child; + } + else if (child) { + result = child.getChildByName(names.slice(1)); + } + } + }); + return result; + }; + Reflection.prototype.isProject = function () { + return false; + }; + Reflection.prototype.findReflectionByName = function (arg) { + var names = Array.isArray(arg) ? arg : arg.split('.'); + var reflection = this.getChildByName(names); + if (reflection) { + return reflection; + } + else { + return this.parent.findReflectionByName(names); + } + }; + Reflection.prototype.traverse = function (callback) { }; + Reflection.prototype.toObject = function () { + var result = { + id: this.id, + name: this.name, + kind: this.kind, + kindString: this.kindString, + flags: {} + }; + if (this.originalName !== this.name) { + result.originalName = this.originalName; + } + if (this.comment) { + result.comment = this.comment.toObject(); + } + for (var key in this.flags) { + if (parseInt(key, 10) == key || key === 'flags') { + continue; + } + if (this.flags[key]) { + result.flags[key] = true; + } + } + if (this.decorates) { + result.decorates = this.decorates.map(function (type) { return type.toObject(); }); + } + if (this.decorators) { + result.decorators = this.decorators.map(function (decorator) { + var result = { name: decorator.name }; + if (decorator.type) { + result.type = decorator.type.toObject(); + } + if (decorator.arguments) { + result.arguments = decorator.arguments; + } + return result; + }); + } + this.traverse(function (child, property) { + if (property === TraverseProperty.TypeLiteral) { + return; + } + var name = TraverseProperty[property]; + name = name.substr(0, 1).toLowerCase() + name.substr(1); + if (!result[name]) { + result[name] = []; + } + result[name].push(child.toObject()); + }); + return result; + }; + Reflection.prototype.toString = function () { + return ReflectionKind[this.kind] + ' ' + this.name; + }; + Reflection.prototype.toStringHierarchy = function (indent) { + if (indent === void 0) { indent = ''; } + var lines = [indent + this.toString()]; + indent += ' '; + this.traverse(function (child, property) { + lines.push(child.toStringHierarchy(indent)); + }); + return lines.join('\n'); + }; + return Reflection; +}()); +exports.Reflection = Reflection; +//# sourceMappingURL=abstract.js.map \ No newline at end of file diff --git a/dist/lib/models/reflections/abstract.js.map b/dist/lib/models/reflections/abstract.js.map new file mode 100644 index 000000000..66b0905a0 --- /dev/null +++ b/dist/lib/models/reflections/abstract.js.map @@ -0,0 +1 @@ +{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/abstract.ts"],"names":[],"mappings":";;AAoBA,IAAI,aAAa,GAAG,CAAC,CAAC;AAOtB;IACI,aAAa,GAAG,CAAC,CAAC;AACtB,CAAC;AAFD,8CAEC;AAKD,IAAY,cA+BX;AA/BD,WAAY,cAAc;IACtB,uDAAU,CAAA;IACV,uEAAkB,CAAA;IAClB,uDAAU,CAAA;IACV,mDAAQ,CAAA;IACR,gEAAe,CAAA;IACf,4DAAa,CAAA;IACb,4DAAa,CAAA;IACb,uDAAW,CAAA;IACX,+DAAe,CAAA;IACf,mEAAiB,CAAA;IACjB,8DAAe,CAAA;IACf,0DAAa,CAAA;IACb,wEAAoB,CAAA;IACpB,0EAAqB,CAAA;IACrB,uFAA4B,CAAA;IAC5B,iEAAiB,CAAA;IACjB,qEAAmB,CAAA;IACnB,0EAAsB,CAAA;IACtB,gEAAiB,CAAA;IACjB,wEAAqB,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cesContent":["import { SourceReference } from '../sources/file';\nimport { Type } from '../types/index';\nimport { Comment } from '../comments/comment';\nimport { TypeParameterReflection } from './type-parameter';\n\n/**\n * Holds all data models used by TypeDoc.\n *\n * The [[BaseReflection]] is base class of all reflection models. The subclass [[ProjectReflection]]\n * serves as the root container for the current project while [[DeclarationReflection]] instances\n * form the structure of the project. Most of the other classes in this namespace are referenced by this\n * two base classes.\n *\n * The models [[NavigationItem]] and [[UrlMapping]] are special as they are only used by the [[Renderer]]\n * while creating the final output.\n */\n\n/**\n * Current reflection id.\n */\nlet REFLECTION_ID = 0;\n\n/**\n * Reset the reflection id.\n *\n * Used by the test cases to ensure the reflection ids won't change between runs.\n */\nexport function resetReflectionID() {\n REFLECTION_ID = 0;\n}\n\n/**\n * Defines the available reflection kinds.\n */\nexport enum ReflectionKind {\n Global = 0,\n ExternalModule = 1,\n Module = 2,\n Enum = 4,\n EnumMember = 16,\n Variable = 32,\n Function = 64,\n Class = 128,\n Interface = 256,\n Constructor = 512,\n Property = 1024,\n Method = 2048,\n CallSignature = 4096,\n IndexSignature = 8192,\n ConstructorSignature = 16384,\n Parameter = 32768,\n TypeLiteral = 65536,\n TypeParameter = 131072,\n Accessor = 262144,\n GetSignature = 524288,\n SetSignature = 1048576,\n ObjectLiteral = 2097152,\n TypeAlias = 4194304,\n Event = 8388608,\n\n ClassOrInterface = Class | Interface,\n VariableOrProperty = Variable | Property,\n FunctionOrMethod = Function | Method,\n SomeSignature = CallSignature | IndexSignature | ConstructorSignature | GetSignature | SetSignature,\n SomeModule = Module | ExternalModule\n}\n\nexport enum ReflectionFlag {\n Private = 1,\n Protected = 2,\n Public = 4,\n Static = 8,\n Exported = 16,\n ExportAssignment = 32,\n External = 64,\n Optional = 128,\n DefaultValue = 256,\n Rest = 512,\n ConstructorProperty = 1024,\n Abstract = 2048,\n Const = 4096,\n Let = 8192\n}\n\nconst relevantFlags: ReflectionFlag[] = [\n ReflectionFlag.Private,\n ReflectionFlag.Protected,\n ReflectionFlag.Static,\n ReflectionFlag.ExportAssignment,\n ReflectionFlag.Optional,\n ReflectionFlag.DefaultValue,\n ReflectionFlag.Rest,\n ReflectionFlag.Abstract,\n ReflectionFlag.Let,\n ReflectionFlag.Const\n];\n\nexport interface ReflectionFlags extends Array {\n flags?: ReflectionFlag;\n\n /**\n * Is this a private member?\n */\n isPrivate?: boolean;\n\n /**\n * Is this a protected member?\n */\n isProtected?: boolean;\n\n /**\n * Is this a public member?\n */\n isPublic?: boolean;\n\n /**\n * Is this a static member?\n */\n isStatic?: boolean;\n\n /**\n * Is this member exported?\n */\n isExported?: boolean;\n\n /**\n * Is this a declaration from an external document?\n */\n isExternal?: boolean;\n\n /**\n * Whether this reflection is an optional component or not.\n *\n * Applies to function parameters and object members.\n */\n isOptional?: boolean;\n\n /**\n * Whether it's a rest parameter, like `foo(...params);`.\n */\n isRest?: boolean;\n\n /**\n *\n */\n hasExportAssignment?: boolean;\n\n isConstructorProperty?: boolean;\n\n isAbstract?: boolean;\n\n isConst?: boolean;\n\n isLet?: boolean;\n}\n\nexport interface DefaultValueContainer extends Reflection {\n defaultValue: string;\n}\n\nexport interface TypeContainer extends Reflection {\n type: Type;\n}\n\nexport interface TypeParameterContainer extends Reflection {\n typeParameters: TypeParameterReflection[];\n}\n\nexport enum TraverseProperty {\n Children,\n Parameters,\n TypeLiteral,\n TypeParameter,\n Signatures,\n IndexSignature,\n GetSignature,\n SetSignature\n}\n\nexport interface TraverseCallback {\n (reflection: Reflection, property: TraverseProperty): void;\n}\n\n/**\n * Defines the usage of a decorator.\n */\nexport interface Decorator {\n /**\n * The name of the decorator being applied.\n */\n name: string;\n\n /**\n * The type declaring the decorator.\n * Usually a ReferenceType instance pointing to the decorator function.\n */\n type?: Type;\n\n /**\n * A named map of arguments the decorator is applied with.\n */\n arguments?: any;\n}\n\n/**\n * Base class for all reflection classes.\n *\n * While generating a documentation, TypeDoc generates an instance of [[ProjectReflection]]\n * as the root for all reflections within the project. All other reflections are represented\n * by the [[DeclarationReflection]] class.\n *\n * This base class exposes the basic properties one may use to traverse the reflection tree.\n * You can use the [[children]] and [[parent]] properties to walk the tree. The [[groups]] property\n * contains a list of all children grouped and sorted for being rendered.\n */\nexport abstract class Reflection {\n /**\n * Unique id of this reflection.\n */\n id: number;\n\n /**\n * The symbol name of this reflection.\n */\n name = '';\n\n /**\n * The original name of the TypeScript declaration.\n */\n originalName: string;\n\n /**\n * The kind of this reflection.\n */\n kind: ReflectionKind;\n\n /**\n * The human readable string representation of the kind of this reflection.\n */\n kindString: string;\n\n flags: ReflectionFlags = [];\n\n /**\n * The reflection this reflection is a child of.\n */\n parent: Reflection;\n\n /**\n * The parsed documentation comment attached to this reflection.\n */\n comment: Comment;\n\n /**\n * A list of all source files that contributed to this reflection.\n */\n sources: SourceReference[];\n\n /**\n * A list of all decorators attached to this reflection.\n */\n decorators: Decorator[];\n\n /**\n * A list of all types that are decorated by this reflection.\n */\n decorates: Type[];\n\n /**\n * The url of this reflection in the generated documentation.\n */\n url: string;\n\n /**\n * The name of the anchor of this child.\n */\n anchor: string;\n\n /**\n * Is the url pointing to an individual document?\n *\n * When FALSE, the url points to an anchor tag on a page of a different reflection.\n */\n hasOwnDocument: boolean;\n\n /**\n * A list of generated css classes that should be applied to representations of this\n * reflection in the generated markup.\n */\n cssClasses: string;\n\n /**\n * Url safe alias for this reflection.\n *\n * @see [[BaseReflection.getAlias]]\n */\n private _alias: string;\n\n private _aliases: string[];\n\n /**\n * Create a new BaseReflection instance.\n */\n constructor(parent?: Reflection, name?: string, kind?: ReflectionKind) {\n this.id = REFLECTION_ID++;\n this.parent = parent;\n this.name = name;\n this.originalName = name;\n this.kind = kind;\n }\n\n /**\n * @param kind The kind to test for.\n */\n kindOf(kind: ReflectionKind): boolean;\n\n /**\n * @param kind An array of kinds to test for.\n */\n kindOf(kind: ReflectionKind[]): boolean;\n\n /**\n * Test whether this reflection is of the given kind.\n */\n kindOf(kind: any): boolean {\n if (Array.isArray(kind)) {\n for (let i = 0, c = kind.length; i < c; i++) {\n if ((this.kind & kind[i]) !== 0) {\n return true;\n }\n }\n return false;\n } else {\n return (this.kind & kind) !== 0;\n }\n }\n\n /**\n * Return the full name of this reflection.\n *\n * The full name contains the name of this reflection and the names of all parent reflections.\n *\n * @param separator Separator used to join the names of the reflections.\n * @returns The full name of this reflection.\n */\n getFullName(separator: string = '.'): string {\n if (this.parent && !this.parent.isProject()) {\n return this.parent.getFullName(separator) + separator + this.name;\n } else {\n return this.name;\n }\n }\n\n /**\n * Set a flag on this reflection.\n */\n setFlag(flag: ReflectionFlag, value: boolean = true) {\n let name: string, index: number;\n if (relevantFlags.indexOf(flag) !== -1) {\n name = ReflectionFlag[flag];\n name = name.replace(/(.)([A-Z])/g, (m, a, b) => a + ' ' + b.toLowerCase());\n index = this.flags.indexOf(name);\n }\n\n if (value) {\n this.flags.flags |= flag;\n if (name && index === -1) {\n this.flags.push(name);\n }\n } else {\n this.flags.flags &= ~flag;\n if (name && index !== -1) {\n this.flags.splice(index, 1);\n }\n }\n\n switch (flag) {\n case ReflectionFlag.Private:\n this.flags.isPrivate = value;\n if (value) {\n this.setFlag(ReflectionFlag.Protected, false);\n this.setFlag(ReflectionFlag.Public, false);\n }\n break;\n case ReflectionFlag.Protected:\n this.flags.isProtected = value;\n if (value) {\n this.setFlag(ReflectionFlag.Private, false);\n this.setFlag(ReflectionFlag.Public, false);\n }\n break;\n case ReflectionFlag.Public:\n this.flags.isPublic = value;\n if (value) {\n this.setFlag(ReflectionFlag.Private, false);\n this.setFlag(ReflectionFlag.Protected, false);\n }\n break;\n case ReflectionFlag.Static:\n this.flags.isStatic = value;\n break;\n case ReflectionFlag.Exported:\n this.flags.isExported = value;\n break;\n case ReflectionFlag.External:\n this.flags.isExternal = value;\n break;\n case ReflectionFlag.Optional:\n this.flags.isOptional = value;\n break;\n case ReflectionFlag.Rest:\n this.flags.isRest = value;\n break;\n case ReflectionFlag.ExportAssignment:\n this.flags.hasExportAssignment = value;\n break;\n case ReflectionFlag.ConstructorProperty:\n this.flags.isConstructorProperty = value;\n break;\n case ReflectionFlag.Abstract:\n this.flags.isAbstract = value;\n break;\n case ReflectionFlag.Let:\n this.flags.isLet = value;\n break;\n case ReflectionFlag.Const:\n this.flags.isConst = value;\n break;\n }\n }\n\n /**\n * Return an url safe alias for this reflection.\n */\n getAlias(): string {\n if (!this._alias) {\n let alias = this.name.replace(/[^a-z0-9]/gi, '_').toLowerCase();\n if (alias === '') {\n alias = 'reflection-' + this.id;\n }\n\n let target = this;\n while (target.parent && !target.parent.isProject() && !target.hasOwnDocument) {\n target = target.parent;\n }\n\n if (!target._aliases) {\n target._aliases = [];\n }\n let suffix = '', index = 0;\n while (target._aliases.indexOf(alias + suffix) !== -1) {\n suffix = '-' + (++index).toString();\n }\n\n alias += suffix;\n target._aliases.push(alias);\n this._alias = alias;\n }\n\n return this._alias;\n }\n\n /**\n * Has this reflection a visible comment?\n *\n * @returns TRUE when this reflection has a visible comment.\n */\n hasComment(): boolean {\n return (this.comment && this.comment.hasVisibleComponent());\n }\n\n hasGetterOrSetter(): boolean {\n return false;\n }\n\n /**\n * @param name The name of the child to look for. Might contain a hierarchy.\n */\n getChildByName(name: string): Reflection;\n\n /**\n * @param names The name hierarchy of the child to look for.\n */\n getChildByName(names: string[]): Reflection;\n\n /**\n * Return a child by its name.\n *\n * @returns The found child or NULL.\n */\n getChildByName(arg: any): Reflection {\n const names: string[] = Array.isArray(arg) ? arg : arg.split('.');\n const name = names[0];\n let result: Reflection = null;\n\n this.traverse((child) => {\n if (child.name === name) {\n if (names.length <= 1) {\n result = child;\n } else if (child) {\n result = child.getChildByName(names.slice(1));\n }\n }\n });\n\n return result;\n }\n\n /**\n * Return whether this reflection is the root / project reflection.\n */\n isProject(): boolean { // this is ProjectReflection\n return false;\n }\n\n /**\n * @param name The name to look for. Might contain a hierarchy.\n */\n findReflectionByName(name: string): Reflection;\n\n /**\n * @param names The name hierarchy to look for.\n */\n findReflectionByName(names: string[]): Reflection;\n\n /**\n * Try to find a reflection by its name.\n *\n * @return The found reflection or null.\n */\n findReflectionByName(arg: any): Reflection {\n const names: string[] = Array.isArray(arg) ? arg : arg.split('.');\n\n const reflection = this.getChildByName(names);\n if (reflection) {\n return reflection;\n } else {\n return this.parent.findReflectionByName(names);\n }\n }\n\n /**\n * Traverse all potential child reflections of this reflection.\n *\n * The given callback will be invoked for all children, signatures and type parameters\n * attached to this reflection.\n *\n * @param callback The callback function that should be applied for each child reflection.\n */\n traverse(callback: TraverseCallback) { }\n\n /**\n * Return a raw object representation of this reflection.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = {\n id: this.id,\n name: this.name,\n kind: this.kind,\n kindString: this.kindString,\n flags: {}\n };\n\n if (this.originalName !== this.name) {\n result.originalName = this.originalName;\n }\n\n if (this.comment) {\n result.comment = this.comment.toObject();\n }\n\n for (let key in this.flags) {\n // tslint:disable-next-line:triple-equals\n if (parseInt(key, 10) == key || key === 'flags') {\n continue;\n }\n if (this.flags[key]) {\n result.flags[key] = true;\n }\n }\n\n if (this.decorates) {\n result.decorates = this.decorates.map((type) => type.toObject());\n }\n\n if (this.decorators) {\n result.decorators = this.decorators.map((decorator) => {\n const result: any = { name: decorator.name };\n if (decorator.type) {\n result.type = decorator.type.toObject();\n }\n if (decorator.arguments) {\n result.arguments = decorator.arguments;\n }\n return result;\n });\n }\n\n this.traverse((child, property) => {\n if (property === TraverseProperty.TypeLiteral) {\n return;\n }\n let name = TraverseProperty[property];\n name = name.substr(0, 1).toLowerCase() + name.substr(1);\n if (!result[name]) {\n result[name] = [];\n }\n result[name].push(child.toObject());\n });\n\n return result;\n }\n\n /**\n * Return a string representation of this reflection.\n */\n toString(): string {\n return ReflectionKind[this.kind] + ' ' + this.name;\n }\n\n /**\n * Return a string representation of this reflection and all of its children.\n *\n * @param indent Used internally to indent child reflections.\n */\n toStringHierarchy(indent: string = '') {\n const lines = [indent + this.toString()];\n\n indent += ' ';\n this.traverse((child, property) => {\n lines.push(child.toStringHierarchy(indent));\n });\n\n return lines.join('\\n');\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/reflections/container.d.ts b/dist/lib/models/reflections/container.d.ts new file mode 100644 index 000000000..c4f76e856 --- /dev/null +++ b/dist/lib/models/reflections/container.d.ts @@ -0,0 +1,12 @@ +import { Reflection, ReflectionKind, TraverseCallback } from './abstract'; +import { ReflectionCategory } from '../ReflectionCategory'; +import { ReflectionGroup } from '../ReflectionGroup'; +import { DeclarationReflection } from './declaration'; +export declare class ContainerReflection extends Reflection { + children: DeclarationReflection[]; + groups: ReflectionGroup[]; + categories: ReflectionCategory[]; + getChildrenByKind(kind: ReflectionKind): DeclarationReflection[]; + traverse(callback: TraverseCallback): void; + toObject(): any; +} diff --git a/dist/lib/models/reflections/container.js b/dist/lib/models/reflections/container.js new file mode 100644 index 000000000..8cb609eb4 --- /dev/null +++ b/dist/lib/models/reflections/container.js @@ -0,0 +1,70 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var ContainerReflection = (function (_super) { + __extends(ContainerReflection, _super); + function ContainerReflection() { + return _super !== null && _super.apply(this, arguments) || this; + } + ContainerReflection.prototype.getChildrenByKind = function (kind) { + var values = []; + for (var key in this.children) { + var child = this.children[key]; + if (child.kindOf(kind)) { + values.push(child); + } + } + return values; + }; + ContainerReflection.prototype.traverse = function (callback) { + if (this.children) { + this.children.slice().forEach(function (child) { + callback(child, abstract_1.TraverseProperty.Children); + }); + } + }; + ContainerReflection.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.groups) { + var groups_1 = []; + this.groups.forEach(function (group) { + groups_1.push(group.toObject()); + }); + result['groups'] = groups_1; + } + if (this.categories) { + var categories_1 = []; + this.categories.forEach(function (category) { + categories_1.push(category.toObject()); + }); + if (categories_1.length > 0) { + result['categories'] = categories_1; + } + } + if (this.sources) { + var sources_1 = []; + this.sources.forEach(function (source) { + sources_1.push({ + fileName: source.fileName, + line: source.line, + character: source.character + }); + }); + result['sources'] = sources_1; + } + return result; + }; + return ContainerReflection; +}(abstract_1.Reflection)); +exports.ContainerReflection = ContainerReflection; +//# sourceMappingURL=container.js.map \ No newline at end of file diff --git a/dist/lib/models/reflections/container.js.map b/dist/lib/models/reflections/container.js.map new file mode 100644 index 000000000..c748b6b6a --- /dev/null +++ b/dist/lib/models/reflections/container.js.map @@ -0,0 +1 @@ +{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/container.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAA4F;AAK5F;IAAyC,uCAAU;IAAnD;;IA2FA,CAAC;IArEG,+CAAiB,GAAjB,UAAkB,IAAoB;QAClC,IAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5B,IAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACjC,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACrB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;QACL,CAAC;QACD,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAUD,sCAAQ,GAAR,UAAS,QAA0B;QAC/B,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,UAAC,KAA4B;gBACvD,QAAQ,CAAC,KAAK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O,CAAC;QAC9B,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,0BAAC;AAAD,CAAC,AA3FD,CAAyC,qBAAU,GA2FlD;AA3FY,kDAAmB","sourcesContent":["import { Reflection, ReflectionKind, TraverseCallback, TraverseProperty } from './abstract';\nimport { ReflectionCategory } from '../ReflectionCategory';\nimport { ReflectionGroup } from '../ReflectionGroup';\nimport { DeclarationReflection } from './declaration';\n\nexport class ContainerReflection extends Reflection {\n /**\n * The children of this reflection.\n */\n children: DeclarationReflection[];\n\n /**\n * All children grouped by their kind.\n */\n groups: ReflectionGroup[];\n\n /**\n * All children grouped by their category.\n */\n categories: ReflectionCategory[];\n\n /**\n * Return a list of all children of a certain kind.\n *\n * @param kind The desired kind of children.\n * @returns An array containing all children with the desired kind.\n */\n getChildrenByKind(kind: ReflectionKind): DeclarationReflection[] {\n const values: DeclarationReflection[] = [];\n for (let key in this.children) {\n const child = this.children[key];\n if (child.kindOf(kind)) {\n values.push(child);\n }\n }\n return values;\n }\n\n /**\n * Traverse all potential child reflections of this reflection.\n *\n * The given callback will be invoked for all children, signatures and type parameters\n * attached to this reflection.\n *\n * @param callback The callback function that should be applied for each child reflection.\n */\n traverse(callback: TraverseCallback) {\n if (this.children) {\n this.children.slice().forEach((child: DeclarationReflection) => {\n callback(child, TraverseProperty.Children);\n });\n }\n }\n\n /**\n * Return a raw object representation of this reflection.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result = super.toObject();\n\n if (this.groups) {\n const groups: any[] = [];\n this.groups.forEach((group) => {\n groups.push(group.toObject());\n });\n\n result['groups'] = groups;\n }\n\n if (this.categories) {\n const categories: any[] = [];\n this.categories.forEach((category) => {\n categories.push(category.toObject());\n });\n\n if (categories.length > 0) {\n result['categories'] = categories;\n }\n }\n\n if (this.sources) {\n const sources: any[] = [];\n this.sources.forEach((source) => {\n sources.push({\n fileName: source.fileName,\n line: source.line,\n character: source.character\n });\n });\n\n result['sources'] = sources;\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/reflections/declaration.d.ts b/dist/lib/models/reflections/declaration.d.ts new file mode 100644 index 000000000..545a83e2c --- /dev/null +++ b/dist/lib/models/reflections/declaration.d.ts @@ -0,0 +1,32 @@ +import { DefaultValueContainer, TypeContainer, TypeParameterContainer, TraverseCallback } from './abstract'; +import { Type } from '../types/index'; +import { ContainerReflection } from './container'; +import { SignatureReflection } from './signature'; +import { TypeParameterReflection } from './type-parameter'; +export interface DeclarationHierarchy { + types: Type[]; + next?: DeclarationHierarchy; + isTarget?: boolean; +} +export declare class DeclarationReflection extends ContainerReflection implements DefaultValueContainer, TypeContainer, TypeParameterContainer { + type: Type; + typeParameters: TypeParameterReflection[]; + signatures: SignatureReflection[]; + indexSignature: SignatureReflection; + getSignature: SignatureReflection; + setSignature: SignatureReflection; + defaultValue: string; + overwrites: Type; + inheritedFrom: Type; + implementationOf: Type; + extendedTypes: Type[]; + extendedBy: Type[]; + implementedTypes: Type[]; + implementedBy: Type[]; + typeHierarchy: DeclarationHierarchy; + hasGetterOrSetter(): boolean; + getAllSignatures(): SignatureReflection[]; + traverse(callback: TraverseCallback): void; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/reflections/declaration.js b/dist/lib/models/reflections/declaration.js new file mode 100644 index 000000000..e86fb51f5 --- /dev/null +++ b/dist/lib/models/reflections/declaration.js @@ -0,0 +1,109 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var index_1 = require("../types/index"); +var container_1 = require("./container"); +var DeclarationReflection = (function (_super) { + __extends(DeclarationReflection, _super); + function DeclarationReflection() { + return _super !== null && _super.apply(this, arguments) || this; + } + DeclarationReflection.prototype.hasGetterOrSetter = function () { + return !!this.getSignature || !!this.setSignature; + }; + DeclarationReflection.prototype.getAllSignatures = function () { + var result = []; + if (this.signatures) { + result = result.concat(this.signatures); + } + if (this.indexSignature) { + result.push(this.indexSignature); + } + if (this.getSignature) { + result.push(this.getSignature); + } + if (this.setSignature) { + result.push(this.setSignature); + } + return result; + }; + DeclarationReflection.prototype.traverse = function (callback) { + if (this.typeParameters) { + this.typeParameters.slice().forEach(function (parameter) { return callback(parameter, abstract_1.TraverseProperty.TypeParameter); }); + } + if (this.type instanceof index_1.ReflectionType) { + callback(this.type.declaration, abstract_1.TraverseProperty.TypeLiteral); + } + if (this.signatures) { + this.signatures.slice().forEach(function (signature) { return callback(signature, abstract_1.TraverseProperty.Signatures); }); + } + if (this.indexSignature) { + callback(this.indexSignature, abstract_1.TraverseProperty.IndexSignature); + } + if (this.getSignature) { + callback(this.getSignature, abstract_1.TraverseProperty.GetSignature); + } + if (this.setSignature) { + callback(this.setSignature, abstract_1.TraverseProperty.SetSignature); + } + _super.prototype.traverse.call(this, callback); + }; + DeclarationReflection.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.type) { + result.type = this.type.toObject(); + } + if (this.defaultValue) { + result.defaultValue = this.defaultValue; + } + if (this.overwrites) { + result.overwrites = this.overwrites.toObject(); + } + if (this.inheritedFrom) { + result.inheritedFrom = this.inheritedFrom.toObject(); + } + if (this.extendedTypes) { + result.extendedTypes = this.extendedTypes.map(function (t) { return t.toObject(); }); + } + if (this.extendedBy) { + result.extendedBy = this.extendedBy.map(function (t) { return t.toObject(); }); + } + if (this.implementedTypes) { + result.implementedTypes = this.implementedTypes.map(function (t) { return t.toObject(); }); + } + if (this.implementedBy) { + result.implementedBy = this.implementedBy.map(function (t) { return t.toObject(); }); + } + if (this.implementationOf) { + result.implementationOf = this.implementationOf.toObject(); + } + return result; + }; + DeclarationReflection.prototype.toString = function () { + var result = _super.prototype.toString.call(this); + if (this.typeParameters) { + var parameters_1 = []; + this.typeParameters.forEach(function (parameter) { + parameters_1.push(parameter.name); + }); + result += '<' + parameters_1.join(', ') + '>'; + } + if (this.type) { + result += ':' + this.type.toString(); + } + return result; + }; + return DeclarationReflection; +}(container_1.ContainerReflection)); +exports.DeclarationReflection = DeclarationReflection; +//# sourceMappingURL=declaration.js.map \ No newline at end of file diff --git a/dist/lib/models/reflections/declaration.js.map b/dist/lib/models/reflections/declaration.js.map new file mode 100644 index 000000000..72f209f01 --- /dev/null +++ b/dist/lib/models/reflections/declaration.js.map @@ -0,0 +1 @@ +{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/declaration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAA8H;AAC9H,wCAAsD;AACtD,yCAAkD;AAgClD;IAA2C,yCAAmB;IAA9D;;IAqNA,CAAC;IA7HG,iDAAiB,GAAjB;QACI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;IACtD,CAAC;IAED,gDAAgB,GAAhB;QACI,IAAI,MAAM,GAA0B,EAAE,CAAC;QAEvC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YAClB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACrC,CAAC;QACD,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC;QACD,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC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} from './abstract';\nimport { Type, ReflectionType } from '../types/index';\nimport { ContainerReflection } from './container';\nimport { SignatureReflection } from './signature';\nimport { TypeParameterReflection } from './type-parameter';\n\n/**\n * Stores hierarchical type data.\n *\n * @see [[DeclarationReflection.typeHierarchy]]\n */\nexport interface DeclarationHierarchy {\n /**\n * The types represented by this node in the hierarchy.\n */\n types: Type[];\n\n /**\n * The next hierarchy level.\n */\n next?: DeclarationHierarchy;\n\n /**\n * Is this the entry containing the target type?\n */\n isTarget?: boolean;\n}\n\n/**\n * A reflection that represents a single declaration emitted by the TypeScript compiler.\n *\n * All parts of a project are represented by DeclarationReflection instances. The actual\n * kind of a reflection is stored in its ´kind´ member.\n */\nexport class DeclarationReflection extends ContainerReflection implements DefaultValueContainer, TypeContainer, TypeParameterContainer {\n /**\n * The type of the reflection.\n *\n * If the reflection represents a variable or a property, this is the value type.
\n * If the reflection represents a signature, this is the return type.\n */\n type: Type;\n\n typeParameters: TypeParameterReflection[];\n\n /**\n * A list of call signatures attached to this declaration.\n *\n * TypeDoc creates one declaration per function that may contain ore or more\n * signature reflections.\n */\n signatures: SignatureReflection[];\n\n /**\n * The index signature of this declaration.\n */\n indexSignature: SignatureReflection;\n\n /**\n * The get signature of this declaration.\n */\n getSignature: SignatureReflection;\n\n /**\n * The set signature of this declaration.\n */\n setSignature: SignatureReflection;\n\n /**\n * The default value of this reflection.\n *\n * Applies to function parameters.\n */\n defaultValue: string;\n\n /**\n * A type that points to the reflection that has been overwritten by this reflection.\n *\n * Applies to interface and class members.\n */\n overwrites: Type;\n\n /**\n * A type that points to the reflection this reflection has been inherited from.\n *\n * Applies to interface and class members.\n */\n inheritedFrom: Type;\n\n /**\n * A type that points to the reflection this reflection is the implementation of.\n *\n * Applies to class members.\n */\n implementationOf: Type;\n\n /**\n * A list of all types this reflection extends (e.g. the parent classes).\n */\n extendedTypes: Type[];\n\n /**\n * A list of all types that extend this reflection (e.g. the subclasses).\n */\n extendedBy: Type[];\n\n /**\n * A list of all types this reflection implements.\n */\n implementedTypes: Type[];\n\n /**\n * A list of all types that implement this reflection.\n */\n implementedBy: Type[];\n\n /**\n * Contains a simplified representation of the type hierarchy suitable for being\n * rendered in templates.\n */\n typeHierarchy: DeclarationHierarchy;\n\n hasGetterOrSetter(): boolean {\n return !!this.getSignature || !!this.setSignature;\n }\n\n getAllSignatures(): SignatureReflection[] {\n let result: SignatureReflection[] = [];\n\n if (this.signatures) {\n result = result.concat(this.signatures);\n }\n if (this.indexSignature) {\n result.push(this.indexSignature);\n }\n if (this.getSignature) {\n result.push(this.getSignature);\n }\n if (this.setSignature) {\n result.push(this.setSignature);\n }\n\n return result;\n }\n\n /**\n * Traverse all potential child reflections of this reflection.\n *\n * The given callback will be invoked for all children, signatures and type parameters\n * attached to this reflection.\n *\n * @param callback The callback function that should be applied for each child reflection.\n */\n traverse(callback: TraverseCallback) {\n if (this.typeParameters) {\n this.typeParameters.slice().forEach((parameter) => callback(parameter, TraverseProperty.TypeParameter));\n }\n\n if (this.type instanceof ReflectionType) {\n callback(( this.type).declaration, TraverseProperty.TypeLiteral);\n }\n\n if (this.signatures) {\n this.signatures.slice().forEach((signature) => callback(signature, TraverseProperty.Signatures));\n }\n\n if (this.indexSignature) {\n callback(this.indexSignature, TraverseProperty.IndexSignature);\n }\n\n if (this.getSignature) {\n callback(this.getSignature, TraverseProperty.GetSignature);\n }\n\n if (this.setSignature) {\n callback(this.setSignature, TraverseProperty.SetSignature);\n }\n\n super.traverse(callback);\n }\n\n /**\n * Return a raw object representation of this reflection.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n let result = super.toObject();\n\n if (this.type) {\n result.type = this.type.toObject();\n }\n\n if (this.defaultValue) {\n result.defaultValue = this.defaultValue;\n }\n\n if (this.overwrites) {\n result.overwrites = this.overwrites.toObject();\n }\n\n if (this.inheritedFrom) {\n result.inheritedFrom = this.inheritedFrom.toObject();\n }\n\n if (this.extendedTypes) {\n result.extendedTypes = this.extendedTypes.map((t) => t.toObject());\n }\n\n if (this.extendedBy) {\n result.extendedBy = this.extendedBy.map((t) => t.toObject());\n }\n\n if (this.implementedTypes) {\n result.implementedTypes = this.implementedTypes.map((t) => t.toObject());\n }\n\n if (this.implementedBy) {\n result.implementedBy = this.implementedBy.map((t) => t.toObject());\n }\n\n if (this.implementationOf) {\n result.implementationOf = this.implementationOf.toObject();\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this reflection.\n */\n toString(): string {\n let result = super.toString();\n\n if (this.typeParameters) {\n const parameters: string[] = [];\n this.typeParameters.forEach((parameter) => {\n parameters.push(parameter.name);\n });\n result += '<' + parameters.join(', ') + '>';\n }\n\n if (this.type) {\n result += ':' + this.type.toString();\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/reflections/index.d.ts b/dist/lib/models/reflections/index.d.ts new file mode 100644 index 000000000..856577dd2 --- /dev/null +++ b/dist/lib/models/reflections/index.d.ts @@ -0,0 +1,7 @@ +export { Reflection, ReflectionKind, ReflectionFlag, TypeParameterContainer, Decorator, TraverseProperty } from './abstract'; +export { ContainerReflection } from './container'; +export { DeclarationReflection, DeclarationHierarchy } from './declaration'; +export { ParameterReflection } from './parameter'; +export { ProjectReflection } from './project'; +export { SignatureReflection } from './signature'; +export { TypeParameterReflection } from './type-parameter'; diff --git a/dist/lib/models/reflections/index.js b/dist/lib/models/reflections/index.js new file mode 100644 index 000000000..09334d889 --- /dev/null +++ b/dist/lib/models/reflections/index.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +exports.Reflection = abstract_1.Reflection; +exports.ReflectionKind = abstract_1.ReflectionKind; +exports.ReflectionFlag = abstract_1.ReflectionFlag; +exports.TraverseProperty = abstract_1.TraverseProperty; +var container_1 = require("./container"); +exports.ContainerReflection = container_1.ContainerReflection; +var declaration_1 = require("./declaration"); +exports.DeclarationReflection = declaration_1.DeclarationReflection; +var parameter_1 = require("./parameter"); +exports.ParameterReflection = parameter_1.ParameterReflection; +var project_1 = require("./project"); +exports.ProjectReflection = project_1.ProjectReflection; +var signature_1 = require("./signature"); +exports.SignatureReflection = signature_1.SignatureReflection; +var type_parameter_1 = require("./type-parameter"); +exports.TypeParameterReflection = type_parameter_1.TypeParameterReflection; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/models/reflections/index.js.map b/dist/lib/models/reflections/index.js.map new file mode 100644 index 000000000..570a747cf --- /dev/null +++ b/dist/lib/models/reflections/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/index.ts"],"names":[],"mappings":";;AAAA,uCAA6H;AAApH,gCAAA,UAAU,CAAA;AAAE,oCAAA,cAAc,CAAA;AAAE,oCAAA,cAAc,CAAA;AAAqC,sCAAA,gBAAgB,CAAA;AACxG,yCAAkD;AAAzC,0CAAA,mBAAmB,CAAA;AAC5B,6CAA4E;AAAnE,8CAAA,qBAAqB,CAAA;AAC9B,yCAAkD;AAAzC,0CAAA,mBAAmB,CAAA;AAC5B,qCAA8C;AAArC,sCAAA,iBAAiB,CAAA;AAC1B,yCAAkD;AAAzC,0CAAA,mBAAmB,CAAA;AAC5B,mDAA2D;AAAlD,mDAAA,uBAAuB,CAAA","sourcesContent":["export { Reflection, ReflectionKind, ReflectionFlag, TypeParameterContainer, Decorator, TraverseProperty } from './abstract';\nexport { ContainerReflection } from './container';\nexport { DeclarationReflection, DeclarationHierarchy } from './declaration';\nexport { ParameterReflection } from './parameter';\nexport { ProjectReflection } from './project';\nexport { SignatureReflection } from './signature';\nexport { TypeParameterReflection } from './type-parameter';\n"]} \ No newline at end of file diff --git a/dist/lib/models/reflections/parameter.d.ts b/dist/lib/models/reflections/parameter.d.ts new file mode 100644 index 000000000..0932dc409 --- /dev/null +++ b/dist/lib/models/reflections/parameter.d.ts @@ -0,0 +1,11 @@ +import { Type } from '../types/index'; +import { Reflection, DefaultValueContainer, TypeContainer, TraverseCallback } from './abstract'; +import { SignatureReflection } from './signature'; +export declare class ParameterReflection extends Reflection implements DefaultValueContainer, TypeContainer { + parent: SignatureReflection; + defaultValue: string; + type: Type; + traverse(callback: TraverseCallback): void; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/reflections/parameter.js b/dist/lib/models/reflections/parameter.js new file mode 100644 index 000000000..691b2f060 --- /dev/null +++ b/dist/lib/models/reflections/parameter.js @@ -0,0 +1,42 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../types/index"); +var abstract_1 = require("./abstract"); +var ParameterReflection = (function (_super) { + __extends(ParameterReflection, _super); + function ParameterReflection() { + return _super !== null && _super.apply(this, arguments) || this; + } + ParameterReflection.prototype.traverse = function (callback) { + if (this.type instanceof index_1.ReflectionType) { + callback(this.type.declaration, abstract_1.TraverseProperty.TypeLiteral); + } + _super.prototype.traverse.call(this, callback); + }; + ParameterReflection.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.type) { + result.type = this.type.toObject(); + } + if (this.defaultValue) { + result.defaultValue = this.defaultValue; + } + return result; + }; + ParameterReflection.prototype.toString = function () { + return _super.prototype.toString.call(this) + (this.type ? ':' + this.type.toString() : ''); + }; + return ParameterReflection; +}(abstract_1.Reflection)); +exports.ParameterReflection = ParameterReflection; +//# sourceMappingURL=parameter.js.map \ No newline at end of file diff --git a/dist/lib/models/reflections/parameter.js.map b/dist/lib/models/reflections/parameter.js.map new file mode 100644 index 000000000..1dbe3c0eb --- /dev/null +++ b/dist/lib/models/reflections/parameter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/parameter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsD;AACtD,uCAAkH;AAGlH;IAAyC,uCAAU;IAAnD;;IA+CA,CAAC;IAhCG,sCAAQ,GAAR,UAAS,QAA0B;QAC/B,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,YAAY,sBAAc,CAAC,CAAC,CAAC;YACtC,QAAQ,CAAmB,IAAI,CAAC,IAAK,CAAC,WAAW,EAAE,2BAAgB,CAAC,WAAW,CAAC,CAAC;QACrF,CAAC;QAED,iBAAM,QAAQ,YAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAMD,sCAAQ,GAAR;QACI,IAAM,MAAM,GAAG,iBAAM,QAAQ,WAAE,CAAC;QAEhC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACZ,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,CAAC;QAED,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;YACpB,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAC5C,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,sCAAQ,GAAR;QACI,MAAM,CAAC,iBAAM,QAAQ,WAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;IACL,0BAAC;AAAD,CAAC,AA/CD,CAAyC,qBAAU,GA+ClD;AA/CY,kDAAmB","sourcesContent":["import { Type, ReflectionType } from '../types/index';\nimport { Reflection, DefaultValueContainer, TypeContainer, TraverseCallback, TraverseProperty } from './abstract';\nimport { SignatureReflection } from './signature';\n\nexport class ParameterReflection extends Reflection implements DefaultValueContainer, TypeContainer {\n parent: SignatureReflection;\n\n defaultValue: string;\n\n type: Type;\n\n /**\n * Traverse all potential child reflections of this reflection.\n *\n * The given callback will be invoked for all children, signatures and type parameters\n * attached to this reflection.\n *\n * @param callback The callback function that should be applied for each child reflection.\n */\n traverse(callback: TraverseCallback) {\n if (this.type instanceof ReflectionType) {\n callback(( this.type).declaration, TraverseProperty.TypeLiteral);\n }\n\n super.traverse(callback);\n }\n\n /**\n * Return a raw object representation of this reflection.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result = super.toObject();\n\n if (this.type) {\n result.type = this.type.toObject();\n }\n\n if (this.defaultValue) {\n result.defaultValue = this.defaultValue;\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this reflection.\n */\n toString() {\n return super.toString() + (this.type ? ':' + this.type.toString() : '');\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/reflections/project.d.ts b/dist/lib/models/reflections/project.d.ts new file mode 100644 index 000000000..ce1445772 --- /dev/null +++ b/dist/lib/models/reflections/project.d.ts @@ -0,0 +1,24 @@ +import { SourceFile, SourceDirectory } from '../sources/index'; +import { Reflection, ReflectionKind } from './abstract'; +import { ContainerReflection } from './container'; +import { ReflectionCategory } from '../ReflectionCategory'; +export declare class ProjectReflection extends ContainerReflection { + reflections: { + [id: number]: Reflection; + }; + symbolMapping: { + [symbolId: number]: number; + }; + directory: SourceDirectory; + files: SourceFile[]; + categories: ReflectionCategory[]; + name: string; + readme: string; + packageInfo: any; + constructor(name: string); + isProject(): boolean; + getReflectionsByKind(kind: ReflectionKind): Reflection[]; + findReflectionByName(name: string): Reflection; + findReflectionByName(names: string[]): Reflection; + toObject(): any; +} diff --git a/dist/lib/models/reflections/project.js b/dist/lib/models/reflections/project.js new file mode 100644 index 000000000..b74fb5dca --- /dev/null +++ b/dist/lib/models/reflections/project.js @@ -0,0 +1,76 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../sources/index"); +var abstract_1 = require("./abstract"); +var container_1 = require("./container"); +var ProjectReflection = (function (_super) { + __extends(ProjectReflection, _super); + function ProjectReflection(name) { + var _this = _super.call(this, null, name, abstract_1.ReflectionKind.Global) || this; + _this.reflections = {}; + _this.symbolMapping = {}; + _this.directory = new index_1.SourceDirectory(); + _this.files = []; + return _this; + } + ProjectReflection.prototype.isProject = function () { + return true; + }; + ProjectReflection.prototype.getReflectionsByKind = function (kind) { + var values = []; + for (var id in this.reflections) { + var reflection = this.reflections[id]; + if (reflection.kindOf(kind)) { + values.push(reflection); + } + } + return values; + }; + ProjectReflection.prototype.findReflectionByName = function (arg) { + var names = Array.isArray(arg) ? arg : arg.split('.'); + var name = names.pop(); + search: for (var key in this.reflections) { + var reflection = this.reflections[key]; + if (reflection.name !== name) { + continue; + } + var depth = names.length - 1; + var target = reflection; + while (target && depth >= 0) { + target = target.parent; + if (target.name !== names[depth]) { + continue search; + } + depth -= 1; + } + return reflection; + } + return null; + }; + ProjectReflection.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.categories) { + var categories_1 = []; + this.categories.forEach(function (category) { + categories_1.push(category.toObject()); + }); + if (categories_1.length > 0) { + result['categories'] = categories_1; + } + } + return result; + }; + return ProjectReflection; +}(container_1.ContainerReflection)); +exports.ProjectReflection = ProjectReflection; +//# sourceMappingURL=project.js.map \ No newline at end of file diff --git a/dist/lib/models/reflections/project.js.map b/dist/lib/models/reflections/project.js.map new file mode 100644 index 000000000..8da2eaa0b --- /dev/null +++ b/dist/lib/models/reflections/project.js.map @@ -0,0 +1 @@ +{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/project.ts"],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,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;gBAC3B,QAAQ,CAAC;YACb,CAAC;YAED,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAC7B,IAAI,MAAM,GAAG,UAAU,CAAC;YACxB,OAAO,MAAM,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBAC1B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;gBACvB,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC/B,QAAQ,CAAC,MAAM,CAAC;gBACpB,CAAC;gBACD,KAAK,IAAI,CAAC,CAAC;YACf,CAAC;YAED,MAAM,CAAC,UAAU,CAAC;QACtB,CAAC;QAED,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAMD,oCAAQ,GAAR;QACI,IAAM,MAAM,GAAG,iBAAM,QAAQ,WAAE,CAAC;QAEhC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YAClB,IAAM,YAAU,GAAU,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,QAAQ;gBAC7B,YAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,CAAC,YAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;gBACxB,MAAM,CAAC,YAAY,CAAC,GAAG,YAAU,CAAC;YACtC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,wBAAC;AAAD,CAAC,AAvID,CAAuC,+BAAmB,GAuIzD;AAvIY,8CAAiB","sourcesContent":["import { SourceFile, SourceDirectory } from '../sources/index';\nimport { Reflection, ReflectionKind } from './abstract';\nimport { ContainerReflection } from './container';\nimport { ReflectionCategory } from '../ReflectionCategory';\n\n/**\n * A reflection that represents the root of the project.\n *\n * The project reflection acts as a global index, one may receive all reflections\n * and source files of the processed project through this reflection.\n */\nexport class ProjectReflection extends ContainerReflection {\n /**\n * A list of all reflections within the project.\n */\n reflections: {[id: number]: Reflection} = {};\n\n symbolMapping: {[symbolId: number]: number} = {};\n\n /**\n * The root directory of the project.\n */\n directory: SourceDirectory = new SourceDirectory();\n\n /**\n * A list of all source files within the project.\n */\n files: SourceFile[] = [];\n\n /**\n * All reflections categorized.\n */\n categories: ReflectionCategory[];\n\n /**\n * The name of the project.\n *\n * The name can be passed as a commandline argument or it is read from the package info.\n */\n name: string;\n\n /**\n * The contents of the readme.md file of the project when found.\n */\n readme: string;\n\n /**\n * The parsed data of the package.json file of the project when found.\n */\n packageInfo: any;\n\n /**\n * Create a new ProjectReflection instance.\n *\n * @param name The name of the project.\n */\n constructor(name: string) {\n super(null, name, ReflectionKind.Global);\n }\n\n /**\n * Return whether this reflection is the root / project reflection.\n */\n isProject(): boolean {\n return true;\n }\n\n /**\n * Return a list of all reflections in this project of a certain kind.\n *\n * @param kind The desired kind of reflection.\n * @returns An array containing all reflections with the desired kind.\n */\n getReflectionsByKind(kind: ReflectionKind): Reflection[] {\n const values: Reflection[] = [];\n for (let id in this.reflections) {\n const reflection = this.reflections[id];\n if (reflection.kindOf(kind)) {\n values.push(reflection);\n }\n }\n\n return values;\n }\n\n /**\n * @param name The name to look for. Might contain a hierarchy.\n */\n findReflectionByName(name: string): Reflection;\n\n /**\n * @param names The name hierarchy to look for.\n */\n findReflectionByName(names: string[]): Reflection;\n\n /**\n * Try to find a reflection by its name.\n *\n * @return The found reflection or null.\n */\n findReflectionByName(arg: any): Reflection {\n const names: string[] = Array.isArray(arg) ? arg : arg.split('.');\n const name = names.pop();\n\n search: for (let key in this.reflections) {\n const reflection = this.reflections[key];\n if (reflection.name !== name) {\n continue;\n }\n\n let depth = names.length - 1;\n let target = reflection;\n while (target && depth >= 0) {\n target = target.parent;\n if (target.name !== names[depth]) {\n continue search;\n }\n depth -= 1;\n }\n\n return reflection;\n }\n\n return null;\n }\n\n /**\n * Return a raw object representation of this reflection.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result = super.toObject();\n\n if (this.categories) {\n const categories: any[] = [];\n this.categories.forEach((category) => {\n categories.push(category.toObject());\n });\n\n if (categories.length > 0) {\n result['categories'] = categories;\n }\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/reflections/signature.d.ts b/dist/lib/models/reflections/signature.d.ts new file mode 100644 index 000000000..adb4dd9a4 --- /dev/null +++ b/dist/lib/models/reflections/signature.d.ts @@ -0,0 +1,18 @@ +import { Type } from '../types/index'; +import { Reflection, TypeContainer, TypeParameterContainer, TraverseCallback } from './abstract'; +import { ContainerReflection } from './container'; +import { ParameterReflection } from './parameter'; +import { TypeParameterReflection } from './type-parameter'; +export declare class SignatureReflection extends Reflection implements TypeContainer, TypeParameterContainer { + parent: ContainerReflection; + parameters: ParameterReflection[]; + typeParameters: TypeParameterReflection[]; + type: Type; + overwrites: Type; + inheritedFrom: Type; + implementationOf: Type; + getParameterTypes(): Type[]; + traverse(callback: TraverseCallback): void; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/reflections/signature.js b/dist/lib/models/reflections/signature.js new file mode 100644 index 000000000..2d6cfa197 --- /dev/null +++ b/dist/lib/models/reflections/signature.js @@ -0,0 +1,69 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("../types/index"); +var abstract_1 = require("./abstract"); +var SignatureReflection = (function (_super) { + __extends(SignatureReflection, _super); + function SignatureReflection() { + return _super !== null && _super.apply(this, arguments) || this; + } + SignatureReflection.prototype.getParameterTypes = function () { + if (!this.parameters) { + return []; + } + return this.parameters.map(function (parameter) { return parameter.type; }); + }; + SignatureReflection.prototype.traverse = function (callback) { + if (this.type instanceof index_1.ReflectionType) { + callback(this.type.declaration, abstract_1.TraverseProperty.TypeLiteral); + } + if (this.typeParameters) { + this.typeParameters.slice().forEach(function (parameter) { return callback(parameter, abstract_1.TraverseProperty.TypeParameter); }); + } + if (this.parameters) { + this.parameters.slice().forEach(function (parameter) { return callback(parameter, abstract_1.TraverseProperty.Parameters); }); + } + _super.prototype.traverse.call(this, callback); + }; + SignatureReflection.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.type) { + result.type = this.type.toObject(); + } + if (this.overwrites) { + result.overwrites = this.overwrites.toObject(); + } + if (this.inheritedFrom) { + result.inheritedFrom = this.inheritedFrom.toObject(); + } + if (this.implementationOf) { + result.implementationOf = this.implementationOf.toObject(); + } + return result; + }; + SignatureReflection.prototype.toString = function () { + var result = _super.prototype.toString.call(this); + if (this.typeParameters) { + var parameters_1 = []; + this.typeParameters.forEach(function (parameter) { return parameters_1.push(parameter.name); }); + result += '<' + parameters_1.join(', ') + '>'; + } + if (this.type) { + result += ':' + this.type.toString(); + } + return result; + }; + return SignatureReflection; +}(abstract_1.Reflection)); +exports.SignatureReflection = SignatureReflection; +//# sourceMappingURL=signature.js.map \ No newline at end of file diff --git a/dist/lib/models/reflections/signature.js.map b/dist/lib/models/reflections/signature.js.map new file mode 100644 index 000000000..a809fa983 --- /dev/null +++ b/dist/lib/models/reflections/signature.js.map @@ -0,0 +1 @@ +{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/signature.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsD;AACtD,uCAAmH;AAKnH;IAAyC,uCAAU;IAAnD;;IA4GA,CAAC;IA3EG,+CAAiB,GAAjB;QACI,EAAE,CAAC,CAAC,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MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QACnD,CAAC;QAED,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YACrB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;QACzD,CAAC;QAED,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAC/D,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,sCAAQ,GAAR;QACI,IAAI,MAAM,GAAG,iBAAM,QAAQ,WAAE,CAAC;QAE9B,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;YACtB,IAAM,YAAU,GAAa,EAAE,CAAC;YAChC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,UAAC,SAAS,IAAK,OAAA,YAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAA/B,CAA+B,CAAC,CAAC;YAC5E,MAAM,IAAI,GAAG,GAAG,YAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QAChD,CAAC;QAED,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACZ,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzC,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,0BAAC;AAAD,CAAC,AA5GD,CAAyC,qBAAU,GA4GlD;AA5GY,kDAAmB","sourcesContent":["import { Type, ReflectionType } from '../types/index';\nimport { Reflection, TypeContainer, TypeParameterContainer, TraverseProperty, TraverseCallback } from './abstract';\nimport { ContainerReflection } from './container';\nimport { ParameterReflection } from './parameter';\nimport { TypeParameterReflection } from './type-parameter';\n\nexport class SignatureReflection extends Reflection implements TypeContainer, TypeParameterContainer {\n parent: ContainerReflection;\n\n parameters: ParameterReflection[];\n\n typeParameters: TypeParameterReflection[];\n\n type: Type;\n\n /**\n * A type that points to the reflection that has been overwritten by this reflection.\n *\n * Applies to interface and class members.\n */\n overwrites: Type;\n\n /**\n * A type that points to the reflection this reflection has been inherited from.\n *\n * Applies to interface and class members.\n */\n inheritedFrom: Type;\n\n /**\n * A type that points to the reflection this reflection is the implementation of.\n *\n * Applies to class members.\n */\n implementationOf: Type;\n\n /**\n * Return an array of the parameter types.\n */\n getParameterTypes(): Type[] {\n if (!this.parameters) {\n return [];\n }\n return this.parameters.map((parameter: ParameterReflection) => parameter.type);\n }\n\n /**\n * Traverse all potential child reflections of this reflection.\n *\n * The given callback will be invoked for all children, signatures and type parameters\n * attached to this reflection.\n *\n * @param callback The callback function that should be applied for each child reflection.\n */\n traverse(callback: TraverseCallback) {\n if (this.type instanceof ReflectionType) {\n callback(( this.type).declaration, TraverseProperty.TypeLiteral);\n }\n\n if (this.typeParameters) {\n this.typeParameters.slice().forEach((parameter) => callback(parameter, TraverseProperty.TypeParameter));\n }\n\n if (this.parameters) {\n this.parameters.slice().forEach((parameter) => callback(parameter, TraverseProperty.Parameters));\n }\n\n super.traverse(callback);\n }\n\n /**\n * Return a raw object representation of this reflection.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result = super.toObject();\n\n if (this.type) {\n result.type = this.type.toObject();\n }\n\n if (this.overwrites) {\n result.overwrites = this.overwrites.toObject();\n }\n\n if (this.inheritedFrom) {\n result.inheritedFrom = this.inheritedFrom.toObject();\n }\n\n if (this.implementationOf) {\n result.implementationOf = this.implementationOf.toObject();\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this reflection.\n */\n toString(): string {\n let result = super.toString();\n\n if (this.typeParameters) {\n const parameters: string[] = [];\n this.typeParameters.forEach((parameter) => parameters.push(parameter.name));\n result += '<' + parameters.join(', ') + '>';\n }\n\n if (this.type) {\n result += ':' + this.type.toString();\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/reflections/type-parameter.d.ts b/dist/lib/models/reflections/type-parameter.d.ts new file mode 100644 index 000000000..3f13ee80c --- /dev/null +++ b/dist/lib/models/reflections/type-parameter.d.ts @@ -0,0 +1,9 @@ +import { Type, TypeParameterType } from '../types/index'; +import { Reflection, TypeContainer } from './abstract'; +import { DeclarationReflection } from './declaration'; +export declare class TypeParameterReflection extends Reflection implements TypeContainer { + parent: DeclarationReflection; + type: Type; + constructor(parent?: Reflection, type?: TypeParameterType); + toObject(): any; +} diff --git a/dist/lib/models/reflections/type-parameter.js b/dist/lib/models/reflections/type-parameter.js new file mode 100644 index 000000000..f26e759d6 --- /dev/null +++ b/dist/lib/models/reflections/type-parameter.js @@ -0,0 +1,31 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var TypeParameterReflection = (function (_super) { + __extends(TypeParameterReflection, _super); + function TypeParameterReflection(parent, type) { + var _this = _super.call(this, parent, type.name, abstract_1.ReflectionKind.TypeParameter) || this; + _this.type = type.constraint; + return _this; + } + TypeParameterReflection.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.type) { + result.type = this.type.toObject(); + } + return result; + }; + return TypeParameterReflection; +}(abstract_1.Reflection)); +exports.TypeParameterReflection = TypeParameterReflection; +//# sourceMappingURL=type-parameter.js.map \ No newline at end of file diff --git a/dist/lib/models/reflections/type-parameter.js.map b/dist/lib/models/reflections/type-parameter.js.map new file mode 100644 index 000000000..dd711d233 --- /dev/null +++ b/dist/lib/models/reflections/type-parameter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"type-parameter.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/type-parameter.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,uCAAuE;AAGvE;IAA6C,2CAAU;IAQnD,iCAAY,MAAmB,EAAE,IAAwB;QAAzD,YACI,kBAAM,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,yBAAc,CAAC,aAAa,CAAC,SAEzD;QADG,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;;IAChC,CAAC;IAMD,0CAAQ,GAAR;QACI,IAAM,MAAM,GAAG,iBAAM,QAAQ,WAAE,CAAC;QAEhC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACZ,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,8BAAC;AAAD,CAAC,AA1BD,CAA6C,qBAAU,GA0BtD;AA1BY,0DAAuB","sourcesContent":["import { Type, TypeParameterType } from '../types/index';\nimport { Reflection, ReflectionKind, TypeContainer } from './abstract';\nimport { DeclarationReflection } from './declaration';\n\nexport class TypeParameterReflection extends Reflection implements TypeContainer {\n parent: DeclarationReflection;\n\n type: Type;\n\n /**\n * Create a new TypeParameterReflection instance.\n */\n constructor(parent?: Reflection, type?: TypeParameterType) {\n super(parent, type.name, ReflectionKind.TypeParameter);\n this.type = type.constraint;\n }\n\n /**\n * Return a raw object representation of this reflection.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result = super.toObject();\n\n if (this.type) {\n result.type = this.type.toObject();\n }\n\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/sources/directory.d.ts b/dist/lib/models/sources/directory.d.ts new file mode 100644 index 000000000..545a4378f --- /dev/null +++ b/dist/lib/models/sources/directory.d.ts @@ -0,0 +1,19 @@ +import { Reflection } from '../reflections/abstract'; +import { ReflectionCategory } from '../ReflectionCategory'; +import { ReflectionGroup } from '../ReflectionGroup'; +import { SourceFile } from './file'; +export declare class SourceDirectory { + parent: SourceDirectory; + directories: { + [name: string]: SourceDirectory; + }; + groups: ReflectionGroup[]; + categories: ReflectionCategory[]; + files: SourceFile[]; + name: string; + dirName: string; + url: string; + constructor(name?: string, parent?: SourceDirectory); + toString(indent?: string): string; + getAllReflections(): Reflection[]; +} diff --git a/dist/lib/models/sources/directory.js b/dist/lib/models/sources/directory.js new file mode 100644 index 000000000..e0694bedd --- /dev/null +++ b/dist/lib/models/sources/directory.js @@ -0,0 +1,40 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var SourceDirectory = (function () { + function SourceDirectory(name, parent) { + this.parent = null; + this.directories = {}; + this.files = []; + this.name = null; + this.dirName = null; + if (name && parent) { + this.name = name; + this.dirName = (parent.dirName ? parent.dirName + '/' : '') + name; + this.parent = parent; + } + } + SourceDirectory.prototype.toString = function (indent) { + if (indent === void 0) { indent = ''; } + var res = indent + this.name; + for (var key in this.directories) { + if (!this.directories.hasOwnProperty(key)) { + continue; + } + res += '\n' + this.directories[key].toString(indent + ' '); + } + this.files.forEach(function (file) { + res += '\n' + indent + ' ' + file.fileName; + }); + return res; + }; + SourceDirectory.prototype.getAllReflections = function () { + var reflections = []; + this.files.forEach(function (file) { + reflections.push.apply(reflections, file.reflections); + }); + return reflections; + }; + return SourceDirectory; +}()); +exports.SourceDirectory = SourceDirectory; +//# sourceMappingURL=directory.js.map \ No newline at end of file diff --git a/dist/lib/models/sources/directory.js.map b/dist/lib/models/sources/directory.js.map new file mode 100644 index 000000000..099d033e9 --- /dev/null +++ b/dist/lib/models/sources/directory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../../../src/lib/models/sources/directory.ts"],"names":[],"mappings":";;AAYA;IAyCI,yBAAY,IAAa,EAAE,MAAwB;QArC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AC,IAAI;YACpB,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QAGH,MAAM,CAAC,WAAW,CAAC;IACvB,CAAC;IACL,sBAAC;AAAD,CAAC,AAvFD,IAuFC;AAvFY,0CAAe","sourcesContent":["import { Reflection } from '../reflections/abstract';\nimport { ReflectionCategory } from '../ReflectionCategory';\nimport { ReflectionGroup } from '../ReflectionGroup';\nimport { SourceFile } from './file';\n\n/**\n * Exposes information about a directory containing source files.\n *\n * One my access the root directory of a project through the [[ProjectReflection.directory]]\n * property. Traverse through directories by utilizing the [[SourceDirectory.parent]] or\n * [[SourceDirectory.directories]] properties.\n */\nexport class SourceDirectory {\n /**\n * The parent directory or NULL if this is a root directory.\n */\n parent: SourceDirectory = null;\n\n /**\n * A list of all subdirectories.\n */\n directories: {[name: string]: SourceDirectory} = {};\n\n groups: ReflectionGroup[];\n\n categories: ReflectionCategory[];\n\n /**\n * A list of all files in this directory.\n */\n files: SourceFile[] = [];\n\n /**\n * The name of this directory.\n */\n name: string = null;\n\n /**\n * The relative path from the root directory to this directory.\n */\n dirName: string = null;\n\n /**\n * The url of the page displaying the directory contents.\n */\n url: string;\n\n /**\n * Create a new SourceDirectory instance.\n *\n * @param name The new of directory.\n * @param parent The parent directory instance.\n */\n constructor(name?: string, parent?: SourceDirectory) {\n if (name && parent) {\n this.name = name;\n this.dirName = (parent.dirName ? parent.dirName + '/' : '') + name;\n this.parent = parent;\n }\n }\n\n /**\n * Return a string describing this directory and its contents.\n *\n * @param indent Used internally for indention.\n * @returns A string representing this directory and all of its children.\n */\n toString(indent: string = '') {\n let res = indent + this.name;\n\n for (let key in this.directories) {\n if (!this.directories.hasOwnProperty(key)) {\n continue;\n }\n res += '\\n' + this.directories[key].toString(indent + ' ');\n }\n\n this.files.forEach((file) => {\n res += '\\n' + indent + ' ' + file.fileName;\n });\n\n return res;\n }\n\n /**\n * Return a list of all reflections exposed by the files within this directory.\n *\n * @returns An aggregated list of all [[DeclarationReflection]] defined in the\n * files of this directory.\n */\n getAllReflections(): Reflection[] {\n const reflections: Reflection[] = [];\n this.files.forEach((file) => {\n reflections.push.apply(reflections, file.reflections);\n });\n\n // reflections.sort(Factories.GroupHandler.sortCallback);\n return reflections;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/sources/file.d.ts b/dist/lib/models/sources/file.d.ts new file mode 100644 index 000000000..49f04cf30 --- /dev/null +++ b/dist/lib/models/sources/file.d.ts @@ -0,0 +1,22 @@ +import { Reflection } from '../reflections/abstract'; +import { ReflectionCategory } from '../ReflectionCategory'; +import { ReflectionGroup } from '../ReflectionGroup'; +import { SourceDirectory } from './directory'; +export interface SourceReference { + file?: SourceFile; + fileName: string; + line: number; + character: number; + url?: string; +} +export declare class SourceFile { + fullFileName: string; + fileName: string; + name: string; + url: string; + parent: SourceDirectory; + reflections: Reflection[]; + groups: ReflectionGroup[]; + categories: ReflectionCategory[]; + constructor(fullFileName: string); +} diff --git a/dist/lib/models/sources/file.js b/dist/lib/models/sources/file.js new file mode 100644 index 000000000..6efe0157e --- /dev/null +++ b/dist/lib/models/sources/file.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var SourceFile = (function () { + function SourceFile(fullFileName) { + this.reflections = []; + this.fileName = fullFileName; + this.fullFileName = fullFileName; + this.name = Path.basename(fullFileName); + } + return SourceFile; +}()); +exports.SourceFile = SourceFile; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/dist/lib/models/sources/file.js.map b/dist/lib/models/sources/file.js.map new file mode 100644 index 000000000..f120332b0 --- /dev/null +++ b/dist/lib/models/sources/file.js.map @@ -0,0 +1 @@ +{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../../src/lib/models/sources/file.ts"],"names":[],"mappings":";;AAAA,2BAA6B;AA8C7B;IA+CI,oBAAY,YAAoB;QAjBhC,gBAAW,GAAiB,EAAE,CAAC;QAkB3B,IAAI,CAAC,QAAQ,GAAO,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,IAAI,GAAW,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACpD,CAAC;IACL,iBAAC;AAAD,CAAC,AApDD,IAoDC;AApDY,gCAAU","sourcesContent":["import * as Path from 'path';\n\nimport { Reflection } from '../reflections/abstract';\nimport { ReflectionCategory } from '../ReflectionCategory';\nimport { ReflectionGroup } from '../ReflectionGroup';\nimport { SourceDirectory } from './directory';\n\n/**\n * Represents references of reflections to their defining source files.\n *\n * @see [[DeclarationReflection.sources]]\n */\nexport interface SourceReference {\n /**\n * A reference to the corresponding file instance.\n */\n file?: SourceFile;\n\n /**\n * The filename of the source file.\n */\n fileName: string;\n\n /**\n * The number of the line that emitted the declaration.\n */\n line: number;\n\n character: number;\n\n /**\n * URL for displaying the source file.\n */\n url?: string;\n}\n\n/**\n * Exposes information about a source file.\n *\n * One my access a list of all source files through the [[ProjectReflection.files]] property or as\n * a tree structure through the [[ProjectReflection.directory]] property.\n *\n * Furthermore each reflection carries references to the related SourceFile with their\n * [[DeclarationReflection.sources]] property. It is an array of of [[IDeclarationSource]] instances\n * containing the reference in their [[IDeclarationSource.file]] field.\n */\nexport class SourceFile {\n /**\n * The original full system file name.\n */\n fullFileName: string;\n\n /**\n * A trimmed version of the file name. Contains only the path relative to the\n * determined base path.\n */\n fileName: string;\n\n /**\n * The base name of the file.\n */\n name: string;\n\n /**\n * A url pointing to a page displaying the contents of this file.\n */\n url: string;\n\n /**\n * The representation of the parent directory of this source file.\n */\n parent: SourceDirectory;\n\n /**\n * A list of all reflections that are declared in this file.\n */\n reflections: Reflection[] = [];\n\n /**\n * A grouped list of the reflections declared in this file.\n */\n groups: ReflectionGroup[];\n\n /**\n * A categorized list of the reflections declared in this file.\n */\n categories: ReflectionCategory[];\n\n /**\n * Create a new SourceFile instance.\n *\n * @param fullFileName The full file name.\n */\n constructor(fullFileName: string) {\n this.fileName = fullFileName;\n this.fullFileName = fullFileName;\n this.name = Path.basename(fullFileName);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/sources/index.d.ts b/dist/lib/models/sources/index.d.ts new file mode 100644 index 000000000..b65653d4a --- /dev/null +++ b/dist/lib/models/sources/index.d.ts @@ -0,0 +1,2 @@ +export { SourceDirectory } from './directory'; +export { SourceFile } from './file'; diff --git a/dist/lib/models/sources/index.js b/dist/lib/models/sources/index.js new file mode 100644 index 000000000..043925487 --- /dev/null +++ b/dist/lib/models/sources/index.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var directory_1 = require("./directory"); +exports.SourceDirectory = directory_1.SourceDirectory; +var file_1 = require("./file"); +exports.SourceFile = file_1.SourceFile; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/models/sources/index.js.map b/dist/lib/models/sources/index.js.map new file mode 100644 index 000000000..066bdb9a3 --- /dev/null +++ b/dist/lib/models/sources/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/models/sources/index.ts"],"names":[],"mappings":";;AAAA,yCAA8C;AAArC,sCAAA,eAAe,CAAA;AACxB,+BAAoC;AAA3B,4BAAA,UAAU,CAAA","sourcesContent":["export { SourceDirectory } from './directory';\nexport { SourceFile } from './file';\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/abstract.d.ts b/dist/lib/models/types/abstract.d.ts new file mode 100644 index 000000000..aa5da6492 --- /dev/null +++ b/dist/lib/models/types/abstract.d.ts @@ -0,0 +1,9 @@ +export declare abstract class Type { + readonly type: string; + abstract clone(): Type; + equals(type: Type): boolean; + toObject(): any; + toString(): string; + static isTypeListSimiliar(a: Type[], b: Type[]): boolean; + static isTypeListEqual(a: Type[], b: Type[]): boolean; +} diff --git a/dist/lib/models/types/abstract.js b/dist/lib/models/types/abstract.js new file mode 100644 index 000000000..8a0b7c684 --- /dev/null +++ b/dist/lib/models/types/abstract.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Type = (function () { + function Type() { + this.type = 'void'; + } + Type.prototype.equals = function (type) { + return false; + }; + Type.prototype.toObject = function () { + var result = {}; + result.type = this.type; + return result; + }; + Type.prototype.toString = function () { + return 'void'; + }; + Type.isTypeListSimiliar = function (a, b) { + if (a.length !== b.length) { + return false; + } + outerLoop: for (var an = 0, count = a.length; an < count; an++) { + var at = a[an]; + for (var bn = 0; bn < count; bn++) { + if (b[bn].equals(at)) { + continue outerLoop; + } + } + return false; + } + return true; + }; + Type.isTypeListEqual = function (a, b) { + if (a.length !== b.length) { + return false; + } + for (var index = 0, count = a.length; index < count; index++) { + if (!a[index].equals(b[index])) { + return false; + } + } + return true; + }; + return Type; +}()); +exports.Type = Type; +//# sourceMappingURL=abstract.js.map \ No newline at end of file diff --git a/dist/lib/models/types/abstract.js.map b/dist/lib/models/types/abstract.js.map new file mode 100644 index 000000000..4281a781b --- /dev/null +++ b/dist/lib/models/types/abstract.js.map @@ -0,0 +1 @@ +{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/lib/models/types/abstract.ts"],"names":[],"mappings":";;AAKA;IAAA;QAKa,SAAI,GAAW,MAAM,CAAC;IA+EnC,CAAC;IAhEG,qBAAM,GAAN,UAAO,IAAU;QACb,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAMD,uBAAQ,GAAR;QACI,IAAI,MAAM,GAAQ,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAExB,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,uBAAQ,GAAR;QACI,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAQM,uBAAkB,GAAzB,UAA0B,CAAS,EAAE,CAAS;QAC1C,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,M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represent the type `void`.\n */\nexport abstract class Type {\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'void';\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n abstract clone(): Type;\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: Type): boolean {\n return false;\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n let result: any = {};\n result.type = this.type;\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString(): string {\n return 'void';\n }\n\n /**\n * Test whether the two given list of types contain equal types.\n *\n * @param a\n * @param b\n */\n static isTypeListSimiliar(a: Type[], b: Type[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n outerLoop: for (let an = 0, count = a.length; an < count; an++) {\n const at = a[an];\n for (let bn = 0; bn < count; bn++) {\n if (b[bn].equals(at)) {\n continue outerLoop;\n }\n }\n\n return false;\n }\n\n return true;\n }\n\n /**\n * Test whether the two given list of types are equal.\n *\n * @param a\n * @param b\n */\n static isTypeListEqual(a: Type[], b: Type[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let index = 0, count = a.length; index < count; index++) {\n if (!a[index].equals(b[index])) {\n return false;\n }\n }\n\n return true;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/array.d.ts b/dist/lib/models/types/array.d.ts new file mode 100644 index 000000000..f83c26295 --- /dev/null +++ b/dist/lib/models/types/array.d.ts @@ -0,0 +1,10 @@ +import { Type } from './index'; +export declare class ArrayType extends Type { + elementType: Type; + readonly type: string; + constructor(elementType: Type); + clone(): Type; + equals(type: Type): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/array.js b/dist/lib/models/types/array.js new file mode 100644 index 000000000..47d9f4e52 --- /dev/null +++ b/dist/lib/models/types/array.js @@ -0,0 +1,48 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("./index"); +var ArrayType = (function (_super) { + __extends(ArrayType, _super); + function ArrayType(elementType) { + var _this = _super.call(this) || this; + _this.type = 'array'; + _this.elementType = elementType; + return _this; + } + ArrayType.prototype.clone = function () { + return new ArrayType(this.elementType); + }; + ArrayType.prototype.equals = function (type) { + if (!(type instanceof ArrayType)) { + return false; + } + return type.elementType.equals(this.elementType); + }; + ArrayType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + result.elementType = this.elementType.toObject(); + return result; + }; + ArrayType.prototype.toString = function () { + var elementTypeStr = this.elementType.toString(); + if (this.elementType instanceof index_1.UnionType || this.elementType instanceof index_1.IntersectionType) { + return '(' + elementTypeStr + ')[]'; + } + else { + return elementTypeStr + '[]'; + } + }; + return ArrayType; +}(index_1.Type)); +exports.ArrayType = ArrayType; +//# sourceMappingURL=array.js.map \ No newline at end of file diff --git a/dist/lib/models/types/array.js.map b/dist/lib/models/types/array.js.map new file mode 100644 index 000000000..766d9028e --- /dev/null +++ b/dist/lib/models/types/array.js.map @@ -0,0 +1 @@ +{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../src/lib/models/types/array.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAA4D;AAS5D;IAA+B,6BAAI;IAiB/B,mBAAY,WAAiB;QAA7B,YACI,iBAAO,SAEV;QAVQ,UAAI,GAAW,OAAO,CAAC;QAS5B,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;;IACnC,CAAC;IAOD,yBAAK,GAAL;QACI,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAQD,0BAAM,GAAN,UAAO,IAAU;QACb,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,SAAS,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAMD,4BAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QACrC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,4BAAQ,GAAR;QACI,IAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QACnD,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,YAAY,iBAAS,IAAI,IAAI,CAAC,WAAW,YAAY,wBAAgB,CAAC,CAAC,CAAC;YACxF,MAAM,CAAC,GAAG,GAAG,cAAc,GAAG,KAAK,CAAC;QACxC,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;QACjC,CAAC;IACL,CAAC;IACL,gBAAC;AAAD,CAAC,AAlED,CAA+B,YAAI,GAkElC;AAlEY,8BAAS","sourcesContent":["import { Type, UnionType, IntersectionType } from './index';\n\n/**\n * Represents an array type.\n *\n * ~~~\n * let value: string[];\n * ~~~\n */\nexport class ArrayType extends Type {\n\n /**\n * The type of the array elements.\n */\n elementType: Type;\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'array';\n\n /**\n * Create a new TupleType instance.\n *\n * @param elementType The type of the array's elements.\n */\n constructor(elementType: Type) {\n super();\n this.elementType = elementType;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new ArrayType(this.elementType);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: Type): boolean {\n if (!(type instanceof ArrayType)) {\n return false;\n }\n return type.elementType.equals(this.elementType);\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n result.elementType = this.elementType.toObject();\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n const elementTypeStr = this.elementType.toString();\n if (this.elementType instanceof UnionType || this.elementType instanceof IntersectionType) {\n return '(' + elementTypeStr + ')[]';\n } else {\n return elementTypeStr + '[]';\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/index.d.ts b/dist/lib/models/types/index.d.ts new file mode 100644 index 000000000..b8dccc31d --- /dev/null +++ b/dist/lib/models/types/index.d.ts @@ -0,0 +1,12 @@ +export { Type } from './abstract'; +export { ArrayType } from './array'; +export { IntrinsicType } from './intrinsic'; +export { IntersectionType } from './intersection'; +export { ReferenceType } from './reference'; +export { ReflectionType } from './reflection'; +export { StringLiteralType } from './string-literal'; +export { TupleType } from './tuple'; +export { TypeOperatorType } from './type-operator'; +export { TypeParameterType } from './type-parameter'; +export { UnionType } from './union'; +export { UnknownType } from './unknown'; diff --git a/dist/lib/models/types/index.js b/dist/lib/models/types/index.js new file mode 100644 index 000000000..cec8fed42 --- /dev/null +++ b/dist/lib/models/types/index.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +exports.Type = abstract_1.Type; +var array_1 = require("./array"); +exports.ArrayType = array_1.ArrayType; +var intrinsic_1 = require("./intrinsic"); +exports.IntrinsicType = intrinsic_1.IntrinsicType; +var intersection_1 = require("./intersection"); +exports.IntersectionType = intersection_1.IntersectionType; +var reference_1 = require("./reference"); +exports.ReferenceType = reference_1.ReferenceType; +var reflection_1 = require("./reflection"); +exports.ReflectionType = reflection_1.ReflectionType; +var string_literal_1 = require("./string-literal"); +exports.StringLiteralType = string_literal_1.StringLiteralType; +var tuple_1 = require("./tuple"); +exports.TupleType = tuple_1.TupleType; +var type_operator_1 = require("./type-operator"); +exports.TypeOperatorType = type_operator_1.TypeOperatorType; +var type_parameter_1 = require("./type-parameter"); +exports.TypeParameterType = type_parameter_1.TypeParameterType; +var union_1 = require("./union"); +exports.UnionType = union_1.UnionType; +var unknown_1 = require("./unknown"); +exports.UnknownType = unknown_1.UnknownType; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/models/types/index.js.map b/dist/lib/models/types/index.js.map new file mode 100644 index 000000000..84253177b --- /dev/null +++ b/dist/lib/models/types/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/models/types/index.ts"],"names":[],"mappings":";;AAAA,uCAAkC;AAAzB,0BAAA,IAAI,CAAA;AACb,iCAAoC;AAA3B,4BAAA,SAAS,CAAA;AAClB,yCAA4C;AAAnC,oCAAA,aAAa,CAAA;AACtB,+CAAkD;AAAzC,0CAAA,gBAAgB,CAAA;AACzB,yCAA4C;AAAnC,oCAAA,aAAa,CAAA;AACtB,2CAA8C;AAArC,sCAAA,cAAc,CAAA;AACvB,mDAAqD;AAA5C,6CAAA,iBAAiB,CAAA;AAC1B,iCAAoC;AAA3B,4BAAA,SAAS,CAAA;AAClB,iDAAmD;AAA1C,2CAAA,gBAAgB,CAAA;AACzB,mDAAqD;AAA5C,6CAAA,iBAAiB,CAAA;AAC1B,iCAAoC;AAA3B,4BAAA,SAAS,CAAA;AAClB,qCAAwC;AAA/B,gCAAA,WAAW,CAAA","sourcesContent":["export { Type } from './abstract';\nexport { ArrayType } from './array';\nexport { IntrinsicType } from './intrinsic';\nexport { IntersectionType } from './intersection';\nexport { ReferenceType } from './reference';\nexport { ReflectionType } from './reflection';\nexport { StringLiteralType } from './string-literal';\nexport { TupleType } from './tuple';\nexport { TypeOperatorType } from './type-operator';\nexport { TypeParameterType } from './type-parameter';\nexport { UnionType } from './union';\nexport { UnknownType } from './unknown';\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/intersection.d.ts b/dist/lib/models/types/intersection.d.ts new file mode 100644 index 000000000..3ac0e5c0e --- /dev/null +++ b/dist/lib/models/types/intersection.d.ts @@ -0,0 +1,10 @@ +import { Type } from './abstract'; +export declare class IntersectionType extends Type { + types: Type[]; + readonly type: string; + constructor(types: Type[]); + clone(): Type; + equals(type: IntersectionType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/intersection.js b/dist/lib/models/types/intersection.js new file mode 100644 index 000000000..1882170cb --- /dev/null +++ b/dist/lib/models/types/intersection.js @@ -0,0 +1,48 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var IntersectionType = (function (_super) { + __extends(IntersectionType, _super); + function IntersectionType(types) { + var _this = _super.call(this) || this; + _this.type = 'intersection'; + _this.types = types; + return _this; + } + IntersectionType.prototype.clone = function () { + return new IntersectionType(this.types); + }; + IntersectionType.prototype.equals = function (type) { + if (!(type instanceof IntersectionType)) { + return false; + } + return abstract_1.Type.isTypeListSimiliar(type.types, this.types); + }; + IntersectionType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.types && this.types.length) { + result.types = this.types.map(function (e) { return e.toObject(); }); + } + return result; + }; + IntersectionType.prototype.toString = function () { + var names = []; + this.types.forEach(function (element) { + names.push(element.toString()); + }); + return names.join(' & '); + }; + return IntersectionType; +}(abstract_1.Type)); +exports.IntersectionType = IntersectionType; +//# sourceMappingURL=intersection.js.map \ No newline at end of file diff --git a/dist/lib/models/types/intersection.js.map b/dist/lib/models/types/intersection.js.map new file mode 100644 index 000000000..4ed372167 --- /dev/null +++ b/dist/lib/models/types/intersection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"intersection.js","sourceRoot":"","sources":["../../../../src/lib/models/types/intersection.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkC;AASlC;IAAsC,oCAAI;IAgBtC,0BAAY,KAAa;QAAzB,YACI,iBAAO,SAEV;QAVQ,UAAI,GAAW,cAAc,CAAC;QASnC,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;;IACvB,CAAC;IAOD,gCAAK,GAAL;QACI,MAAM,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAQD,iCAAM,GAAN,UAAO,IAAsB;QACzB,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,gBAAgB,CAAC,CAAC,CAAC,CAAC;YACtC,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;QACD,MAAM,CAAC,eAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;IAMD,mCAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QAErC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,QAAQ,EAAE,EAAZ,CAAY,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,mCAAQ,GAAR;QACI,IAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAC,OAAO;YACvB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACL,uBAAC;AAAD,CAAC,AApED,CAAsC,eAAI,GAoEzC;AApEY,4CAAgB","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents an intersection type.\n *\n * ~~~\n * let value: A & B;\n * ~~~\n */\nexport class IntersectionType extends Type {\n /**\n * The types this union consists of.\n */\n types: Type[];\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'intersection';\n\n /**\n * Create a new TupleType instance.\n *\n * @param types The types this union consists of.\n */\n constructor(types: Type[]) {\n super();\n this.types = types;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new IntersectionType(this.types);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: IntersectionType): boolean {\n if (!(type instanceof IntersectionType)) {\n return false;\n }\n return Type.isTypeListSimiliar(type.types, this.types);\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n\n if (this.types && this.types.length) {\n result.types = this.types.map((e) => e.toObject());\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n const names: string[] = [];\n this.types.forEach((element) => {\n names.push(element.toString());\n });\n\n return names.join(' & ');\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/intrinsic.d.ts b/dist/lib/models/types/intrinsic.d.ts new file mode 100644 index 000000000..0c15120a1 --- /dev/null +++ b/dist/lib/models/types/intrinsic.d.ts @@ -0,0 +1,10 @@ +import { Type } from './abstract'; +export declare class IntrinsicType extends Type { + name: string; + readonly type: string; + constructor(name: string); + clone(): Type; + equals(type: IntrinsicType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/intrinsic.js b/dist/lib/models/types/intrinsic.js new file mode 100644 index 000000000..f1713fadf --- /dev/null +++ b/dist/lib/models/types/intrinsic.js @@ -0,0 +1,40 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var IntrinsicType = (function (_super) { + __extends(IntrinsicType, _super); + function IntrinsicType(name) { + var _this = _super.call(this) || this; + _this.type = 'intrinsic'; + _this.name = name; + return _this; + } + IntrinsicType.prototype.clone = function () { + return new IntrinsicType(this.name); + }; + IntrinsicType.prototype.equals = function (type) { + return type instanceof IntrinsicType && + type.name === this.name; + }; + IntrinsicType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + result.name = this.name; + return result; + }; + IntrinsicType.prototype.toString = function () { + return this.name; + }; + return IntrinsicType; +}(abstract_1.Type)); +exports.IntrinsicType = IntrinsicType; +//# sourceMappingURL=intrinsic.js.map \ No newline at end of file diff --git a/dist/lib/models/types/intrinsic.js.map b/dist/lib/models/types/intrinsic.js.map new file mode 100644 index 000000000..b870984ed --- /dev/null +++ b/dist/lib/models/types/intrinsic.js.map @@ -0,0 +1 @@ +{"version":3,"file":"intrinsic.js","sourceRoot":"","sources":["../../../../src/lib/models/types/intrinsic.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkC;AASlC;IAAmC,iCAAI;IAgBnC,uBAAY,IAAY;QAAxB,YACI,iBAAO,SAEV;QAVQ,UAAI,GAAW,WAAW,CAAC;QAShC,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACrB,CAAC;IAOD,6BAAK,GAAL;QACI,MAAM,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAQD,8BAAM,GAAN,UAAO,IAAmB;QACtB,MAAM,CAAC,IAAI,YAAY,aAAa;YAChC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;IAChC,CAAC;IAMD,gCAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QACrC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,gCAAQ,GAAR;QACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACL,oBAAC;AAAD,CAAC,AAzDD,CAAmC,eAAI,GAyDtC;AAzDY,sCAAa","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents an intrinsic type like `string` or `boolean`.\n *\n * ~~~\n * let value: number;\n * ~~~\n */\nexport class IntrinsicType extends Type {\n /**\n * The name of the intrinsic type like `string` or `boolean`.\n */\n name: string;\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'intrinsic';\n\n /**\n * Create a new instance of IntrinsicType.\n *\n * @param name The name of the intrinsic type like `string` or `boolean`.\n */\n constructor(name: string) {\n super();\n this.name = name;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new IntrinsicType(this.name);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: IntrinsicType): boolean {\n return type instanceof IntrinsicType &&\n type.name === this.name;\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n result.name = this.name;\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n return this.name;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/reference.d.ts b/dist/lib/models/types/reference.d.ts new file mode 100644 index 000000000..18fb2e603 --- /dev/null +++ b/dist/lib/models/types/reference.d.ts @@ -0,0 +1,16 @@ +import { Reflection } from '../reflections/abstract'; +import { Type } from './abstract'; +export declare class ReferenceType extends Type { + readonly type: string; + name: string; + typeArguments: Type[]; + symbolID: number; + reflection: Reflection; + static SYMBOL_ID_RESOLVED: number; + static SYMBOL_ID_RESOLVE_BY_NAME: number; + constructor(name: string, symbolID: number, reflection?: Reflection); + clone(): Type; + equals(type: ReferenceType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/reference.js b/dist/lib/models/types/reference.js new file mode 100644 index 000000000..480877287 --- /dev/null +++ b/dist/lib/models/types/reference.js @@ -0,0 +1,59 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var ReferenceType = (function (_super) { + __extends(ReferenceType, _super); + function ReferenceType(name, symbolID, reflection) { + var _this = _super.call(this) || this; + _this.type = 'reference'; + _this.name = name; + _this.symbolID = symbolID; + _this.reflection = reflection; + return _this; + } + ReferenceType.prototype.clone = function () { + var clone = new ReferenceType(this.name, this.symbolID, this.reflection); + clone.typeArguments = this.typeArguments; + return clone; + }; + ReferenceType.prototype.equals = function (type) { + return type instanceof ReferenceType && + (type.symbolID === this.symbolID || type.reflection === this.reflection); + }; + ReferenceType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + result.name = this.name; + if (this.reflection) { + result.id = this.reflection.id; + } + if (this.typeArguments) { + result.typeArguments = this.typeArguments.map(function (t) { return t.toObject(); }); + } + return result; + }; + ReferenceType.prototype.toString = function () { + var name = this.reflection ? this.reflection.name : this.name; + var typeArgs = ''; + if (this.typeArguments) { + typeArgs += '<'; + typeArgs += this.typeArguments.map(function (arg) { return arg.toString(); }).join(', '); + typeArgs += '>'; + } + return name + typeArgs; + }; + ReferenceType.SYMBOL_ID_RESOLVED = -1; + ReferenceType.SYMBOL_ID_RESOLVE_BY_NAME = -2; + return ReferenceType; +}(abstract_1.Type)); +exports.ReferenceType = ReferenceType; +//# sourceMappingURL=reference.js.map \ No newline at end of file diff --git a/dist/lib/models/types/reference.js.map b/dist/lib/models/types/reference.js.map new file mode 100644 index 000000000..f74700d10 --- /dev/null +++ b/dist/lib/models/types/reference.js.map @@ -0,0 +1 @@ +{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../../src/lib/models/types/reference.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,uCAAkC;AASlC;IAAmC,iCAAI;IAmDnC,uBAAY,IAAY,EAAE,QAAgB,EAAE,UAAuB;QAAnE,YACI,iBAAO,SAIV;QApDQ,UAAI,GAAW,WAAW,CAAC;QAiDhC,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;;IACjC,CAAC;IAOD,6BAAK,GAAL;QACI,IAAM,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3E,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAQD,8BAAM,GAAN,UAAO,IAAmB;QACtB,MAAM,CAAC,IAAI,YAAY,aAAa;YAChC,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,CAA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reflection } from '../reflections/abstract';\nimport { Type } from './abstract';\n\n/**\n * Represents a type that refers to another reflection like a class, interface or enum.\n *\n * ~~~\n * let value: MyClass;\n * ~~~\n */\nexport class ReferenceType extends Type {\n /**\n * The type name identifier.\n */\n readonly type: string = 'reference';\n\n /**\n * The name of the referenced type.\n *\n * If the symbol cannot be found cause it's not part of the documentation this\n * can be used to represent the type.\n */\n name: string;\n\n /**\n * The type arguments of this reference.\n */\n typeArguments: Type[];\n\n /**\n * The symbol id of the referenced type as returned from the TypeScript compiler.\n *\n * After the all reflections have been generated this is can be used to lookup the\n * relevant reflection with [[ProjectReflection.symbolMapping]].\n */\n symbolID: number;\n\n /**\n * The resolved reflection.\n *\n * The [[TypePlugin]] will try to set this property in the resolving phase.\n */\n reflection: Reflection;\n\n /**\n * Special symbol ID noting that the reference of a ReferenceType was known when creating the type.\n */\n static SYMBOL_ID_RESOLVED = -1;\n\n /**\n * Special symbol ID noting that the reference should be resolved by the type name.\n */\n static SYMBOL_ID_RESOLVE_BY_NAME = -2;\n\n /**\n * Create a new instance of ReferenceType.\n *\n * @param name The name of the referenced type.\n * @param symbolID The symbol id of the referenced type as returned from the TypeScript compiler.\n * @param reflection The resolved reflection if already known.\n */\n constructor(name: string, symbolID: number, reflection?: Reflection) {\n super();\n this.name = name;\n this.symbolID = symbolID;\n this.reflection = reflection;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n const clone = new ReferenceType(this.name, this.symbolID, this.reflection);\n clone.typeArguments = this.typeArguments;\n return clone;\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: ReferenceType): boolean {\n return type instanceof ReferenceType &&\n (type.symbolID === this.symbolID || type.reflection === this.reflection);\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n result.name = this.name;\n\n if (this.reflection) {\n result.id = this.reflection.id;\n }\n\n if (this.typeArguments) {\n result.typeArguments = this.typeArguments.map((t) => t.toObject());\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n * @example EventEmitter\n */\n toString() {\n const name = this.reflection ? this.reflection.name : this.name;\n let typeArgs = '';\n if (this.typeArguments) {\n typeArgs += '<';\n typeArgs += this.typeArguments.map(arg => arg.toString()).join(', ');\n typeArgs += '>';\n }\n\n return name + typeArgs;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/reflection.d.ts b/dist/lib/models/types/reflection.d.ts new file mode 100644 index 000000000..6061b532c --- /dev/null +++ b/dist/lib/models/types/reflection.d.ts @@ -0,0 +1,11 @@ +import { DeclarationReflection } from '../reflections/declaration'; +import { Type } from './abstract'; +export declare class ReflectionType extends Type { + declaration: DeclarationReflection; + readonly type: string; + constructor(declaration: DeclarationReflection); + clone(): Type; + equals(type: ReflectionType): boolean; + toObject(): any; + toString(): "function" | "object"; +} diff --git a/dist/lib/models/types/reflection.js b/dist/lib/models/types/reflection.js new file mode 100644 index 000000000..886bdf45b --- /dev/null +++ b/dist/lib/models/types/reflection.js @@ -0,0 +1,46 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var ReflectionType = (function (_super) { + __extends(ReflectionType, _super); + function ReflectionType(declaration) { + var _this = _super.call(this) || this; + _this.type = 'reflection'; + _this.declaration = declaration; + return _this; + } + ReflectionType.prototype.clone = function () { + return new ReflectionType(this.declaration); + }; + ReflectionType.prototype.equals = function (type) { + return type === this; + }; + ReflectionType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.declaration) { + result.declaration = this.declaration.toObject(); + } + return result; + }; + ReflectionType.prototype.toString = function () { + if (!this.declaration.children && this.declaration.signatures) { + return 'function'; + } + else { + return 'object'; + } + }; + return ReflectionType; +}(abstract_1.Type)); +exports.ReflectionType = ReflectionType; +//# sourceMappingURL=reflection.js.map \ No newline at end of file diff --git a/dist/lib/models/types/reflection.js.map b/dist/lib/models/types/reflection.js.map new file mode 100644 index 000000000..f9191d103 --- /dev/null +++ b/dist/lib/models/types/reflection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"reflection.js","sourceRoot":"","sources":["../../../../src/lib/models/types/reflection.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,uCAAkC;AASlC;IAAoC,kCAAI;IAgBpC,wBAAY,WAAkC;QAA9C,YACI,iBAAO,SAEV;QAVQ,UAAI,GAAW,YAAY,CAAC;QASjC,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;;IACnC,CAAC;IAOD,8BAAK,GAAL;QACI,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAQD,+BAAM,GAAN,UAAO,IAAoB;QACvB,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;IACzB,CAAC;IAMD,iCAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QAErC,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YACnB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QACrD,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,iCAAQ,GAAR;QACI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;YAC5D,MAAM,CAAC,UAAU,CAAC;QACtB,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,MAAM,CAAC,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;IACL,qBAAC;AAAD,CAAC,AAhED,CAAoC,eAAI,GAgEvC;AAhEY,wCAAc","sourcesContent":["import { DeclarationReflection } from '../reflections/declaration';\nimport { Type } from './abstract';\n\n/**\n * Represents a type which has it's own reflection like literal types.\n *\n * ~~~\n * let value: {subValueA;subValueB;subValueC;};\n * ~~~\n */\nexport class ReflectionType extends Type {\n /**\n * The reflection of the type.\n */\n declaration: DeclarationReflection;\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'reflection';\n\n /**\n * Create a new instance of ReflectionType.\n *\n * @param declaration The reflection of the type.\n */\n constructor(declaration: DeclarationReflection) {\n super();\n this.declaration = declaration;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new ReflectionType(this.declaration);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: ReflectionType): boolean {\n return type === this;\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n\n if (this.declaration) {\n result.declaration = this.declaration.toObject();\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n if (!this.declaration.children && this.declaration.signatures) {\n return 'function';\n } else {\n return 'object';\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/string-literal.d.ts b/dist/lib/models/types/string-literal.d.ts new file mode 100644 index 000000000..557bc6fd5 --- /dev/null +++ b/dist/lib/models/types/string-literal.d.ts @@ -0,0 +1,10 @@ +import { Type } from './abstract'; +export declare class StringLiteralType extends Type { + value: string; + readonly type: string; + constructor(value: string); + clone(): Type; + equals(type: StringLiteralType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/string-literal.js b/dist/lib/models/types/string-literal.js new file mode 100644 index 000000000..b275c2895 --- /dev/null +++ b/dist/lib/models/types/string-literal.js @@ -0,0 +1,40 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var StringLiteralType = (function (_super) { + __extends(StringLiteralType, _super); + function StringLiteralType(value) { + var _this = _super.call(this) || this; + _this.type = 'stringLiteral'; + _this.value = value; + return _this; + } + StringLiteralType.prototype.clone = function () { + return new StringLiteralType(this.value); + }; + StringLiteralType.prototype.equals = function (type) { + return type instanceof StringLiteralType && + type.value === this.value; + }; + StringLiteralType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + result.value = this.value; + return result; + }; + StringLiteralType.prototype.toString = function () { + return '"' + this.value + '"'; + }; + return StringLiteralType; +}(abstract_1.Type)); +exports.StringLiteralType = StringLiteralType; +//# sourceMappingURL=string-literal.js.map \ No newline at end of file diff --git a/dist/lib/models/types/string-literal.js.map b/dist/lib/models/types/string-literal.js.map new file mode 100644 index 000000000..8e729485e --- /dev/null +++ b/dist/lib/models/types/string-literal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"string-literal.js","sourceRoot":"","sources":["../../../../src/lib/models/types/string-literal.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkC;AASlC;IAAuC,qCAAI;IAgBvC,2BAAY,KAAa;QAAzB,YACI,iBAAO,SAEV;QAVQ,UAAI,GAAW,eAAe,CAAC;QASpC,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;;IACvB,CAAC;IAOD,iCAAK,GAAL;QACI,MAAM,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAQD,kCAAM,GAAN,UAAO,IAAuB;QAC1B,MAAM,CAAC,IAAI,YAAY,iBAAiB;YACpC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC;IAClC,CAAC;IAMD,oCAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QACrC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC1B,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,oCAAQ,GAAR;QACI,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IAClC,CAAC;IACL,wBAAC;AAAD,CAAC,AAzDD,CAAuC,eAAI,GAyD1C;AAzDY,8CAAiB","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents a string literal type.\n *\n * ~~~\n * let value: \"DIV\";\n * ~~~\n */\nexport class StringLiteralType extends Type {\n /**\n * The string literal value.\n */\n value: string;\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'stringLiteral';\n\n /**\n * Create a new instance of StringLiteralType.\n *\n * @param value The string literal value.\n */\n constructor(value: string) {\n super();\n this.value = value;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new StringLiteralType(this.value);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: StringLiteralType): boolean {\n return type instanceof StringLiteralType &&\n type.value === this.value;\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n result.value = this.value;\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString(): string {\n return '\"' + this.value + '\"';\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/tuple.d.ts b/dist/lib/models/types/tuple.d.ts new file mode 100644 index 000000000..9e9560e03 --- /dev/null +++ b/dist/lib/models/types/tuple.d.ts @@ -0,0 +1,10 @@ +import { Type } from './abstract'; +export declare class TupleType extends Type { + elements: Type[]; + readonly type: string; + constructor(elements: Type[]); + clone(): Type; + equals(type: TupleType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/tuple.js b/dist/lib/models/types/tuple.js new file mode 100644 index 000000000..743d72bb7 --- /dev/null +++ b/dist/lib/models/types/tuple.js @@ -0,0 +1,48 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var TupleType = (function (_super) { + __extends(TupleType, _super); + function TupleType(elements) { + var _this = _super.call(this) || this; + _this.type = 'tuple'; + _this.elements = elements; + return _this; + } + TupleType.prototype.clone = function () { + return new TupleType(this.elements); + }; + TupleType.prototype.equals = function (type) { + if (!(type instanceof TupleType)) { + return false; + } + return abstract_1.Type.isTypeListEqual(type.elements, this.elements); + }; + TupleType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.elements && this.elements.length) { + result.elements = this.elements.map(function (e) { return e.toObject(); }); + } + return result; + }; + TupleType.prototype.toString = function () { + var names = []; + this.elements.forEach(function (element) { + names.push(element.toString()); + }); + return '[' + names.join(', ') + ']'; + }; + return TupleType; +}(abstract_1.Type)); +exports.TupleType = TupleType; +//# sourceMappingURL=tuple.js.map \ No newline at end of file diff --git a/dist/lib/models/types/tuple.js.map b/dist/lib/models/types/tuple.js.map new file mode 100644 index 000000000..490ccb9f1 --- /dev/null +++ b/dist/lib/models/types/tuple.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tuple.js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AI,CAAC,GAAG,GAAG,CAAC;IACxC,CAAC;IACL,gBAAC;AAAD,CAAC,AApED,CAA+B,eAAI,GAoElC;AApEY,8BAAS","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents a tuple type.\n *\n * ~~~\n * let value: [string,boolean];\n * ~~~\n */\nexport class TupleType extends Type {\n /**\n * The ordered type elements of the tuple type.\n */\n elements: Type[];\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'tuple';\n\n /**\n * Create a new TupleType instance.\n *\n * @param elements The ordered type elements of the tuple type.\n */\n constructor(elements: Type[]) {\n super();\n this.elements = elements;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new TupleType(this.elements);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: TupleType): boolean {\n if (!(type instanceof TupleType)) {\n return false;\n }\n return Type.isTypeListEqual(type.elements, this.elements);\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n\n if (this.elements && this.elements.length) {\n result.elements = this.elements.map((e) => e.toObject());\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n const names: string[] = [];\n this.elements.forEach((element) => {\n names.push(element.toString());\n });\n\n return '[' + names.join(', ') + ']';\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/type-operator.d.ts b/dist/lib/models/types/type-operator.d.ts new file mode 100644 index 000000000..78da13dfe --- /dev/null +++ b/dist/lib/models/types/type-operator.d.ts @@ -0,0 +1,11 @@ +import { Type } from './abstract'; +export declare class TypeOperatorType extends Type { + readonly type: string; + target: Type; + operator: 'keyof'; + constructor(target: Type); + clone(): Type; + equals(type: TypeOperatorType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/type-operator.js b/dist/lib/models/types/type-operator.js new file mode 100644 index 000000000..866450fa9 --- /dev/null +++ b/dist/lib/models/types/type-operator.js @@ -0,0 +1,44 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var TypeOperatorType = (function (_super) { + __extends(TypeOperatorType, _super); + function TypeOperatorType(target) { + var _this = _super.call(this) || this; + _this.type = 'typeOperator'; + _this.operator = 'keyof'; + _this.target = target; + return _this; + } + TypeOperatorType.prototype.clone = function () { + return new TypeOperatorType(this.target.clone()); + }; + TypeOperatorType.prototype.equals = function (type) { + if (!(type instanceof TypeOperatorType)) { + return false; + } + return type.target.equals(this.target); + }; + TypeOperatorType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + result.operator = this.operator; + result.target = this.target.toObject(); + return result; + }; + TypeOperatorType.prototype.toString = function () { + return "keyof " + this.target.toString(); + }; + return TypeOperatorType; +}(abstract_1.Type)); +exports.TypeOperatorType = TypeOperatorType; +//# sourceMappingURL=type-operator.js.map \ No newline at end of file diff --git a/dist/lib/models/types/type-operator.js.map b/dist/lib/models/types/type-operator.js.map new file mode 100644 index 000000000..1ad867e07 --- /dev/null +++ b/dist/lib/models/types/type-operator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"type-operator.js","sourceRoot":"","sources":["../../../../src/lib/models/types/type-operator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkC;AAUlC;IAAsC,oCAAI;IAYtC,0BAAY,MAAY;QAAxB,YACI,iBAAO,SAEV;QAXQ,UAAI,GAAW,cAAc,CAAC;QAMvC,cAAQ,GAAY,OAAO,CAAC;QAIxB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;IACzB,CAAC;IAOD,gCAAK,GAAL;QACI,MAAM,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IAQD,iCAAM,GAAN,UAAO,IAAsB;QACzB,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,gBAAgB,CAAC,CAAC,CAAC,CAAC;YACtC,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAKD,mCAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QACrC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAChC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,mCAAQ,GAAR;QACI,MAAM,CAAC,WAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAI,CAAC;IAC7C,CAAC;IACL,uBAAC;AAAD,CAAC,AAxDD,CAAsC,eAAI,GAwDzC;AAxDY,4CAAgB","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents a type operator type.\n *\n * ~~~\n * class A {}\n * class B {}\n * ~~~\n */\nexport class TypeOperatorType extends Type {\n /**\n * The type name identifier.\n */\n readonly type: string = 'typeOperator';\n\n target: Type;\n\n // currently, there is only one type operator, this is always \"keyof\"\n // but, if more types will be added in the future we are ready.\n operator: 'keyof' = 'keyof';\n\n constructor(target: Type) {\n super();\n this.target = target;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new TypeOperatorType(this.target.clone());\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: TypeOperatorType): boolean {\n if (!(type instanceof TypeOperatorType)) {\n return false;\n }\n\n return type.target.equals(this.target);\n }\n\n /**\n * Return a raw object representation of this type.\n */\n toObject(): any {\n const result: any = super.toObject();\n result.operator = this.operator;\n result.target = this.target.toObject();\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n return `keyof ${this.target.toString()}`;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/type-parameter.d.ts b/dist/lib/models/types/type-parameter.d.ts new file mode 100644 index 000000000..7798d1be7 --- /dev/null +++ b/dist/lib/models/types/type-parameter.d.ts @@ -0,0 +1,10 @@ +import { Type } from './abstract'; +export declare class TypeParameterType extends Type { + name: string; + constraint: Type; + readonly type: string; + clone(): Type; + equals(type: TypeParameterType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/type-parameter.js b/dist/lib/models/types/type-parameter.js new file mode 100644 index 000000000..78af575ba --- /dev/null +++ b/dist/lib/models/types/type-parameter.js @@ -0,0 +1,55 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var TypeParameterType = (function (_super) { + __extends(TypeParameterType, _super); + function TypeParameterType() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.type = 'typeParameter'; + return _this; + } + TypeParameterType.prototype.clone = function () { + var clone = new TypeParameterType(); + clone.name = this.name; + clone.constraint = this.constraint; + return clone; + }; + TypeParameterType.prototype.equals = function (type) { + if (!(type instanceof TypeParameterType)) { + return false; + } + if (this.constraint && type.constraint) { + return type.constraint.equals(this.constraint); + } + else if (!this.constraint && !type.constraint) { + return true; + } + else { + return false; + } + }; + TypeParameterType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + result.name = this.name; + if (this.constraint) { + result.constraint = this.constraint.toObject(); + } + return result; + }; + TypeParameterType.prototype.toString = function () { + return this.name; + }; + return TypeParameterType; +}(abstract_1.Type)); +exports.TypeParameterType = TypeParameterType; +//# sourceMappingURL=type-parameter.js.map \ No newline at end of file diff --git a/dist/lib/models/types/type-parameter.js.map b/dist/lib/models/types/type-parameter.js.map new file mode 100644 index 000000000..44f0539c5 --- /dev/null +++ b/dist/lib/models/types/type-parameter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"type-parameter.js","sourceRoot":"","sources":["../../../../src/lib/models/types/type-parameter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkC;AASlC;IAAuC,qCAAI;IAA3C;QAAA,qEAkEC;QAvDY,UAAI,GAAW,eAAe,CAAC;;IAuD5C,CAAC;IAhDG,iCAAK,GAAL;QACI,IAAM,KAAK,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAQD,kCAAM,GAAN,UAAO,IAAuB;QAC1B,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,iBAAiB,CAAC,CAAC,CAAC,CAAC;YACvC,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;QAED,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnD,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IAMD,oCAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QACrC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAExB,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YAClB,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QACnD,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,oCAAQ,GAAR;QACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACL,wBAAC;AAAD,CAAC,AAlED,CAAuC,eAAI,GAkE1C;AAlEY,8CAAiB","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents a type parameter type.\n *\n * ~~~\n * let value: T;\n * ~~~\n */\nexport class TypeParameterType extends Type {\n /**\n *\n */\n name: string;\n\n constraint: Type;\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'typeParameter';\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n const clone = new TypeParameterType();\n clone.name = this.name;\n clone.constraint = this.constraint;\n return clone;\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: TypeParameterType): boolean {\n if (!(type instanceof TypeParameterType)) {\n return false;\n }\n\n if (this.constraint && type.constraint) {\n return type.constraint.equals(this.constraint);\n } else if (!this.constraint && !type.constraint) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n result.name = this.name;\n\n if (this.constraint) {\n result.constraint = this.constraint.toObject();\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n return this.name;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/union.d.ts b/dist/lib/models/types/union.d.ts new file mode 100644 index 000000000..3addad437 --- /dev/null +++ b/dist/lib/models/types/union.d.ts @@ -0,0 +1,10 @@ +import { Type } from './abstract'; +export declare class UnionType extends Type { + types: Type[]; + readonly type: string; + constructor(types: Type[]); + clone(): Type; + equals(type: UnionType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/union.js b/dist/lib/models/types/union.js new file mode 100644 index 000000000..5007a10cf --- /dev/null +++ b/dist/lib/models/types/union.js @@ -0,0 +1,48 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var UnionType = (function (_super) { + __extends(UnionType, _super); + function UnionType(types) { + var _this = _super.call(this) || this; + _this.type = 'union'; + _this.types = types; + return _this; + } + UnionType.prototype.clone = function () { + return new UnionType(this.types); + }; + UnionType.prototype.equals = function (type) { + if (!(type instanceof UnionType)) { + return false; + } + return abstract_1.Type.isTypeListSimiliar(type.types, this.types); + }; + UnionType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + if (this.types && this.types.length) { + result.types = this.types.map(function (e) { return e.toObject(); }); + } + return result; + }; + UnionType.prototype.toString = function () { + var names = []; + this.types.forEach(function (element) { + names.push(element.toString()); + }); + return names.join(' | '); + }; + return UnionType; +}(abstract_1.Type)); +exports.UnionType = UnionType; +//# sourceMappingURL=union.js.map \ No newline at end of file diff --git a/dist/lib/models/types/union.js.map b/dist/lib/models/types/union.js.map new file mode 100644 index 000000000..02eff8443 --- /dev/null +++ b/dist/lib/models/types/union.js.map @@ -0,0 +1 @@ +{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../../src/lib/models/types/union.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkC;AASlC;IAA+B,6BAAI;IAgB/B,mBAAY,KAAa;QAAzB,YACI,iBAAO,SAEV;QAVQ,UAAI,GAAW,OAAO,CAAC;QAS5B,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;;IACvB,CAAC;IAOD,yBAAK,GAAL;QACI,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAQD,0BAAM,GAAN,UAAO,IAAe;QAClB,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,SAAS,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;QACD,MAAM,CAAC,eAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;IAMD,4BAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QAErC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,QAAQ,EAAE,EAAZ,CAAY,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,4BAAQ,GAAR;QACI,IAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAC,OAAO;YACvB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACL,gBAAC;AAAD,CAAC,AApED,CAA+B,eAAI,GAoElC;AApEY,8BAAS","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents an union type.\n *\n * ~~~\n * let value: string | string[];\n * ~~~\n */\nexport class UnionType extends Type {\n /**\n * The types this union consists of.\n */\n types: Type[];\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'union';\n\n /**\n * Create a new TupleType instance.\n *\n * @param types The types this union consists of.\n */\n constructor(types: Type[]) {\n super();\n this.types = types;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new UnionType(this.types);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: UnionType): boolean {\n if (!(type instanceof UnionType)) {\n return false;\n }\n return Type.isTypeListSimiliar(type.types, this.types);\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n\n if (this.types && this.types.length) {\n result.types = this.types.map((e) => e.toObject());\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n const names: string[] = [];\n this.types.forEach((element) => {\n names.push(element.toString());\n });\n\n return names.join(' | ');\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/models/types/unknown.d.ts b/dist/lib/models/types/unknown.d.ts new file mode 100644 index 000000000..cff3dfe97 --- /dev/null +++ b/dist/lib/models/types/unknown.d.ts @@ -0,0 +1,10 @@ +import { Type } from './abstract'; +export declare class UnknownType extends Type { + name: string; + readonly type: string; + constructor(name: string); + clone(): Type; + equals(type: UnknownType): boolean; + toObject(): any; + toString(): string; +} diff --git a/dist/lib/models/types/unknown.js b/dist/lib/models/types/unknown.js new file mode 100644 index 000000000..01f927b39 --- /dev/null +++ b/dist/lib/models/types/unknown.js @@ -0,0 +1,40 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_1 = require("./abstract"); +var UnknownType = (function (_super) { + __extends(UnknownType, _super); + function UnknownType(name) { + var _this = _super.call(this) || this; + _this.type = 'unknown'; + _this.name = name; + return _this; + } + UnknownType.prototype.clone = function () { + return new UnknownType(this.name); + }; + UnknownType.prototype.equals = function (type) { + return type instanceof UnknownType && + type.name === this.name; + }; + UnknownType.prototype.toObject = function () { + var result = _super.prototype.toObject.call(this); + result.name = this.name; + return result; + }; + UnknownType.prototype.toString = function () { + return this.name; + }; + return UnknownType; +}(abstract_1.Type)); +exports.UnknownType = UnknownType; +//# sourceMappingURL=unknown.js.map \ No newline at end of file diff --git a/dist/lib/models/types/unknown.js.map b/dist/lib/models/types/unknown.js.map new file mode 100644 index 000000000..412299e27 --- /dev/null +++ b/dist/lib/models/types/unknown.js.map @@ -0,0 +1 @@ +{"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../../src/lib/models/types/unknown.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkC;AAKlC;IAAiC,+BAAI;IAgBjC,qBAAY,IAAY;QAAxB,YACI,iBAAO,SAEV;QAVQ,UAAI,GAAW,SAAS,CAAC;QAS9B,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACrB,CAAC;IAOD,2BAAK,GAAL;QACI,MAAM,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAQD,4BAAM,GAAN,UAAO,IAAiB;QACpB,MAAM,CAAC,IAAI,YAAY,WAAW;YAC9B,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;IAChC,CAAC;IAMD,8BAAQ,GAAR;QACI,IAAM,MAAM,GAAQ,iBAAM,QAAQ,WAAE,CAAC;QACrC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAKD,8BAAQ,GAAR;QACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACL,kBAAC;AAAD,CAAC,AAzDD,CAAiC,eAAI,GAyDpC;AAzDY,kCAAW","sourcesContent":["import { Type } from './abstract';\n\n/**\n * Represents all unknown types.\n */\nexport class UnknownType extends Type {\n /**\n * A string representation of the type as returned from TypeScript compiler.\n */\n name: string;\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'unknown';\n\n /**\n * Create a new instance of UnknownType.\n *\n * @param name A string representation of the type as returned from TypeScript compiler.\n */\n constructor(name: string) {\n super();\n this.name = name;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new UnknownType(this.name);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: UnknownType): boolean {\n return type instanceof UnknownType &&\n type.name === this.name;\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n result.name = this.name;\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n return this.name;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/components.d.ts b/dist/lib/output/components.d.ts new file mode 100644 index 000000000..bc227cd49 --- /dev/null +++ b/dist/lib/output/components.d.ts @@ -0,0 +1,17 @@ +import { Component, AbstractComponent } from '../utils/component'; +import { ProjectReflection, DeclarationReflection } from '../models/reflections/index'; +import { Renderer } from './renderer'; +import { RendererEvent, PageEvent } from './events'; +export { Component }; +export declare abstract class RendererComponent extends AbstractComponent { +} +export declare abstract class ContextAwareRendererComponent extends RendererComponent { + protected project: ProjectReflection; + protected reflection: DeclarationReflection; + private location; + protected urlPrefix: RegExp; + protected initialize(): void; + getRelativeUrl(absolute: string): string; + protected onBeginRenderer(event: RendererEvent): void; + protected onBeginPage(page: PageEvent): void; +} diff --git a/dist/lib/output/components.js b/dist/lib/output/components.js new file mode 100644 index 000000000..6dc853c6c --- /dev/null +++ b/dist/lib/output/components.js @@ -0,0 +1,59 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var component_1 = require("../utils/component"); +exports.Component = component_1.Component; +var index_1 = require("../models/reflections/index"); +var events_1 = require("./events"); +var RendererComponent = (function (_super) { + __extends(RendererComponent, _super); + function RendererComponent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return RendererComponent; +}(component_1.AbstractComponent)); +exports.RendererComponent = RendererComponent; +var ContextAwareRendererComponent = (function (_super) { + __extends(ContextAwareRendererComponent, _super); + function ContextAwareRendererComponent() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.urlPrefix = /^(http|ftp)s?:\/\//; + return _this; + } + ContextAwareRendererComponent.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[events_1.RendererEvent.BEGIN] = this.onBeginRenderer, + _a[events_1.PageEvent.BEGIN] = this.onBeginPage, + _a)); + var _a; + }; + ContextAwareRendererComponent.prototype.getRelativeUrl = function (absolute) { + if (this.urlPrefix.test(absolute)) { + return absolute; + } + else { + var relative = Path.relative(Path.dirname(this.location), Path.dirname(absolute)); + return Path.join(relative, Path.basename(absolute)).replace(/\\/g, '/'); + } + }; + ContextAwareRendererComponent.prototype.onBeginRenderer = function (event) { + this.project = event.project; + }; + ContextAwareRendererComponent.prototype.onBeginPage = function (page) { + this.location = page.url; + this.reflection = page.model instanceof index_1.DeclarationReflection ? page.model : null; + }; + return ContextAwareRendererComponent; +}(RendererComponent)); +exports.ContextAwareRendererComponent = ContextAwareRendererComponent; +//# sourceMappingURL=components.js.map \ No newline at end of file diff --git a/dist/lib/output/components.js.map b/dist/lib/output/components.js.map new file mode 100644 index 000000000..7a8c7ae08 --- /dev/null +++ b/dist/lib/output/components.js.map @@ -0,0 +1 @@ +{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/lib/output/components.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA6B;AAE7B,gDAAkE;AAK1D,oBALC,qBAAS,CAKD;AAJjB,qDAAuF;AAEvF,mCAAoD;AAIpD;IAAgD,qCAA2B;IAA3E;;IAA8E,CAAC;IAAD,wBAAC;AAAD,CAAC,AAA/E,CAAgD,6BAAiB,GAAc;AAAzD,8CAAiB;AAKvC;IAA4D,iDAAiB;IAA7E;QAAA,qEAkEC;QA/Ca,eAAS,GAAW,oBAAoB,CAAC;;IA+CvD,CAAC;IAxCa,kDAAU,GAApB;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,sBAAa,CAAC,KAAK,IAAG,IAAI,CAAC,eAAe;YAC3C,GAAC,kBAAS,CAAC,KAAK,IAAO,IAAI,CAAC,WAAW;gBACzC,CAAC;;IACP,CAAC;IAQM,sDAAc,GAArB,UAAsB,QAAgB;QAClC,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,QAAQ,CAAC;QACpB,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YACpF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC5E,CAAC;IACL,CAAC;IAOS,uDAAe,GAAzB,UAA0B,KAAoB;QAC1C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IACjC,CAAC;IAOS,mDAAW,GAArB,UAAsB,IAAe;QACjC,IAAI,CAAC,QAAQ,GAAK,IAAI,CAAC,GAAG,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,YAAY,6BAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACtF,CAAC;IACL,oCAAC;AAAD,CAAC,AAlED,CAA4D,iBAAiB,GAkE5E;AAlEqB,sEAA6B","sourcesContent":["import * as Path from 'path';\n\nimport { Component, AbstractComponent } from '../utils/component';\nimport { ProjectReflection, DeclarationReflection } from '../models/reflections/index';\nimport { Renderer } from './renderer';\nimport { RendererEvent, PageEvent } from './events';\n\nexport {Component};\n\nexport abstract class RendererComponent extends AbstractComponent { }\n\n/**\n * A plugin for the renderer that reads the current render context.\n */\nexport abstract class ContextAwareRendererComponent extends RendererComponent {\n /**\n * The project that is currently processed.\n */\n protected project: ProjectReflection;\n\n /**\n * The reflection that is currently processed.\n */\n protected reflection: DeclarationReflection;\n\n /**\n * The url of the document that is being currently generated.\n */\n private location: string;\n\n /**\n * Regular expression to test if a string looks like an external url.\n */\n protected urlPrefix: RegExp = /^(http|ftp)s?:\\/\\//;\n\n /**\n * Create a new ContextAwareRendererPlugin instance.\n *\n * @param renderer The renderer this plugin should be attached to.\n */\n protected initialize() {\n this.listenTo(this.owner, {\n [RendererEvent.BEGIN]: this.onBeginRenderer,\n [PageEvent.BEGIN]: this.onBeginPage\n });\n }\n\n /**\n * Transform the given absolute path into a relative path.\n *\n * @param absolute The absolute path to transform.\n * @returns A path relative to the document currently processed.\n */\n public getRelativeUrl(absolute: string): string {\n if (this.urlPrefix.test(absolute)) {\n return absolute;\n } else {\n const relative = Path.relative(Path.dirname(this.location), Path.dirname(absolute));\n return Path.join(relative, Path.basename(absolute)).replace(/\\\\/g, '/');\n }\n }\n\n /**\n * Triggered before the renderer starts rendering a project.\n *\n * @param event An event object describing the current render operation.\n */\n protected onBeginRenderer(event: RendererEvent) {\n this.project = event.project;\n }\n\n /**\n * Triggered before a document will be rendered.\n *\n * @param page An event object describing the current render operation.\n */\n protected onBeginPage(page: PageEvent) {\n this.location = page.url;\n this.reflection = page.model instanceof DeclarationReflection ? page.model : null;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/events.d.ts b/dist/lib/output/events.d.ts new file mode 100644 index 000000000..9659cc53c --- /dev/null +++ b/dist/lib/output/events.d.ts @@ -0,0 +1,33 @@ +/// +import { Event } from '../utils/events'; +import { ProjectReflection } from '../models/reflections/project'; +import { UrlMapping } from './models/UrlMapping'; +import { NavigationItem } from './models/NavigationItem'; +export declare class RendererEvent extends Event { + project: ProjectReflection; + settings: any; + outputDirectory: string; + urls: UrlMapping[]; + static BEGIN: string; + static END: string; + createPageEvent(mapping: UrlMapping): PageEvent; +} +export declare class PageEvent extends Event { + project: ProjectReflection; + settings: any; + filename: string; + url: string; + model: any; + template: HandlebarsTemplateDelegate; + templateName: string; + navigation: NavigationItem; + toc: NavigationItem; + contents: string; + static BEGIN: string; + static END: string; +} +export declare class MarkdownEvent extends Event { + originalText: string; + parsedText: string; + static PARSE: string; +} diff --git a/dist/lib/output/events.js b/dist/lib/output/events.js new file mode 100644 index 000000000..d8a4cf054 --- /dev/null +++ b/dist/lib/output/events.js @@ -0,0 +1,54 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var events_1 = require("../utils/events"); +var RendererEvent = (function (_super) { + __extends(RendererEvent, _super); + function RendererEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + RendererEvent.prototype.createPageEvent = function (mapping) { + var event = new PageEvent(PageEvent.BEGIN); + event.project = this.project; + event.settings = this.settings; + event.url = mapping.url; + event.model = mapping.model; + event.templateName = mapping.template; + event.filename = Path.join(this.outputDirectory, mapping.url); + return event; + }; + RendererEvent.BEGIN = 'beginRender'; + RendererEvent.END = 'endRender'; + return RendererEvent; +}(events_1.Event)); +exports.RendererEvent = RendererEvent; +var PageEvent = (function (_super) { + __extends(PageEvent, _super); + function PageEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + PageEvent.BEGIN = 'beginPage'; + PageEvent.END = 'endPage'; + return PageEvent; +}(events_1.Event)); +exports.PageEvent = PageEvent; +var MarkdownEvent = (function (_super) { + __extends(MarkdownEvent, _super); + function MarkdownEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + MarkdownEvent.PARSE = 'parseMarkdown'; + return MarkdownEvent; +}(events_1.Event)); +exports.MarkdownEvent = MarkdownEvent; +//# sourceMappingURL=events.js.map \ No newline at end of file diff --git a/dist/lib/output/events.js.map b/dist/lib/output/events.js.map new file mode 100644 index 000000000..e7c0e370b --- /dev/null +++ b/dist/lib/output/events.js.map @@ -0,0 +1 @@ +{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/lib/output/events.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA6B;AAE7B,0CAAwC;AAYxC;IAAmC,iCAAK;IAAxC;;IAoDA,CAAC;IAVU,uCAAe,GAAtB,UAAuB,OAAmB;QACtC,IAAM,KAAK,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC7C,KAAK,CAAC,OAAO,GAAQ,IAAI,CAAC,OAAO,CAAC;QAClC,KAAK,CAAC,QAAQ,GAAO,IAAI,CAAC,QAAQ,CAAC;QACnC,KAAK,CAAC,GAAG,GAAY,OAAO,CAAC,GAAG,CAAC;QACjC,KAAK,CAAC,KAAK,GAAU,OAAO,CAAC,KAAK,CAAC;QACnC,KAAK,CAAC,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;QACtC,KAAK,CAAC,QAAQ,GAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAxBM,mBAAK,GAAG,aAAa,CAAC;IAMtB,iBAAG,GAAG,WAAW,CAAC;IAmB7B,oBAAC;CAAA,AApDD,CAAmC,cAAK,GAoDvC;AApDY,sCAAa;AA+D1B;IAA+B,6BAAK;IAApC;;IAgEA,CAAC;IAPU,eAAK,GAAG,WAAW,CAAC;IAMpB,aAAG,GAAG,SAAS,CAAC;IAC3B,gBAAC;CAAA,AAhED,CAA+B,cAAK,GAgEnC;AAhEY,8BAAS;AAwEtB;IAAmC,iCAAK;IAAxC;;IAgBA,CAAC;IADU,mBAAK,GAAG,eAAe,CAAC;IACnC,oBAAC;CAAA,AAhBD,CAAmC,cAAK,GAgBvC;AAhBY,sCAAa","sourcesContent":["import * as Path from 'path';\n\nimport { Event } from '../utils/events';\nimport { ProjectReflection } from '../models/reflections/project';\nimport { UrlMapping } from './models/UrlMapping';\nimport { NavigationItem } from './models/NavigationItem';\n\n/**\n * An event emitted by the [[Renderer]] class at the very beginning and\n * ending of the entire rendering process.\n *\n * @see [[Renderer.EVENT_BEGIN]]\n * @see [[Renderer.EVENT_END]]\n */\nexport class RendererEvent extends Event {\n /**\n * The project the renderer is currently processing.\n */\n project: ProjectReflection;\n\n /**\n * The settings that have been passed to TypeDoc.\n */\n settings: any;\n\n /**\n * The path of the directory the documentation should be written to.\n */\n outputDirectory: string;\n\n /**\n * A list of all pages that should be generated.\n *\n * This list can be altered during the [[Renderer.EVENT_BEGIN]] event.\n */\n urls: UrlMapping[];\n\n /**\n * Triggered before the renderer starts rendering a project.\n * @event\n */\n static BEGIN = 'beginRender';\n\n /**\n * Triggered after the renderer has written all documents.\n * @event\n */\n static END = 'endRender';\n\n /**\n * Create an [[PageEvent]] event based on this event and the given url mapping.\n *\n * @internal\n * @param mapping The mapping that defines the generated [[PageEvent]] state.\n * @returns A newly created [[PageEvent]] instance.\n */\n public createPageEvent(mapping: UrlMapping): PageEvent {\n const event = new PageEvent(PageEvent.BEGIN);\n event.project = this.project;\n event.settings = this.settings;\n event.url = mapping.url;\n event.model = mapping.model;\n event.templateName = mapping.template;\n event.filename = Path.join(this.outputDirectory, mapping.url);\n return event;\n }\n}\n\n/**\n * An event emitted by the [[Renderer]] class before and after the\n * markup of a page is rendered.\n *\n * This object will be passed as the rendering context to handlebars templates.\n *\n * @see [[Renderer.EVENT_BEGIN_PAGE]]\n * @see [[Renderer.EVENT_END_PAGE]]\n */\nexport class PageEvent extends Event {\n /**\n * The project the renderer is currently processing.\n */\n project: ProjectReflection;\n\n /**\n * The settings that have been passed to TypeDoc.\n */\n settings: any;\n\n /**\n * The filename the page will be written to.\n */\n filename: string;\n\n /**\n * The url this page will be located at.\n */\n url: string;\n\n /**\n * The model that should be rendered on this page.\n */\n model: any;\n\n /**\n * The template that should be used to render this page.\n */\n template: HandlebarsTemplateDelegate;\n\n /**\n * The name of the template that should be used to render this page.\n */\n templateName: string;\n\n /**\n * The primary navigation structure of this page.\n */\n navigation: NavigationItem;\n\n /**\n * The table of contents structure of this page.\n */\n toc: NavigationItem;\n\n /**\n * The final html content of this page.\n *\n * Should be rendered by layout templates and can be modifies by plugins.\n */\n contents: string;\n\n /**\n * Triggered before a document will be rendered.\n * @event\n */\n static BEGIN = 'beginPage';\n\n /**\n * Triggered after a document has been rendered, just before it is written to disc.\n * @event\n */\n static END = 'endPage';\n}\n\n/**\n * An event emitted by the [[MarkedPlugin]] on the [[Renderer]] after a chunk of\n * markdown has been processed. Allows other plugins to manipulate the result.\n *\n * @see [[MarkedPlugin.EVENT_PARSE_MARKDOWN]]\n */\nexport class MarkdownEvent extends Event {\n /**\n * The unparsed original text.\n */\n originalText: string;\n\n /**\n * The parsed output.\n */\n parsedText: string;\n\n /**\n * Triggered on the renderer when this plugin parses a markdown string.\n * @event\n */\n static PARSE = 'parseMarkdown';\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/helpers/compact.d.ts b/dist/lib/output/helpers/compact.d.ts new file mode 100644 index 000000000..851195f6d --- /dev/null +++ b/dist/lib/output/helpers/compact.d.ts @@ -0,0 +1 @@ +export declare function compact(options: any): string; diff --git a/dist/lib/output/helpers/compact.js b/dist/lib/output/helpers/compact.js new file mode 100644 index 000000000..54f082d42 --- /dev/null +++ b/dist/lib/output/helpers/compact.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function compact(options) { + var lines = options.fn(this).split('\n'); + for (var i = 0, c = lines.length; i < c; i++) { + lines[i] = lines[i].trim().replace(/ /, ' '); + } + return lines.join(''); +} +exports.compact = compact; +//# sourceMappingURL=compact.js.map \ No newline at end of file diff --git a/dist/lib/output/helpers/compact.js.map b/dist/lib/output/helpers/compact.js.map new file mode 100644 index 000000000..1f27a8ef2 --- /dev/null +++ b/dist/lib/output/helpers/compact.js.map @@ -0,0 +1 @@ +{"version":3,"file":"compact.js","sourceRoot":"","sources":["../../../../src/lib/output/helpers/compact.ts"],"names":[],"mappings":";;AAMA,iBAAwB,OAAY;IAChC,IAAM,KAAK,GAAG,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE3C,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AARD,0BAQC","sourcesContent":["/**\n * Compress the given string by removing all newlines.\n *\n * @param text The string that should be compressed.\n * @returns The string with all newlines stripped.\n */\nexport function compact(options: any): string {\n const lines = options.fn(this).split('\\n');\n\n for (let i = 0, c = lines.length; i < c; i++) {\n lines[i] = lines[i].trim().replace(/ /, ' ');\n }\n\n return lines.join('');\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/helpers/if-cond.d.ts b/dist/lib/output/helpers/if-cond.d.ts new file mode 100644 index 000000000..152f2dc90 --- /dev/null +++ b/dist/lib/output/helpers/if-cond.d.ts @@ -0,0 +1 @@ +export declare function ifCond(v1: any, operator: any, v2: any, options: any): any; diff --git a/dist/lib/output/helpers/if-cond.js b/dist/lib/output/helpers/if-cond.js new file mode 100644 index 000000000..290ab6498 --- /dev/null +++ b/dist/lib/output/helpers/if-cond.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function ifCond(v1, operator, v2, options) { + switch (operator) { + case '==': + return (v1 == v2) ? options.fn(this) : options.inverse(this); + case '===': + return (v1 === v2) ? options.fn(this) : options.inverse(this); + case '<': + return (v1 < v2) ? options.fn(this) : options.inverse(this); + case '<=': + return (v1 <= v2) ? options.fn(this) : options.inverse(this); + case '>': + return (v1 > v2) ? options.fn(this) : options.inverse(this); + case '>=': + return (v1 >= v2) ? options.fn(this) : options.inverse(this); + case '&&': + return (v1 && v2) ? options.fn(this) : options.inverse(this); + case '||': + return (v1 || v2) ? options.fn(this) : options.inverse(this); + default: + return options.inverse(this); + } +} +exports.ifCond = ifCond; +//# sourceMappingURL=if-cond.js.map \ No newline at end of file diff --git a/dist/lib/output/helpers/if-cond.js.map b/dist/lib/output/helpers/if-cond.js.map new file mode 100644 index 000000000..a4de35e84 --- /dev/null +++ b/dist/lib/output/helpers/if-cond.js.map @@ -0,0 +1 @@ +{"version":3,"file":"if-cond.js","sourceRoot":"","sources":["../../../../src/lib/output/helpers/if-cond.ts"],"names":[],"mappings":";;AAUA,gBAAuB,EAAO,EAAE,QAAa,EAAE,EAAO,EAAE,OAAY;IAChE,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACf,KAAK,IAAI;YAEL,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE,KAAK,KAAK;YACN,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClE,KAAK,GAAG;YACJ,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChE,KAAK,IAAI;YACL,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE,KAAK,GAAG;YACJ,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChE,KAAK,IAAI;YACL,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE,KAAK,IAAI;YACL,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE,KAAK,IAAI;YACL,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE;YACI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;AACL,CAAC;AAtBD,wBAsBC","sourcesContent":["/**\n * Handlebars if helper with condition.\n *\n * @param v1 The first value to be compared.\n * @param operator The operand to perform on the two given values.\n * @param v2 The second value to be compared\n * @param options The current handlebars object.\n * @param this The current handlebars this.\n * @returns {*}\n */\nexport function ifCond(v1: any, operator: any, v2: any, options: any) {\n switch (operator) {\n case '==':\n // tslint:disable-next-line:triple-equals\n return (v1 == v2) ? options.fn(this) : options.inverse(this);\n case '===':\n return (v1 === v2) ? options.fn(this) : options.inverse(this);\n case '<':\n return (v1 < v2) ? options.fn(this) : options.inverse(this);\n case '<=':\n return (v1 <= v2) ? options.fn(this) : options.inverse(this);\n case '>':\n return (v1 > v2) ? options.fn(this) : options.inverse(this);\n case '>=':\n return (v1 >= v2) ? options.fn(this) : options.inverse(this);\n case '&&':\n return (v1 && v2) ? options.fn(this) : options.inverse(this);\n case '||':\n return (v1 || v2) ? options.fn(this) : options.inverse(this);\n default:\n return options.inverse(this);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/helpers/if-signature.d.ts b/dist/lib/output/helpers/if-signature.d.ts new file mode 100644 index 000000000..afe1a5e80 --- /dev/null +++ b/dist/lib/output/helpers/if-signature.d.ts @@ -0,0 +1 @@ +export declare function ifSignature(obj: any, arg: any): any; diff --git a/dist/lib/output/helpers/if-signature.js b/dist/lib/output/helpers/if-signature.js new file mode 100644 index 000000000..d4ff767ae --- /dev/null +++ b/dist/lib/output/helpers/if-signature.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var signature_1 = require("../../models/reflections/signature"); +function ifSignature(obj, arg) { + if (obj instanceof signature_1.SignatureReflection) { + return arg.fn(this); + } + else { + return arg.inverse(this); + } +} +exports.ifSignature = ifSignature; +//# sourceMappingURL=if-signature.js.map \ No newline at end of file diff --git a/dist/lib/output/helpers/if-signature.js.map b/dist/lib/output/helpers/if-signature.js.map new file mode 100644 index 000000000..e86f00fbb --- /dev/null +++ b/dist/lib/output/helpers/if-signature.js.map @@ -0,0 +1 @@ +{"version":3,"file":"if-signature.js","sourceRoot":"","sources":["../../../../src/lib/output/helpers/if-signature.ts"],"names":[],"mappings":";;AAAA,gEAAyE;AAEzE,qBAA4B,GAAQ,EAAE,GAAQ;IAC1C,EAAE,CAAC,CAAC,GAAG,YAAY,+BAAmB,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;AACL,CAAC;AAND,kCAMC","sourcesContent":["import { SignatureReflection } from '../../models/reflections/signature';\n\nexport function ifSignature(obj: any, arg: any) {\n if (obj instanceof SignatureReflection) {\n return arg.fn(this);\n } else {\n return arg.inverse(this);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/helpers/wbr.d.ts b/dist/lib/output/helpers/wbr.d.ts new file mode 100644 index 000000000..717dbaed1 --- /dev/null +++ b/dist/lib/output/helpers/wbr.d.ts @@ -0,0 +1 @@ +export declare function wbr(options: any): string; diff --git a/dist/lib/output/helpers/wbr.js b/dist/lib/output/helpers/wbr.js new file mode 100644 index 000000000..929a13681 --- /dev/null +++ b/dist/lib/output/helpers/wbr.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function wbr(options) { + var str = typeof options === 'string' ? options : options.fn(this); + str = str.replace(/([^_\-][_\-])([^_\-])/g, function (m, a, b) { return a + '' + b; }); + str = str.replace(/([^A-Z])([A-Z][^A-Z])/g, function (m, a, b) { return a + '' + b; }); + return str; +} +exports.wbr = wbr; +//# sourceMappingURL=wbr.js.map \ No newline at end of file diff --git a/dist/lib/output/helpers/wbr.js.map b/dist/lib/output/helpers/wbr.js.map new file mode 100644 index 000000000..a10fd04d8 --- /dev/null +++ b/dist/lib/output/helpers/wbr.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wbr.js","sourceRoot":"","sources":["../../../../src/lib/output/helpers/wbr.ts"],"names":[],"mappings":";;AAQA,aAAoB,OAAY;IAC5B,IAAI,GAAG,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAEnE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,wBAAwB,EAAE,UAAC,CAAS,EAAE,CAAS,EAAE,CAAS,IAAK,OAAA,CAAC,GAAG,OAAO,GAAG,CAAC,EAAf,CAAe,CAAC,CAAC;IAClG,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,wBAAwB,EAAE,UAAC,CAAS,EAAE,CAAS,EAAE,CAAS,IAAK,OAAA,CAAC,GAAG,OAAO,GAAG,CAAC,EAAf,CAAe,CAAC,CAAC;IAElG,MAAM,CAAC,GAAG,CAAC;AACf,CAAC;AAPD,kBAOC","sourcesContent":["/**\n * Insert word break tags ```` into the given string.\n *\n * Breaks the given string at ``_``, ``-`` and captial letters.\n *\n * @param str The string that should be split.\n * @return The original string containing ```` tags where possible.\n */\nexport function wbr(options: any): string {\n let str = typeof options === 'string' ? options : options.fn(this);\n\n str = str.replace(/([^_\\-][_\\-])([^_\\-])/g, (m: string, a: string, b: string) => a + '' + b);\n str = str.replace(/([^A-Z])([A-Z][^A-Z])/g, (m: string, a: string, b: string) => a + '' + b);\n\n return str;\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/models/NavigationItem.d.ts b/dist/lib/output/models/NavigationItem.d.ts new file mode 100644 index 000000000..4edd30b62 --- /dev/null +++ b/dist/lib/output/models/NavigationItem.d.ts @@ -0,0 +1,17 @@ +import { Reflection } from '../../models/reflections/abstract'; +export declare class NavigationItem { + title: string; + url: string; + dedicatedUrls: string[]; + parent: NavigationItem; + children: NavigationItem[]; + cssClasses: string; + isLabel: boolean; + isVisible: boolean; + isCurrent: boolean; + isGlobals: boolean; + isInPath: boolean; + reflection: Reflection; + constructor(title?: string, url?: string, parent?: NavigationItem, cssClasses?: string, reflection?: Reflection); + static create(reflection: Reflection, parent?: NavigationItem, useShortNames?: boolean): NavigationItem; +} diff --git a/dist/lib/output/models/NavigationItem.js b/dist/lib/output/models/NavigationItem.js new file mode 100644 index 000000000..ab1c6b000 --- /dev/null +++ b/dist/lib/output/models/NavigationItem.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var NavigationItem = (function () { + function NavigationItem(title, url, parent, cssClasses, reflection) { + this.title = title || ''; + this.url = url || ''; + this.parent = parent || null; + this.cssClasses = cssClasses || ''; + this.reflection = reflection; + if (!url) { + this.isLabel = true; + } + if (this.parent) { + if (!this.parent.children) { + this.parent.children = []; + } + this.parent.children.push(this); + } + } + NavigationItem.create = function (reflection, parent, useShortNames) { + var name; + if (useShortNames || (parent && parent.parent)) { + name = reflection.name; + } + else { + name = reflection.getFullName(); + } + name = name.trim(); + if (name === '') { + name = "" + reflection.kindString + ""; + } + return new NavigationItem(name, reflection.url, parent, reflection.cssClasses, reflection); + }; + return NavigationItem; +}()); +exports.NavigationItem = NavigationItem; +//# sourceMappingURL=NavigationItem.js.map \ No newline at end of file diff --git a/dist/lib/output/models/NavigationItem.js.map b/dist/lib/output/models/NavigationItem.js.map new file mode 100644 index 000000000..711ba9e89 --- /dev/null +++ b/dist/lib/output/models/NavigationItem.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NavigationItem.js","sourceRoot":"","sources":["../../../../src/lib/output/models/NavigationItem.ts"],"names":[],"mappings":";;AASA;IAsEI,wBAAY,KAAc,EAAE,GAAY,EAAE,MAAuB,EAAE,UAAmB,EAAE,UAAuB;QAC3G,IAAI,CAAC,KAAK,GAAQ,KAAK,IAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAU,GAAG,IAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAO,MAAM,IAAI,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACP,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YACd,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;YAC9B,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;IACL,CAAC;IASM,qBAAM,GAAb,UAAc,UAAsB,EAAE,MAAuB,EAAE,aAAuB;QAClF,IAAI,IAAY,CAAC;QACjB,EAAE,CAAC,CAAC,aAAa,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC3B,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,IAAI,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;QACpC,CAAC;QAED,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,EAAE,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;YACd,IAAI,GAAG,SAAO,UAAU,CAAC,UAAU,UAAO,CAAC;QAC/C,CAAC;QAED,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC/F,CAAC;IACL,qBAAC;AAAD,CAAC,AA/GD,IA+GC;AA/GY,wCAAc","sourcesContent":["import { Reflection } from '../../models/reflections/abstract';\n\n/**\n * A hierarchical model holding the data of single node within the navigation.\n *\n * This structure is used by the [[NavigationPlugin]] and [[TocPlugin]] to expose the current\n * navigation state to the template engine. Themes should generate the primary navigation structure\n * through the [[BaseTheme.getNavigation]] method.\n */\nexport class NavigationItem {\n /**\n * The visible title of the navigation node.\n */\n title: string;\n\n /**\n * The url this navigation node points to.\n */\n url: string;\n\n /**\n * A list of urls that should be seen as sub-pages of this node.\n */\n dedicatedUrls: string[];\n\n /**\n * The parent navigation node.\n */\n parent: NavigationItem;\n\n /**\n * An array containing all child navigation nodes.\n */\n children: NavigationItem[];\n\n /**\n * A string containing the css classes of this node.\n */\n cssClasses: string;\n\n /**\n * Is this item a simple label without a link?\n */\n isLabel: boolean;\n\n /**\n * Is this item visible?\n */\n isVisible: boolean;\n\n /**\n * Does this navigation node represent the current page?\n */\n isCurrent: boolean;\n\n /**\n * Is this the navigation node for the globals page?\n */\n isGlobals: boolean;\n\n /**\n * Is this navigation node one of the parents of the current page?\n */\n isInPath: boolean;\n\n /**\n * The source [Reflection] this item is built from\n */\n reflection: Reflection;\n\n /**\n * Create a new NavigationItem instance.\n *\n * @param title The visible title of the navigation node.\n * @param url The url this navigation node points to.\n * @param parent The parent navigation node.\n * @param cssClasses A string containing the css classes of this node.\n * @param reflection The source [Reflection] for this [NavigationItem]\n */\n constructor(title?: string, url?: string, parent?: NavigationItem, cssClasses?: string, reflection?: Reflection) {\n this.title = title || '';\n this.url = url || '';\n this.parent = parent || null;\n this.cssClasses = cssClasses || '';\n this.reflection = reflection;\n\n if (!url) {\n this.isLabel = true;\n }\n\n if (this.parent) {\n if (!this.parent.children) {\n this.parent.children = [];\n }\n this.parent.children.push(this);\n }\n }\n\n /**\n * Create a navigation node for the given reflection.\n *\n * @param reflection The reflection whose navigation node should be created.\n * @param parent The parent navigation node.\n * @param useShortNames Force this function to always use short names.\n */\n static create(reflection: Reflection, parent?: NavigationItem, useShortNames?: boolean) {\n let name: string;\n if (useShortNames || (parent && parent.parent)) {\n name = reflection.name;\n } else {\n name = reflection.getFullName();\n }\n\n name = name.trim();\n if (name === '') {\n name = `${reflection.kindString}`;\n }\n\n return new NavigationItem(name, reflection.url, parent, reflection.cssClasses, reflection);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/models/UrlMapping.d.ts b/dist/lib/output/models/UrlMapping.d.ts new file mode 100644 index 000000000..b94356f7e --- /dev/null +++ b/dist/lib/output/models/UrlMapping.d.ts @@ -0,0 +1,6 @@ +export declare class UrlMapping { + url: string; + model: any; + template: string; + constructor(url: string, model: any, template: string); +} diff --git a/dist/lib/output/models/UrlMapping.js b/dist/lib/output/models/UrlMapping.js new file mode 100644 index 000000000..8c50cdb1c --- /dev/null +++ b/dist/lib/output/models/UrlMapping.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var UrlMapping = (function () { + function UrlMapping(url, model, template) { + this.url = url; + this.model = model; + this.template = template; + } + return UrlMapping; +}()); +exports.UrlMapping = UrlMapping; +//# sourceMappingURL=UrlMapping.js.map \ No newline at end of file diff --git a/dist/lib/output/models/UrlMapping.js.map b/dist/lib/output/models/UrlMapping.js.map new file mode 100644 index 000000000..56f8c8637 --- /dev/null +++ b/dist/lib/output/models/UrlMapping.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UrlMapping.js","sourceRoot":"","sources":["../../../../src/lib/output/models/UrlMapping.ts"],"names":[],"mappings":";;AAGA;IAOI,oBAAY,GAAW,EAAE,KAAU,EAAE,QAAgB;QACjD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IACL,iBAAC;AAAD,CAAC,AAZD,IAYC;AAZY,gCAAU","sourcesContent":["/**\n *\n */\nexport class UrlMapping {\n url: string;\n\n model: any;\n\n template: string;\n\n constructor(url: string, model: any, template: string) {\n this.url = url;\n this.model = model;\n this.template = template;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/plugins/AssetsPlugin.d.ts b/dist/lib/output/plugins/AssetsPlugin.d.ts new file mode 100644 index 000000000..fe6409554 --- /dev/null +++ b/dist/lib/output/plugins/AssetsPlugin.d.ts @@ -0,0 +1,6 @@ +import { RendererComponent } from '../components'; +export declare class AssetsPlugin extends RendererComponent { + copyDefaultAssets: boolean; + initialize(): void; + private onRendererBegin(event); +} diff --git a/dist/lib/output/plugins/AssetsPlugin.js b/dist/lib/output/plugins/AssetsPlugin.js new file mode 100644 index 000000000..8e0408ec3 --- /dev/null +++ b/dist/lib/output/plugins/AssetsPlugin.js @@ -0,0 +1,57 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var FS = require("fs-extra"); +var components_1 = require("../components"); +var events_1 = require("../events"); +var renderer_1 = require("../renderer"); +var AssetsPlugin = (function (_super) { + __extends(AssetsPlugin, _super); + function AssetsPlugin() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.copyDefaultAssets = true; + return _this; + } + AssetsPlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[events_1.RendererEvent.BEGIN] = this.onRendererBegin, + _a)); + var _a; + }; + AssetsPlugin.prototype.onRendererBegin = function (event) { + var fromDefault = Path.join(renderer_1.Renderer.getDefaultTheme(), 'assets'); + var to = Path.join(event.outputDirectory, 'assets'); + if (this.copyDefaultAssets) { + FS.copySync(fromDefault, to); + } + else { + fromDefault = null; + } + var from = Path.join(this.owner.theme.basePath, 'assets'); + if (from !== fromDefault && FS.existsSync(from)) { + FS.copySync(from, to); + } + }; + AssetsPlugin = __decorate([ + components_1.Component({ name: 'assets' }) + ], AssetsPlugin); + return AssetsPlugin; +}(components_1.RendererComponent)); +exports.AssetsPlugin = AssetsPlugin; +//# sourceMappingURL=AssetsPlugin.js.map \ No newline at end of file diff --git a/dist/lib/output/plugins/AssetsPlugin.js.map b/dist/lib/output/plugins/AssetsPlugin.js.map new file mode 100644 index 000000000..3f51f7830 --- /dev/null +++ b/dist/lib/output/plugins/AssetsPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"AssetsPlugin.js","sourceRoot":"","sources":["../../../../src/lib/output/plugins/AssetsPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAC7B,6BAA+B;AAE/B,4CAA6D;AAC7D,oCAA0C;AAC1C,wCAAuC;AAOvC;IAAkC,gCAAiB;IADnD;QAAA,qEAoCC;QA/BG,uBAAiB,GAAG,IAAI,CAAC;;IA+B7B,CAAC;IA1BG,iCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,sBAAa,CAAC,KAAK,IAAG,IAAI,CAAC,eAAe;gBAC7C,CAAC;;IACP,CAAC;IAOO,sCAAe,GAAvB,UAAwB,KAAoB;QACxC,IAAI,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAQ,CAAC,eAAe,EAAE,EAAE,QAAQ,CAAC,CAAC;QAClE,IAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAEtD,EAAE,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;YACzB,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACjC,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,WAAW,GAAG,IAAI,CAAC;QACvB,CAAC;QAED,IAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5D,EAAE,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC9C,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC;IAlCQ,YAAY;QADxB,sBAAS,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;OACf,YAAY,CAmCxB;IAAD,mBAAC;CAAA,AAnCD,CAAkC,8BAAiB,GAmClD;AAnCY,oCAAY","sourcesContent":["import * as Path from 'path';\nimport * as FS from 'fs-extra';\n\nimport { Component, RendererComponent } from '../components';\nimport { RendererEvent } from '../events';\nimport { Renderer } from '../renderer';\n\n/**\n * A plugin that copies the subdirectory ´assets´ from the current themes\n * source folder to the output directory.\n */\n@Component({name: 'assets'})\nexport class AssetsPlugin extends RendererComponent {\n /**\n * Should the default assets always be copied to the output directory?\n */\n copyDefaultAssets = true;\n\n /**\n * Create a new AssetsPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [RendererEvent.BEGIN]: this.onRendererBegin\n });\n }\n\n /**\n * Triggered before the renderer starts rendering a project.\n *\n * @param event An event object describing the current render operation.\n */\n private onRendererBegin(event: RendererEvent) {\n let fromDefault = Path.join(Renderer.getDefaultTheme(), 'assets');\n const to = Path.join(event.outputDirectory, 'assets');\n\n if (this.copyDefaultAssets) {\n FS.copySync(fromDefault, to);\n } else {\n fromDefault = null;\n }\n\n const from = Path.join(this.owner.theme.basePath, 'assets');\n if (from !== fromDefault && FS.existsSync(from)) {\n FS.copySync(from, to);\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts b/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts new file mode 100644 index 000000000..2b24bc952 --- /dev/null +++ b/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts @@ -0,0 +1,5 @@ +import { RendererComponent } from '../components'; +export declare class JavascriptIndexPlugin extends RendererComponent { + initialize(): void; + private onRendererBegin(event); +} diff --git a/dist/lib/output/plugins/JavascriptIndexPlugin.js b/dist/lib/output/plugins/JavascriptIndexPlugin.js new file mode 100644 index 000000000..18b79dd90 --- /dev/null +++ b/dist/lib/output/plugins/JavascriptIndexPlugin.js @@ -0,0 +1,76 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Path = require("path"); +var index_1 = require("../../models/reflections/index"); +var GroupPlugin_1 = require("../../converter/plugins/GroupPlugin"); +var components_1 = require("../components"); +var fs_1 = require("../../utils/fs"); +var events_1 = require("../events"); +var JavascriptIndexPlugin = (function (_super) { + __extends(JavascriptIndexPlugin, _super); + function JavascriptIndexPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + JavascriptIndexPlugin.prototype.initialize = function () { + this.listenTo(this.owner, events_1.RendererEvent.BEGIN, this.onRendererBegin); + }; + JavascriptIndexPlugin.prototype.onRendererBegin = function (event) { + var rows = []; + var kinds = {}; + for (var key in event.project.reflections) { + var reflection = event.project.reflections[key]; + if (!(reflection instanceof index_1.DeclarationReflection)) { + continue; + } + if (!reflection.url || + !reflection.name || + reflection.flags.isExternal || + reflection.name === '') { + continue; + } + var parent_1 = reflection.parent; + if (parent_1 instanceof index_1.ProjectReflection) { + parent_1 = null; + } + var row = { + id: rows.length, + kind: reflection.kind, + name: reflection.name, + url: reflection.url, + classes: reflection.cssClasses + }; + if (parent_1) { + row.parent = parent_1.getFullName(); + } + if (!kinds[reflection.kind]) { + kinds[reflection.kind] = GroupPlugin_1.GroupPlugin.getKindSingular(reflection.kind); + } + rows.push(row); + } + var fileName = Path.join(event.outputDirectory, 'assets', 'js', 'search.js'); + var data = "var typedoc = typedoc || {};\n typedoc.search = typedoc.search || {};\n typedoc.search.data = " + JSON.stringify({ kinds: kinds, rows: rows }) + ";"; + fs_1.writeFile(fileName, data, false); + }; + JavascriptIndexPlugin = __decorate([ + components_1.Component({ name: 'javascript-index' }) + ], JavascriptIndexPlugin); + return JavascriptIndexPlugin; +}(components_1.RendererComponent)); +exports.JavascriptIndexPlugin = JavascriptIndexPlugin; +//# sourceMappingURL=JavascriptIndexPlugin.js.map \ No newline at end of file diff --git a/dist/lib/output/plugins/JavascriptIndexPlugin.js.map b/dist/lib/output/plugins/JavascriptIndexPlugin.js.map new file mode 100644 index 000000000..7328563e9 --- /dev/null +++ b/dist/lib/output/plugins/JavascriptIndexPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"JavascriptIndexPlugin.js","sourceRoot":"","sources":["../../../../src/lib/output/plugins/JavascriptIndexPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAE7B,wDAA0F;AAC1F,mEAAkE;AAClE,4CAA6D;AAC7D,qCAA2C;AAC3C,oCAA0C;AAQ1C;IAA2C,yCAAiB;IAA5D;;IA8DA,CAAC;IA1DG,0CAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,sBAAa,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IACzE,CAAC;IAOO,+CAAe,GAAvB,UAAwB,KAAoB;QACxC,IAAM,IAAI,GAAU,EAAE,CAAC;QACvB,IAAM,KAAK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AG,CAAC,CAAC;QACnB,CAAC;QAED,IAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QAC/E,IAAM,IAAI,GACN,yHAEwB,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC,MAAG,CAAC;QAE1E,cAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IA7DQ,qBAAqB;QADjC,sBAAS,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC;OACzB,qBAAqB,CA8DjC;IAAD,4BAAC;CAAA,AA9DD,CAA2C,8BAAiB,GA8D3D;AA9DY,sDAAqB","sourcesContent":["import * as Path from 'path';\n\nimport { DeclarationReflection, ProjectReflection } from '../../models/reflections/index';\nimport { GroupPlugin } from '../../converter/plugins/GroupPlugin';\nimport { Component, RendererComponent } from '../components';\nimport { writeFile } from '../../utils/fs';\nimport { RendererEvent } from '../events';\n\n/**\n * A plugin that exports an index of the project to a javascript file.\n *\n * The resulting javascript file can be used to build a simple search function.\n */\n@Component({name: 'javascript-index'})\nexport class JavascriptIndexPlugin extends RendererComponent {\n /**\n * Create a new JavascriptIndexPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, RendererEvent.BEGIN, this.onRendererBegin);\n }\n\n /**\n * Triggered after a document has been rendered, just before it is written to disc.\n *\n * @param event An event object describing the current render operation.\n */\n private onRendererBegin(event: RendererEvent) {\n const rows: any[] = [];\n const kinds = {};\n\n for (let key in event.project.reflections) {\n const reflection: DeclarationReflection = event.project.reflections[key];\n if (!(reflection instanceof DeclarationReflection)) {\n continue;\n }\n\n if (!reflection.url ||\n !reflection.name ||\n reflection.flags.isExternal ||\n reflection.name === '') {\n continue;\n }\n\n let parent = reflection.parent;\n if (parent instanceof ProjectReflection) {\n parent = null;\n }\n\n const row: any = {\n id: rows.length,\n kind: reflection.kind,\n name: reflection.name,\n url: reflection.url,\n classes: reflection.cssClasses\n };\n\n if (parent) {\n row.parent = parent.getFullName();\n }\n\n if (!kinds[reflection.kind]) {\n kinds[reflection.kind] = GroupPlugin.getKindSingular(reflection.kind);\n }\n\n rows.push(row);\n }\n\n const fileName = Path.join(event.outputDirectory, 'assets', 'js', 'search.js');\n const data =\n `var typedoc = typedoc || {};\n typedoc.search = typedoc.search || {};\n typedoc.search.data = ${JSON.stringify({kinds: kinds, rows: rows})};`;\n\n writeFile(fileName, data, false);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/plugins/LayoutPlugin.d.ts b/dist/lib/output/plugins/LayoutPlugin.d.ts new file mode 100644 index 000000000..3d7d9c79e --- /dev/null +++ b/dist/lib/output/plugins/LayoutPlugin.d.ts @@ -0,0 +1,5 @@ +import { RendererComponent } from '../components'; +export declare class LayoutPlugin extends RendererComponent { + initialize(): void; + private onRendererEndPage(page); +} diff --git a/dist/lib/output/plugins/LayoutPlugin.js b/dist/lib/output/plugins/LayoutPlugin.js new file mode 100644 index 000000000..756502c2b --- /dev/null +++ b/dist/lib/output/plugins/LayoutPlugin.js @@ -0,0 +1,39 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var components_1 = require("../components"); +var events_1 = require("../events"); +var LayoutPlugin = (function (_super) { + __extends(LayoutPlugin, _super); + function LayoutPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + LayoutPlugin.prototype.initialize = function () { + this.listenTo(this.owner, events_1.PageEvent.END, this.onRendererEndPage); + }; + LayoutPlugin.prototype.onRendererEndPage = function (page) { + var layout = this.owner.theme.resources.layouts.getResource('default').getTemplate(); + page.contents = layout(page); + }; + LayoutPlugin = __decorate([ + components_1.Component({ name: 'layout' }) + ], LayoutPlugin); + return LayoutPlugin; +}(components_1.RendererComponent)); +exports.LayoutPlugin = LayoutPlugin; +//# sourceMappingURL=LayoutPlugin.js.map \ No newline at end of file diff --git a/dist/lib/output/plugins/LayoutPlugin.js.map b/dist/lib/output/plugins/LayoutPlugin.js.map new file mode 100644 index 000000000..30b479451 --- /dev/null +++ b/dist/lib/output/plugins/LayoutPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LayoutPlugin.js","sourceRoot":"","sources":["../../../../src/lib/output/plugins/LayoutPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4CAA6D;AAC7D,oCAAsC;AAStC;IAAkC,gCAAiB;IAAnD;;IAiBA,CAAC;IAbG,iCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAS,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACrE,CAAC;IAOO,wCAAiB,GAAzB,UAA0B,IAAe;QACrC,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QACvF,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAhBQ,YAAY;QADxB,sBAAS,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;OACf,YAAY,CAiBxB;IAAD,mBAAC;CAAA,AAjBD,CAAkC,8BAAiB,GAiBlD;AAjBY,oCAAY","sourcesContent":["import { Component, RendererComponent } from '../components';\nimport { PageEvent } from '../events';\n\n/**\n * A plugin that wraps the generated output with a layout template.\n *\n * Currently only a default layout is supported. The layout must be stored\n * as ´layouts/default.hbs´ in the theme directory.\n */\n@Component({name: 'layout'})\nexport class LayoutPlugin extends RendererComponent {\n /**\n * Create a new LayoutPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, PageEvent.END, this.onRendererEndPage);\n }\n\n /**\n * Triggered after a document has been rendered, just before it is written to disc.\n *\n * @param page An event object describing the current render operation.\n */\n private onRendererEndPage(page: PageEvent) {\n const layout = this.owner.theme.resources.layouts.getResource('default').getTemplate();\n page.contents = layout(page);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/plugins/MarkedLinksPlugin.d.ts b/dist/lib/output/plugins/MarkedLinksPlugin.d.ts new file mode 100644 index 000000000..4b0ee7891 --- /dev/null +++ b/dist/lib/output/plugins/MarkedLinksPlugin.d.ts @@ -0,0 +1,18 @@ +import { ContextAwareRendererComponent } from '../components'; +import { MarkdownEvent, RendererEvent } from '../events'; +export declare class MarkedLinksPlugin extends ContextAwareRendererComponent { + private brackets; + private inlineTag; + listInvalidSymbolLinks: boolean; + private warnings; + initialize(): void; + private replaceBrackets(text); + private replaceInlineTags(text); + private buildLink(original, target, caption, monospace?); + onParseMarkdown(event: MarkdownEvent): void; + onEndRenderer(event: RendererEvent): void; + static splitLinkText(text: string): { + caption: string; + target: string; + }; +} diff --git a/dist/lib/output/plugins/MarkedLinksPlugin.js b/dist/lib/output/plugins/MarkedLinksPlugin.js new file mode 100644 index 000000000..3d24cdee6 --- /dev/null +++ b/dist/lib/output/plugins/MarkedLinksPlugin.js @@ -0,0 +1,144 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Util = require("util"); +var components_1 = require("../components"); +var events_1 = require("../events"); +var component_1 = require("../../utils/component"); +var declaration_1 = require("../../utils/options/declaration"); +var MarkedLinksPlugin = (function (_super) { + __extends(MarkedLinksPlugin, _super); + function MarkedLinksPlugin() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.brackets = /\[\[([^\]]+)\]\]/g; + _this.inlineTag = /(?:\[(.+?)\])?\{@(link|linkcode|linkplain)\s+((?:.|\n)+?)\}/gi; + _this.warnings = []; + return _this; + } + MarkedLinksPlugin_1 = MarkedLinksPlugin; + MarkedLinksPlugin.prototype.initialize = function () { + _super.prototype.initialize.call(this); + this.listenTo(this.owner, (_a = {}, + _a[events_1.MarkdownEvent.PARSE] = this.onParseMarkdown, + _a[events_1.RendererEvent.END] = this.onEndRenderer, + _a), null, 100); + var _a; + }; + MarkedLinksPlugin.prototype.replaceBrackets = function (text) { + var _this = this; + return text.replace(this.brackets, function (match, content) { + var split = MarkedLinksPlugin_1.splitLinkText(content); + return _this.buildLink(match, split.target, split.caption); + }); + }; + MarkedLinksPlugin.prototype.replaceInlineTags = function (text) { + var _this = this; + return text.replace(this.inlineTag, function (match, leading, tagName, content) { + var split = MarkedLinksPlugin_1.splitLinkText(content); + var target = split.target; + var caption = leading || split.caption; + var monospace; + if (tagName === 'linkcode') { + monospace = true; + } + if (tagName === 'linkplain') { + monospace = false; + } + return _this.buildLink(match, target, caption, monospace); + }); + }; + MarkedLinksPlugin.prototype.buildLink = function (original, target, caption, monospace) { + var attributes = ''; + if (this.urlPrefix.test(target)) { + attributes = ' class="external"'; + } + else { + var reflection = void 0; + if (this.reflection) { + reflection = this.reflection.findReflectionByName(target); + } + else if (this.project) { + reflection = this.project.findReflectionByName(target); + } + if (reflection && reflection.url) { + if (this.urlPrefix.test(reflection.url)) { + target = reflection.url; + attributes = ' class="external"'; + } + else { + target = this.getRelativeUrl(reflection.url); + } + } + else { + reflection = this.reflection || this.project; + this.warnings.push("In " + reflection.getFullName() + ": " + original); + return original; + } + } + if (monospace) { + caption = '' + caption + ''; + } + return Util.format('%s', target, attributes, caption); + }; + MarkedLinksPlugin.prototype.onParseMarkdown = function (event) { + event.parsedText = this.replaceInlineTags(this.replaceBrackets(event.parsedText)); + }; + MarkedLinksPlugin.prototype.onEndRenderer = function (event) { + if (this.listInvalidSymbolLinks && this.warnings.length > 0) { + this.application.logger.write(''); + this.application.logger.warn('[MarkedLinksPlugin]: Found invalid symbol reference(s) in JSDocs, ' + + 'they will not render as links in the generated documentation.'); + for (var _i = 0, _a = this.warnings; _i < _a.length; _i++) { + var warning = _a[_i]; + this.application.logger.write(' ' + warning); + } + } + }; + MarkedLinksPlugin.splitLinkText = function (text) { + var splitIndex = text.indexOf('|'); + if (splitIndex === -1) { + splitIndex = text.search(/\s/); + } + if (splitIndex !== -1) { + return { + caption: text.substr(splitIndex + 1).replace(/\n+/, ' '), + target: text.substr(0, splitIndex) + }; + } + else { + return { + caption: text, + target: text + }; + } + }; + __decorate([ + component_1.Option({ + name: 'listInvalidSymbolLinks', + help: 'Emits a list of broken symbol [[navigation]] links after documentation generation', + type: declaration_1.ParameterType.Boolean + }) + ], MarkedLinksPlugin.prototype, "listInvalidSymbolLinks", void 0); + MarkedLinksPlugin = MarkedLinksPlugin_1 = __decorate([ + components_1.Component({ name: 'marked-links' }) + ], MarkedLinksPlugin); + return MarkedLinksPlugin; + var MarkedLinksPlugin_1; +}(components_1.ContextAwareRendererComponent)); +exports.MarkedLinksPlugin = MarkedLinksPlugin; +//# sourceMappingURL=MarkedLinksPlugin.js.map \ No newline at end of file diff --git a/dist/lib/output/plugins/MarkedLinksPlugin.js.map b/dist/lib/output/plugins/MarkedLinksPlugin.js.map new file mode 100644 index 000000000..a9147cad3 --- /dev/null +++ b/dist/lib/output/plugins/MarkedLinksPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MarkedLinksPlugin.js","sourceRoot":"","sources":["../../../../src/lib/output/plugins/MarkedLinksPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAG7B,4CAAyE;AACzE,oCAAyD;AACzD,mDAA+C;AAC/C,+DAAgE;AAMhE;IAAuC,qCAA6B;IADpE;QAAA,qEAoKC;QA/JW,cAAQ,GAAW,mBAAmB,CAAC;QAKvC,eAAS,GAAW,+DAA+D,CAAC;QASpF,cAAQ,GAAa,EAAE,CAAC;;IAiJpC,CAAC;0BAnKY,iBAAiB;IAuB1B,sCAAU,GAAV;QACI,iBAAM,UAAU,WAAE,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,sBAAa,CAAC,KAAK,IAAG,IAAI,CAAC,eAAe;YAC3C,GAAC,sBAAa,CAAC,GAAG,IAAG,IAAI,CAAC,aAAa;iBACxC,IAAI,EAAE,GAAG,CAAC,CAAC;;IAClB,CAAC;IAaO,2CAAe,GAAvB,UAAwB,IAAY;QAApC,iBAKC;QAJG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAC,KA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ACb,MAAM,EAAE,IAAI;aACf,CAAC;QACN,CAAC;IACL,CAAC;IAlJD;QALC,kBAAM,CAAC;YACJ,IAAI,EAAE,wBAAwB;YAC9B,IAAI,EAAE,mFAAmF;YACzF,IAAI,EAAE,2BAAa,CAAC,OAAO;SAC9B,CAAC;qEAC8B;IAhBvB,iBAAiB;QAD7B,sBAAS,CAAC,EAAC,IAAI,EAAE,cAAc,EAAC,CAAC;OACrB,iBAAiB,CAmK7B;IAAD,wBAAC;;CAAA,AAnKD,CAAuC,0CAA6B,GAmKnE;AAnKY,8CAAiB","sourcesContent":["import * as Util from 'util';\n\nimport { Reflection } from '../../models/reflections/abstract';\nimport { Component, ContextAwareRendererComponent } from '../components';\nimport { MarkdownEvent, RendererEvent } from '../events';\nimport { Option } from '../../utils/component';\nimport { ParameterType } from '../../utils/options/declaration';\n\n/**\n * A plugin that builds links in markdown texts.\n */\n@Component({name: 'marked-links'})\nexport class MarkedLinksPlugin extends ContextAwareRendererComponent {\n /**\n * Regular expression for detecting bracket links.\n */\n private brackets: RegExp = /\\[\\[([^\\]]+)\\]\\]/g;\n\n /**\n * Regular expression for detecting inline tags like {@link ...}.\n */\n private inlineTag: RegExp = /(?:\\[(.+?)\\])?\\{@(link|linkcode|linkplain)\\s+((?:.|\\n)+?)\\}/gi;\n\n @Option({\n name: 'listInvalidSymbolLinks',\n help: 'Emits a list of broken symbol [[navigation]] links after documentation generation',\n type: ParameterType.Boolean\n })\n listInvalidSymbolLinks: boolean;\n\n private warnings: string[] = [];\n\n /**\n * Create a new MarkedLinksPlugin instance.\n */\n initialize() {\n super.initialize();\n this.listenTo(this.owner, {\n [MarkdownEvent.PARSE]: this.onParseMarkdown,\n [RendererEvent.END]: this.onEndRenderer\n }, null, 100);\n }\n\n /**\n * Find all references to symbols within the given text and transform them into a link.\n *\n * This function is aware of the current context and will try to find the symbol within the\n * current reflection. It will walk up the reflection chain till the symbol is found or the\n * root reflection is reached. As a last resort the function will search the entire project\n * for the given symbol.\n *\n * @param text The text that should be parsed.\n * @returns The text with symbol references replaced by links.\n */\n private replaceBrackets(text: string): string {\n return text.replace(this.brackets, (match: string, content: string): string => {\n const split = MarkedLinksPlugin.splitLinkText(content);\n return this.buildLink(match, split.target, split.caption);\n });\n }\n\n /**\n * Find symbol {@link ...} strings in text and turn into html links\n *\n * @param text The string in which to replace the inline tags.\n * @return The updated string.\n */\n private replaceInlineTags(text: string): string {\n return text.replace(this.inlineTag, (match: string, leading: string, tagName: string, content: string): string => {\n const split = MarkedLinksPlugin.splitLinkText(content);\n const target = split.target;\n const caption = leading || split.caption;\n\n let monospace: boolean;\n if (tagName === 'linkcode') {\n monospace = true;\n }\n if (tagName === 'linkplain') {\n monospace = false;\n }\n\n return this.buildLink(match, target, caption, monospace);\n });\n }\n\n /**\n * Format a link with the given text and target.\n *\n * @param original The original link string, will be returned if the target cannot be resolved..\n * @param target The link target.\n * @param caption The caption of the link.\n * @param monospace Whether to use monospace formatting or not.\n * @returns A html link tag.\n */\n private buildLink(original: string, target: string, caption: string, monospace?: boolean): string {\n let attributes = '';\n if (this.urlPrefix.test(target)) {\n attributes = ' class=\"external\"';\n } else {\n let reflection: Reflection;\n if (this.reflection) {\n reflection = this.reflection.findReflectionByName(target);\n } else if (this.project) {\n reflection = this.project.findReflectionByName(target);\n }\n\n if (reflection && reflection.url) {\n if (this.urlPrefix.test(reflection.url)) {\n target = reflection.url;\n attributes = ' class=\"external\"';\n } else {\n target = this.getRelativeUrl(reflection.url);\n }\n } else {\n reflection = this.reflection || this.project;\n this.warnings.push(`In ${reflection.getFullName()}: ${original}`);\n return original;\n }\n }\n\n if (monospace) {\n caption = '' + caption + '';\n }\n\n return Util.format('%s', target, attributes, caption);\n }\n\n /**\n * Triggered when [[MarkedPlugin]] parses a markdown string.\n *\n * @param event\n */\n onParseMarkdown(event: MarkdownEvent) {\n event.parsedText = this.replaceInlineTags(this.replaceBrackets(event.parsedText));\n }\n\n /**\n * Triggered when [[Renderer]] is finished\n */\n onEndRenderer(event: RendererEvent) {\n if (this.listInvalidSymbolLinks && this.warnings.length > 0) {\n this.application.logger.write('');\n this.application.logger.warn('[MarkedLinksPlugin]: Found invalid symbol reference(s) in JSDocs, ' +\n 'they will not render as links in the generated documentation.');\n\n for (let warning of this.warnings) {\n this.application.logger.write(' ' + warning);\n }\n }\n }\n\n /**\n * Split the given link into text and target at first pipe or space.\n *\n * @param text The source string that should be checked for a split character.\n * @returns An object containing the link text and target.\n */\n static splitLinkText(text: string): { caption: string; target: string; } {\n let splitIndex = text.indexOf('|');\n if (splitIndex === -1) {\n splitIndex = text.search(/\\s/);\n }\n\n if (splitIndex !== -1) {\n return {\n caption: text.substr(splitIndex + 1).replace(/\\n+/, ' '),\n target: text.substr(0, splitIndex)\n };\n } else {\n return {\n caption: text,\n target: text\n };\n }\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/plugins/MarkedPlugin.d.ts b/dist/lib/output/plugins/MarkedPlugin.d.ts new file mode 100644 index 000000000..bdb41725b --- /dev/null +++ b/dist/lib/output/plugins/MarkedPlugin.d.ts @@ -0,0 +1,15 @@ +import { ContextAwareRendererComponent } from '../components'; +import { RendererEvent, MarkdownEvent } from '../events'; +export declare class MarkedPlugin extends ContextAwareRendererComponent { + includeSource: string; + mediaSource: string; + private includes; + private mediaDirectory; + private includePattern; + private mediaPattern; + initialize(): void; + getHighlighted(text: string, lang?: string): string; + parseMarkdown(text: string, context: any): string; + protected onBeginRenderer(event: RendererEvent): void; + onParseMarkdown(event: MarkdownEvent): void; +} diff --git a/dist/lib/output/plugins/MarkedPlugin.js b/dist/lib/output/plugins/MarkedPlugin.js new file mode 100644 index 000000000..53807fee4 --- /dev/null +++ b/dist/lib/output/plugins/MarkedPlugin.js @@ -0,0 +1,144 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var FS = require("fs-extra"); +var Path = require("path"); +var Marked = require("marked"); +var HighlightJS = require("highlight.js"); +var Handlebars = require("handlebars"); +var components_1 = require("../components"); +var events_1 = require("../events"); +var component_1 = require("../../utils/component"); +var declaration_1 = require("../../utils/options/declaration"); +var MarkedPlugin = (function (_super) { + __extends(MarkedPlugin, _super); + function MarkedPlugin() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.includePattern = /\[\[include:([^\]]+?)\]\]/g; + _this.mediaPattern = /media:\/\/([^ "\)\]\}]+)/g; + return _this; + } + MarkedPlugin.prototype.initialize = function () { + var _this = this; + _super.prototype.initialize.call(this); + this.listenTo(this.owner, events_1.MarkdownEvent.PARSE, this.onParseMarkdown); + var that = this; + Handlebars.registerHelper('markdown', function (arg) { return that.parseMarkdown(arg.fn(this), this); }); + Handlebars.registerHelper('relativeURL', function (url) { return url ? _this.getRelativeUrl(url) : url; }); + Marked.setOptions({ + highlight: function (text, lang) { return _this.getHighlighted(text, lang); } + }); + }; + MarkedPlugin.prototype.getHighlighted = function (text, lang) { + try { + if (lang) { + return HighlightJS.highlight(lang, text).value; + } + else { + return HighlightJS.highlightAuto(text).value; + } + } + catch (error) { + this.application.logger.warn(error.message); + return text; + } + }; + MarkedPlugin.prototype.parseMarkdown = function (text, context) { + var _this = this; + if (this.includes) { + text = text.replace(this.includePattern, function (match, path) { + path = Path.join(_this.includes, path.trim()); + if (FS.existsSync(path) && FS.statSync(path).isFile()) { + var contents = FS.readFileSync(path, 'utf-8'); + if (path.substr(-4).toLocaleLowerCase() === '.hbs') { + var template = Handlebars.compile(contents); + return template(context); + } + else { + return contents; + } + } + else { + return ''; + } + }); + } + if (this.mediaDirectory) { + text = text.replace(this.mediaPattern, function (match, path) { + if (FS.existsSync(Path.join(_this.mediaDirectory, path))) { + return _this.getRelativeUrl('media') + '/' + path; + } + else { + return match; + } + }); + } + var event = new events_1.MarkdownEvent(events_1.MarkdownEvent.PARSE); + event.originalText = text; + event.parsedText = text; + this.owner.trigger(event); + return event.parsedText; + }; + MarkedPlugin.prototype.onBeginRenderer = function (event) { + _super.prototype.onBeginRenderer.call(this, event); + delete this.includes; + if (this.includeSource) { + var includes = Path.resolve(this.includeSource); + if (FS.existsSync(includes) && FS.statSync(includes).isDirectory()) { + this.includes = includes; + } + else { + this.application.logger.warn('Could not find provided includes directory: ' + includes); + } + } + if (this.mediaSource) { + var media = Path.resolve(this.mediaSource); + if (FS.existsSync(media) && FS.statSync(media).isDirectory()) { + this.mediaDirectory = Path.join(event.outputDirectory, 'media'); + FS.copySync(media, this.mediaDirectory); + } + else { + this.mediaDirectory = null; + this.application.logger.warn('Could not find provided media directory: ' + media); + } + } + }; + MarkedPlugin.prototype.onParseMarkdown = function (event) { + event.parsedText = Marked(event.parsedText); + }; + __decorate([ + component_1.Option({ + name: 'includes', + help: 'Specifies the location to look for included documents (use [[include:FILENAME]] in comments).', + hint: declaration_1.ParameterHint.Directory + }) + ], MarkedPlugin.prototype, "includeSource", void 0); + __decorate([ + component_1.Option({ + name: 'media', + help: 'Specifies the location with media files that should be copied to the output directory.', + hint: declaration_1.ParameterHint.Directory + }) + ], MarkedPlugin.prototype, "mediaSource", void 0); + MarkedPlugin = __decorate([ + components_1.Component({ name: 'marked' }) + ], MarkedPlugin); + return MarkedPlugin; +}(components_1.ContextAwareRendererComponent)); +exports.MarkedPlugin = MarkedPlugin; +//# sourceMappingURL=MarkedPlugin.js.map \ No newline at end of file diff --git a/dist/lib/output/plugins/MarkedPlugin.js.map b/dist/lib/output/plugins/MarkedPlugin.js.map new file mode 100644 index 000000000..2a464cda4 --- /dev/null +++ b/dist/lib/output/plugins/MarkedPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MarkedPlugin.js","sourceRoot":"","sources":["../../../../src/lib/output/plugins/MarkedPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,2BAA6B;AAC7B,+BAAiC;AACjC,0CAA4C;AAC5C,uCAAyC;AAEzC,4CAAyE;AACzE,oCAAyD;AACzD,mDAA+C;AAC/C,+DAAgE;AAiChE;IAAkC,gCAA6B;IAD/D;QAAA,qEAyJC;QA5HW,oBAAc,GAAW,4BAA4B,CAAC;QAKtD,kBAAY,GAAW,2BAA2B,CAAC;;IAuH/D,CAAC;IAlHG,iCAAU,GAAV;QAAA,iBAWC;QAVG,iBAAM,UAAU,WAAE,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,sBAAa,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAErE,IAAM,IAAI,GAAG,IAAI,CAAC;QAClB,UAAU,CAAC,cAAc,CAAC,UAAU,EAAE,UAAS,GAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7G,UAAU,CAAC,cAAc,CAAC,aAAa,EAAE,UAAC,GAAW,IAAK,OAAA,GAAG,CAAC,CAAC,CAAC,KAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAApC,CAAoC,CAAC,CAAC;QAEhG,MAAM,CAAC,UAAU,CAAC;YACd,SAAS,EA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MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC;IAjJD;QALC,kBAAM,CAAC;YACJ,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,+FAA+F;YACrG,IAAI,EAAE,2BAAa,CAAC,SAAS;SAChC,CAAC;uDACoB;IAOtB;QALC,kBAAM,CAAC;YACJ,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,wFAAwF;YAC9F,IAAI,EAAE,2BAAa,CAAC,SAAS;SAChC,CAAC;qDACkB;IAbX,YAAY;QADxB,sBAAS,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;OACf,YAAY,CAwJxB;IAAD,mBAAC;CAAA,AAxJD,CAAkC,0CAA6B,GAwJ9D;AAxJY,oCAAY","sourcesContent":["import * as FS from 'fs-extra';\nimport * as Path from 'path';\nimport * as Marked from 'marked';\nimport * as HighlightJS from 'highlight.js';\nimport * as Handlebars from 'handlebars';\n\nimport { Component, ContextAwareRendererComponent } from '../components';\nimport { RendererEvent, MarkdownEvent } from '../events';\nimport { Option } from '../../utils/component';\nimport { ParameterHint } from '../../utils/options/declaration';\n\n/**\n * A plugin that exposes the markdown, compact and relativeURL helper to handlebars.\n *\n * Templates should parse all comments with the markdown handler so authors can\n * easily format their documentation. TypeDoc uses the Marked (https://github.com/chjj/marked)\n * markdown parser and HighlightJS (https://github.com/isagalaev/highlight.js) to highlight\n * code blocks within markdown sections. Additionally this plugin allows to link to other symbols\n * using double angle brackets.\n *\n * You can use the markdown helper anywhere in the templates to convert content to html:\n *\n * ```handlebars\n * {{#markdown}}{{{comment.text}}}{{/markdown}}\n * ```\n *\n * The compact helper removes all newlines of its content:\n *\n * ```handlebars\n * {{#compact}}\n * Compact\n * this\n * {{/compact}}\n * ```\n *\n * The relativeURL helper simply transforms an absolute url into a relative url:\n *\n * ```handlebars\n * {{#relativeURL url}}\n * ```\n */\n@Component({name: 'marked'})\nexport class MarkedPlugin extends ContextAwareRendererComponent {\n @Option({\n name: 'includes',\n help: 'Specifies the location to look for included documents (use [[include:FILENAME]] in comments).',\n hint: ParameterHint.Directory\n })\n includeSource: string;\n\n @Option({\n name: 'media',\n help: 'Specifies the location with media files that should be copied to the output directory.',\n hint: ParameterHint.Directory\n })\n mediaSource: string;\n\n /**\n * The path referenced files are located in.\n */\n private includes: string;\n\n /**\n * Path to the output media directory.\n */\n private mediaDirectory: string;\n\n /**\n * The pattern used to find references in markdown.\n */\n private includePattern: RegExp = /\\[\\[include:([^\\]]+?)\\]\\]/g;\n\n /**\n * The pattern used to find media links.\n */\n private mediaPattern: RegExp = /media:\\/\\/([^ \"\\)\\]\\}]+)/g;\n\n /**\n * Create a new MarkedPlugin instance.\n */\n initialize() {\n super.initialize();\n this.listenTo(this.owner, MarkdownEvent.PARSE, this.onParseMarkdown);\n\n const that = this;\n Handlebars.registerHelper('markdown', function(arg: any) { return that.parseMarkdown(arg.fn(this), this); });\n Handlebars.registerHelper('relativeURL', (url: string) => url ? this.getRelativeUrl(url) : url);\n\n Marked.setOptions({\n highlight: (text: any, lang: any) => this.getHighlighted(text, lang)\n });\n }\n\n /**\n * Highlight the synatx of the given text using HighlightJS.\n *\n * @param text The text taht should be highlightes.\n * @param lang The language that should be used to highlight the string.\n * @return A html string with syntax highlighting.\n */\n public getHighlighted(text: string, lang?: string): string {\n try {\n if (lang) {\n return HighlightJS.highlight(lang, text).value;\n } else {\n return HighlightJS.highlightAuto(text).value;\n }\n } catch (error) {\n this.application.logger.warn(error.message);\n return text;\n }\n }\n\n /**\n * Parse the given markdown string and return the resulting html.\n *\n * @param text The markdown string that should be parsed.\n * @param context The current handlebars context.\n * @returns The resulting html string.\n */\n public parseMarkdown(text: string, context: any) {\n if (this.includes) {\n text = text.replace(this.includePattern, (match: string, path: string) => {\n path = Path.join(this.includes, path.trim());\n if (FS.existsSync(path) && FS.statSync(path).isFile()) {\n const contents = FS.readFileSync(path, 'utf-8');\n if (path.substr(-4).toLocaleLowerCase() === '.hbs') {\n const template = Handlebars.compile(contents);\n return template(context);\n } else {\n return contents;\n }\n } else {\n return '';\n }\n });\n }\n\n if (this.mediaDirectory) {\n text = text.replace(this.mediaPattern, (match: string, path: string) => {\n if (FS.existsSync(Path.join(this.mediaDirectory, path))) {\n return this.getRelativeUrl('media') + '/' + path;\n } else {\n return match;\n }\n });\n }\n\n const event = new MarkdownEvent(MarkdownEvent.PARSE);\n event.originalText = text;\n event.parsedText = text;\n\n this.owner.trigger(event);\n return event.parsedText;\n }\n\n /**\n * Triggered before the renderer starts rendering a project.\n *\n * @param event An event object describing the current render operation.\n */\n protected onBeginRenderer(event: RendererEvent) {\n super.onBeginRenderer(event);\n\n delete this.includes;\n if (this.includeSource) {\n const includes = Path.resolve(this.includeSource);\n if (FS.existsSync(includes) && FS.statSync(includes).isDirectory()) {\n this.includes = includes;\n } else {\n this.application.logger.warn('Could not find provided includes directory: ' + includes);\n }\n }\n\n if (this.mediaSource) {\n const media = Path.resolve(this.mediaSource);\n if (FS.existsSync(media) && FS.statSync(media).isDirectory()) {\n this.mediaDirectory = Path.join(event.outputDirectory, 'media');\n FS.copySync(media, this.mediaDirectory);\n } else {\n this.mediaDirectory = null;\n this.application.logger.warn('Could not find provided media directory: ' + media);\n }\n }\n }\n\n /**\n * Triggered when [[MarkedPlugin]] parses a markdown string.\n *\n * @param event\n */\n onParseMarkdown(event: MarkdownEvent) {\n event.parsedText = Marked(event.parsedText);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/plugins/NavigationPlugin.d.ts b/dist/lib/output/plugins/NavigationPlugin.d.ts new file mode 100644 index 000000000..350cc18c6 --- /dev/null +++ b/dist/lib/output/plugins/NavigationPlugin.d.ts @@ -0,0 +1,8 @@ +import { RendererComponent } from '../components'; +import { NavigationItem } from '../models/NavigationItem'; +export declare class NavigationPlugin extends RendererComponent { + navigation: NavigationItem; + initialize(): void; + private onBeginRenderer(event); + private onBeginPage(page); +} diff --git a/dist/lib/output/plugins/NavigationPlugin.js b/dist/lib/output/plugins/NavigationPlugin.js new file mode 100644 index 000000000..2c98cccd8 --- /dev/null +++ b/dist/lib/output/plugins/NavigationPlugin.js @@ -0,0 +1,77 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var components_1 = require("../components"); +var events_1 = require("../events"); +var NavigationPlugin = (function (_super) { + __extends(NavigationPlugin, _super); + function NavigationPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + NavigationPlugin.prototype.initialize = function () { + this.listenTo(this.owner, (_a = {}, + _a[events_1.RendererEvent.BEGIN] = this.onBeginRenderer, + _a[events_1.PageEvent.BEGIN] = this.onBeginPage, + _a)); + var _a; + }; + NavigationPlugin.prototype.onBeginRenderer = function (event) { + this.navigation = this.owner.theme.getNavigation(event.project); + }; + NavigationPlugin.prototype.onBeginPage = function (page) { + var currentItems = []; + (function updateItem(item) { + item.isCurrent = false; + item.isInPath = false; + item.isVisible = item.isGlobals; + if (item.url === page.url || (item.dedicatedUrls && item.dedicatedUrls.indexOf(page.url) !== -1)) { + currentItems.push(item); + } + if (item.children) { + item.children.forEach(function (child) { return updateItem(child); }); + } + })(this.navigation); + currentItems.forEach(function (item) { + item.isCurrent = true; + var depth = item.isGlobals ? -1 : 0; + var count = 1; + while (item) { + item.isInPath = true; + item.isVisible = true; + count += 1; + depth += 1; + if (item.children) { + count += item.children.length; + if (depth < 2 || count < 30) { + item.children.forEach(function (child) { + child.isVisible = true; + }); + } + } + item = item.parent; + } + }); + page.navigation = this.navigation; + }; + NavigationPlugin = __decorate([ + components_1.Component({ name: 'navigation' }) + ], NavigationPlugin); + return NavigationPlugin; +}(components_1.RendererComponent)); +exports.NavigationPlugin = NavigationPlugin; +//# sourceMappingURL=NavigationPlugin.js.map \ No newline at end of file diff --git a/dist/lib/output/plugins/NavigationPlugin.js.map b/dist/lib/output/plugins/NavigationPlugin.js.map new file mode 100644 index 000000000..6f3da88c5 --- /dev/null +++ b/dist/lib/output/plugins/NavigationPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NavigationPlugin.js","sourceRoot":"","sources":["../../../../src/lib/output/plugins/NavigationPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4CAA6D;AAE7D,oCAAqD;AAWrD;IAAsC,oCAAiB;IAAvD;;IAwEA,CAAC;IA/DG,qCAAU,GAAV;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;YACpB,GAAC,sBAAa,CAAC,KAAK,IAAG,IAAI,CAAC,eAAe;YAC3C,GAAC,kBAAS,CAAC,KAAK,IAAO,IAAI,CAAC,WAAW;gBACzC,CAAC;;IACP,CAAC;IAOO,0CAAe,GAAvB,UAAwB,KAAoB;QACxC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;IAOO,sCAAW,GAAnB,UAAoB,IAAe;QAC/B,IAAM,YAAY,GAAqB,EAAE,CAAC;QAC1C,CAAC,oBAAoB,IAAoB;YACrC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,IAAI,CAAC,QAA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OAAO,CAAC,UAAC,KAAK;4BACxB,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;wBAC3B,CAAC,CAAC,CAAC;oBACP,CAAC;gBACL,CAAC;gBAED,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;YACvB,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACtC,CAAC;IAvEQ,gBAAgB;QAD5B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,gBAAgB,CAwE5B;IAAD,uBAAC;CAAA,AAxED,CAAsC,8BAAiB,GAwEtD;AAxEY,4CAAgB","sourcesContent":["import { Component, RendererComponent } from '../components';\nimport { NavigationItem } from '../models/NavigationItem';\nimport { RendererEvent, PageEvent } from '../events';\n\n/**\n * A plugin that exposes the navigation structure of the documentation\n * to the rendered templates.\n *\n * The navigation structure is generated using the current themes\n * [[BaseTheme.getNavigation]] function. This plugins takes care that the navigation\n * is updated and passed to the render context.\n */\n@Component({name: 'navigation'})\nexport class NavigationPlugin extends RendererComponent {\n /**\n * The navigation structure generated by the current theme.\n */\n navigation: NavigationItem;\n\n /**\n * Create a new NavigationPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [RendererEvent.BEGIN]: this.onBeginRenderer,\n [PageEvent.BEGIN]: this.onBeginPage\n });\n }\n\n /**\n * Triggered before the renderer starts rendering a project.\n *\n * @param event An event object describing the current render operation.\n */\n private onBeginRenderer(event: RendererEvent) {\n this.navigation = this.owner.theme.getNavigation(event.project);\n }\n\n /**\n * Triggered before a document will be rendered.\n *\n * @param page An event object describing the current render operation.\n */\n private onBeginPage(page: PageEvent) {\n const currentItems: NavigationItem[] = [];\n (function updateItem(item: NavigationItem) {\n item.isCurrent = false;\n item.isInPath = false;\n item.isVisible = item.isGlobals;\n\n if (item.url === page.url || (item.dedicatedUrls && item.dedicatedUrls.indexOf(page.url) !== -1)) {\n currentItems.push(item);\n }\n\n if (item.children) {\n item.children.forEach((child) => updateItem(child));\n }\n })(this.navigation);\n\n currentItems.forEach((item: NavigationItem) => {\n item.isCurrent = true;\n\n let depth = item.isGlobals ? -1 : 0;\n let count = 1;\n while (item) {\n item.isInPath = true;\n item.isVisible = true;\n\n count += 1;\n depth += 1;\n if (item.children) {\n count += item.children.length;\n if (depth < 2 || count < 30) {\n item.children.forEach((child) => {\n child.isVisible = true;\n });\n }\n }\n\n item = item.parent;\n }\n });\n\n page.navigation = this.navigation;\n }\n}\n"]} \ No newline at end of file diff --git a/dist/lib/output/plugins/PrettyPrintPlugin.d.ts b/dist/lib/output/plugins/PrettyPrintPlugin.d.ts new file mode 100644 index 000000000..9436fa8e9 --- /dev/null +++ b/dist/lib/output/plugins/PrettyPrintPlugin.d.ts @@ -0,0 +1,8 @@ +import { RendererComponent } from '../components'; +import { PageEvent } from '../events'; +export declare class PrettyPrintPlugin extends RendererComponent { + static IGNORED_TAGS: any; + static PRE_TAGS: any; + initialize(): void; + onRendererEndPage(event: PageEvent): void; +} diff --git a/dist/lib/output/plugins/PrettyPrintPlugin.js b/dist/lib/output/plugins/PrettyPrintPlugin.js new file mode 100644 index 000000000..122971b6f --- /dev/null +++ b/dist/lib/output/plugins/PrettyPrintPlugin.js @@ -0,0 +1,149 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var components_1 = require("../components"); +var events_1 = require("../events"); +var PrettyPrintState; +(function (PrettyPrintState) { + PrettyPrintState[PrettyPrintState["Default"] = 0] = "Default"; + PrettyPrintState[PrettyPrintState["Comment"] = 1] = "Comment"; + PrettyPrintState[PrettyPrintState["Pre"] = 2] = "Pre"; +})(PrettyPrintState || (PrettyPrintState = {})); +var PrettyPrintPlugin = (function (_super) { + __extends(PrettyPrintPlugin, _super); + function PrettyPrintPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + PrettyPrintPlugin_1 = PrettyPrintPlugin; + PrettyPrintPlugin.prototype.initialize = function () { + this.listenTo(this.owner, events_1.PageEvent.END, this.onRendererEndPage, -1024); + }; + PrettyPrintPlugin.prototype.onRendererEndPage = function (event) { + var match; + var line; + var lineState; + var lineDepth; + var tagName; + var preName; + var tagExp = /<\s*(\w+)[^>]*>|<\/\s*(\w+)[^>]*>|/g; + var emptyLineExp = /^[\s]*$/; + var minLineDepth = 1; + var state = PrettyPrintState.Default; + var stack = []; + var lines = event.contents.split(/\r\n?|\n/); + var index = 0; + var count = lines.length; + while (index < count) { + line = lines[index]; + if (emptyLineExp.test(line)) { + if (state === PrettyPrintState.Default) { + lines.splice(index, 1); + count -= 1; + continue; + } + } + else { + lineState = state; + lineDepth = stack.length; + while (match = tagExp.exec(line)) { + if (state === PrettyPrintState.Comment) { + if (match[0] === '-->') { + state = PrettyPrintState.Default; + } + } + else if (state === PrettyPrintState.Pre) { + if (match[2] && match[2].toLowerCase() === preName) { + state = PrettyPrintState.Default; + } + } + else { + if (match[0] === '/g;\n let emptyLineExp = /^[\\s]*$/;\n let minLineDepth = 1;\n let state = PrettyPrintState.Default;\n const stack: string[] = [];\n\n const lines = event.contents.split(/\\r\\n?|\\n/);\n let index = 0;\n let count = lines.length;\n\n while (index < count) {\n line = lines[index];\n if (emptyLineExp.test(line)) {\n if (state === PrettyPrintState.Default) {\n lines.splice(index, 1);\n count -= 1;\n continue;\n }\n } else {\n lineState = state;\n lineDepth = stack.length;\n\n while (match = tagExp.exec(line)) {\n if (state === PrettyPrintState.Comment) {\n if (match[0] === '-->') {\n state = PrettyPrintState.Default;\n }\n } else if (state === PrettyPrintState.Pre) {\n if (match[2] && match[2].toLowerCase() === preName) {\n state = PrettyPrintState.Default;\n }\n } else {\n if (match[0] === '