From c5d021eb15160d4233d3c1894b2a43e274d542d0 Mon Sep 17 00:00:00 2001 From: Martin <7252614+Lhoerion@users.noreply.github.com> Date: Tue, 12 May 2020 18:47:51 +0200 Subject: [PATCH 1/5] Fix module declaration parsed as namespace --- src/lib/converter/nodes/module.ts | 4 +- src/test/converter/function/specs.json | 272 ++++++++--------- src/test/converter/interface/specs.json | 12 +- .../specs/classes/_access_.privateclass.html | 3 +- .../specs/classes/_classes_.baseclass.html | 1 - .../specs/classes/_classes_.genericclass.html | 1 - .../classes/_classes_.internalclass.html | 1 - .../classes/_classes_.nongenericclass.html | 1 - .../specs/classes/_classes_.subclassa.html | 1 - .../specs/classes/_classes_.subclassb.html | 1 - ..._default_export_.defaultexportedclass.html | 1 - ..._default_export_.notexportedclassname.html | 1 - .../classes/_flattened_.flattenedclass.html | 1 - .../renderer/specs/classes/_mixin_.base.html | 1 - .../classes/_mixin_.someclasswithmixin.html | 1 - .../_single_export_.notexportedclass.html | 1 - .../_single_export_.singleexportedclass.html | 1 - .../enums/_enumerations_.directions.html | 1 - .../specs/enums/_enumerations_.size.html | 1 - src/test/renderer/specs/globals.html | 1 - src/test/renderer/specs/index.html | 1 - .../interfaces/_classes_.nameinterface.html | 1 - .../interfaces/_classes_.printinterface.html | 1 - .../_classes_.printnameinterface.html | 1 - .../specs/interfaces/_generics_.a.html | 1 - .../specs/interfaces/_generics_.ab.html | 1 - .../specs/interfaces/_generics_.abnumber.html | 1 - .../specs/interfaces/_generics_.abstring.html | 1 - .../specs/interfaces/_generics_.b.html | 1 - .../specs/interfaces/_mixin_.mixin1type.html | 1 - .../specs/interfaces/_mixin_.mixin2.html | 1 - src/test/renderer/specs/modules/_access_.html | 7 +- .../specs/modules/_access_.privatemodule.html | 13 +- .../renderer/specs/modules/_classes_.html | 1 - .../specs/modules/_default_export_.html | 1 - .../specs/modules/_enumerations_.html | 1 - .../renderer/specs/modules/_flattened_.html | 1 - .../renderer/specs/modules/_functions_.html | 94 +++++- .../modules/_functions_.modulefunction.html | 285 ------------------ .../renderer/specs/modules/_generics_.html | 1 - src/test/renderer/specs/modules/_mixin_.html | 1 - src/test/renderer/specs/modules/_mod2_.html | 1 - src/test/renderer/specs/modules/_mod_.html | 1 - .../renderer/specs/modules/_modules_.html | 7 +- .../specs/modules/_modules_.mymodule.html | 35 ++- .../_modules_.mymodule.mysubmodule.html | 26 +- .../specs/modules/_single_export_.html | 1 - .../renderer/specs/modules/_weird_names_.html | 1 - 48 files changed, 273 insertions(+), 522 deletions(-) delete mode 100644 src/test/renderer/specs/modules/_functions_.modulefunction.html diff --git a/src/lib/converter/nodes/module.ts b/src/lib/converter/nodes/module.ts index 7c015fda3..f1e4bc5e1 100644 --- a/src/lib/converter/nodes/module.ts +++ b/src/lib/converter/nodes/module.ts @@ -24,7 +24,9 @@ export class ModuleConverter extends ConverterNodeComponent context.scope - : createDeclaration(context, node, ReflectionKind.Namespace); + : createDeclaration(context, node, (node.flags & ts.NodeFlags.Namespace) == ts.NodeFlags.Namespace + ? ReflectionKind.Namespace + : ReflectionKind.Module); context.withScope(reflection, () => { if (node.body) { this.owner.convertNode(context, node.body); diff --git a/src/test/converter/function/specs.json b/src/test/converter/function/specs.json index 860c021ba..8f1157a0b 100644 --- a/src/test/converter/function/specs.json +++ b/src/test/converter/function/specs.json @@ -14,135 +14,6 @@ }, "originalName": "%BASE%/function/function.ts", "children": [ - { - "id": 35, - "name": "moduleFunction", - "kind": 2, - "kindString": "Namespace", - "flags": { - "isExported": true - }, - "comment": { - "shortText": "This is the module extending the function moduleFunction()." - }, - "signatures": [ - { - "id": 36, - "name": "moduleFunction", - "kind": 4096, - "kindString": "Call signature", - "flags": { - "isExported": true - }, - "comment": { - "shortText": "This is a function that is extended by a module." - }, - "parameters": [ - { - "id": 37, - "name": "arg", - "kind": 32768, - "kindString": "Parameter", - "flags": { - "isExported": true - }, - "comment": { - "text": "An argument.\n" - }, - "type": { - "type": "intrinsic", - "name": "string" - } - } - ], - "type": { - "type": "intrinsic", - "name": "string" - } - } - ], - "children": [ - { - "id": 52, - "name": "functionVariable", - "kind": 32, - "kindString": "Variable", - "flags": { - "isLet": true - }, - "comment": { - "shortText": "This variable is appended to a function." - }, - "type": { - "type": "intrinsic", - "name": "string" - } - }, - { - "id": 53, - "name": "append", - "kind": 64, - "kindString": "Function", - "flags": {}, - "signatures": [ - { - "id": 54, - "name": "append", - "kind": 4096, - "kindString": "Call signature", - "flags": {}, - "comment": { - "shortText": "This function is appended to another function." - }, - "type": { - "type": "intrinsic", - "name": "void" - } - } - ] - }, - { - "id": 55, - "name": "prepend", - "kind": 64, - "kindString": "Function", - "flags": {}, - "signatures": [ - { - "id": 56, - "name": "prepend", - "kind": 4096, - "kindString": "Call signature", - "flags": {}, - "comment": { - "shortText": "This function is appended to another function." - }, - "type": { - "type": "intrinsic", - "name": "void" - } - } - ] - } - ], - "groups": [ - { - "title": "Variables", - "kind": 32, - "children": [ - 52 - ] - }, - { - "title": "Functions", - "kind": 64, - "children": [ - 53, - 55 - ] - } - ] - }, { "id": 44, "name": "assertIsNonNull", @@ -737,6 +608,141 @@ } ] }, + { + "id": 35, + "name": "moduleFunction", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true + }, + "signatures": [ + { + "id": 36, + "name": "moduleFunction", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "isExported": true + }, + "comment": { + "shortText": "This is a function that is extended by a module." + }, + "parameters": [ + { + "id": 37, + "name": "arg", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isExported": true + }, + "comment": { + "text": "An argument.\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "children": [ + { + "id": 52, + "name": "functionVariable", + "kind": 32, + "kindString": "Variable", + "flags": { + "isExported": true, + "isLet": true + }, + "comment": { + "shortText": "This variable is appended to a function." + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 53, + "name": "append", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true + }, + "signatures": [ + { + "id": 54, + "name": "append", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "isExported": true + }, + "comment": { + "shortText": "This function is appended to another function." + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ] + }, + { + "id": 55, + "name": "prepend", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true + }, + "signatures": [ + { + "id": 56, + "name": "prepend", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "isExported": true + }, + "comment": { + "shortText": "This function is appended to another function." + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ] + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 52 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 53, + 55 + ] + } + ] + }, { "id": 28, "name": "multipleSignatures", @@ -910,13 +916,6 @@ } ], "groups": [ - { - "title": "Namespaces", - "kind": 2, - "children": [ - 35 - ] - }, { "title": "Functions", "kind": 64, @@ -931,6 +930,7 @@ 25, 2, 48, + 35, 28, 11 ] diff --git a/src/test/converter/interface/specs.json b/src/test/converter/interface/specs.json index 1832ed291..969a84519 100644 --- a/src/test/converter/interface/specs.json +++ b/src/test/converter/interface/specs.json @@ -296,9 +296,11 @@ { "id": 21, "name": "Forms", - "kind": 2, - "kindString": "Namespace", - "flags": {}, + "kind": 1, + "kindString": "Module", + "flags": { + "isExported": true + }, "children": [ { "id": 64, @@ -1345,8 +1347,8 @@ ], "groups": [ { - "title": "Namespaces", - "kind": 2, + "title": "Modules", + "kind": 1, "children": [ 21 ] diff --git a/src/test/renderer/specs/classes/_access_.privateclass.html b/src/test/renderer/specs/classes/_access_.privateclass.html index 10974afe9..55df9c672 100644 --- a/src/test/renderer/specs/classes/_access_.privateclass.html +++ b/src/test/renderer/specs/classes/_access_.privateclass.html @@ -183,7 +183,7 @@

Returns void "access" @@ -271,7 +271,6 @@

Returns voidLegend