diff --git a/package-lock.json b/package-lock.json index dcbdf7b51..4a0eca382 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "typedoc", - "version": "0.15.2", + "version": "0.15.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/lib/converter/nodes/export-declaration.ts b/src/lib/converter/nodes/export-declaration.ts new file mode 100644 index 000000000..1119792fe --- /dev/null +++ b/src/lib/converter/nodes/export-declaration.ts @@ -0,0 +1,39 @@ +import * as ts from 'typescript'; + +import { Reflection, ReflectionFlag, DeclarationReflection } from '../../models/index'; +import { Context } from '../context'; +import { Component, ConverterNodeComponent } from '../components'; + +@Component({name: 'node:export-declaration'}) +export class ExportDeclarationConverter extends ConverterNodeComponent { + /** + * List of supported TypeScript syntax kinds. + */ + supports: ts.SyntaxKind[] = [ + ts.SyntaxKind.ExportDeclaration + ]; + + convert(context: Context, node: ts.ExportDeclaration): Reflection { + // export list declaration (export {Foo, Bar};) + if (node && node.exportClause) { + const project = context.project; + for (const exportSpecifier of node.exportClause.elements) { + const identifier = exportSpecifier.name.text; + const reflection = project.findReflectionByName(identifier); + if (reflection) { + markAsExported(reflection); + } + } + } + + function markAsExported(reflection: Reflection) { + if (reflection instanceof DeclarationReflection) { + reflection.setFlag(ReflectionFlag.Exported, true); + } + + reflection.traverse(markAsExported); + } + + return context.scope; + } +} diff --git a/src/lib/converter/nodes/index.ts b/src/lib/converter/nodes/index.ts index bdf4e681f..9b8a7adec 100644 --- a/src/lib/converter/nodes/index.ts +++ b/src/lib/converter/nodes/index.ts @@ -5,6 +5,7 @@ export { ClassConverter } from './class'; export { ConstructorConverter } from './constructor'; export { EnumConverter } from './enum'; export { ExportConverter } from './export'; +export { ExportDeclarationConverter } from './export-declaration'; export { FunctionConverter } from './function'; export { InterfaceConverter } from './interface'; export { TypeLiteralConverter } from './literal-type'; diff --git a/src/test/converter/export-list-class/export-list-class.ts b/src/test/converter/export-list-class/export-list-class.ts new file mode 100644 index 000000000..9dd285ed2 --- /dev/null +++ b/src/test/converter/export-list-class/export-list-class.ts @@ -0,0 +1,4 @@ +class Foo {} +class Bar {} + +export { Foo, Bar }; diff --git a/src/test/converter/export-list-class/specs.json b/src/test/converter/export-list-class/specs.json new file mode 100644 index 000000000..0b376dbcf --- /dev/null +++ b/src/test/converter/export-list-class/specs.json @@ -0,0 +1,77 @@ +{ + "id": 0, + "name": "typedoc", + "kind": 0, + "flags": {}, + "children": [ + { + "id": 1, + "name": "\"export-list-class\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true + }, + "originalName": "%BASE%/export-list-class/export-list-class.ts", + "children": [ + { + "id": 3, + "name": "Bar", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true + }, + "sources": [ + { + "fileName": "export-list-class.ts", + "line": 2, + "character": 9 + } + ] + }, + { + "id": 2, + "name": "Foo", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true + }, + "sources": [ + { + "fileName": "export-list-class.ts", + "line": 1, + "character": 9 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 3, 2 + ] + } + ], + "sources": [ + { + "fileName": "export-list-class.ts", + "line": 1, + "character": 0 + } + ] + } + ], + "groups": [ + { + "title": "External modules", + "kind": 1, + "children": [ + 1 + ] + } + ] +}