Skip to content

Commit

Permalink
fix!: Rename external modules to modules
Browse files Browse the repository at this point in the history
Closes #109

BREAKING CHANGE: Any plugins which referenced ReflectionKind.ExternalModule or ReflectionKind.Module need to be updated to reference ReflectionKind.Module and ReflectionKind.Namespace respectively.
  • Loading branch information
Gerrit0 committed Mar 15, 2020
1 parent 5d41a2e commit 295ccdd
Show file tree
Hide file tree
Showing 71 changed files with 1,163 additions and 1,984 deletions.
8 changes: 4 additions & 4 deletions src/lib/converter/factories/declaration.ts
Expand Up @@ -12,7 +12,7 @@ import { createReferenceType } from './reference';
const nonStaticKinds = [
ReflectionKind.Class,
ReflectionKind.Interface,
ReflectionKind.Module
ReflectionKind.Namespace
];

/**
Expand Down Expand Up @@ -73,13 +73,13 @@ export function createDeclaration(context: Context, node: ts.Declaration, kind:
let hasComment: boolean = Boolean(getRawComment(node));
// Test whether the node is exported
let isExported: boolean;
if (kind === ReflectionKind.ExternalModule || kind === ReflectionKind.Global) {
if (kind === ReflectionKind.Module || kind === ReflectionKind.Global) {
isExported = true;
hasComment = true;
} else if (container.kind === ReflectionKind.Global) {
// In file mode, everything is exported.
isExported = true;
} else if (container.kindOf([ReflectionKind.Module, ReflectionKind.ExternalModule])) {
} else if (container.kindOf([ReflectionKind.Namespace, ReflectionKind.Module])) {
const symbol = context.getSymbolAtLocation(node);
if (!symbol) {
isExported = false;
Expand Down Expand Up @@ -220,7 +220,7 @@ function canMergeReflectionsByKind(kind1: ReflectionKind, kind2: ReflectionKind)
*/
function mergeDeclarations(context: Context, reflection: DeclarationReflection, node: ts.Node, kind: ReflectionKind) {
if (reflection.kind !== kind) {
const weights = [ReflectionKind.Module, ReflectionKind.Enum, ReflectionKind.Class];
const weights = [ReflectionKind.Namespace, ReflectionKind.Enum, ReflectionKind.Class];
const kindWeight = weights.indexOf(kind);
const childKindWeight = weights.indexOf(reflection.kind);
if (kindWeight > childKindWeight) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/nodes/block.ts
Expand Up @@ -55,7 +55,7 @@ export class BlockConverter extends ConverterNodeComponent<ts.SourceFile|ts.Bloc

context.withSourceFile(node, () => {
if (this.mode === SourceFileMode.Modules) {
result = createDeclaration(context, node, ReflectionKind.ExternalModule, node.fileName);
result = createDeclaration(context, node, ReflectionKind.Module, node.fileName);
context.withScope(result, () => {
this.convertStatements(context, node);
result!.setFlag(ReflectionFlag.Exported);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/nodes/module.ts
Expand Up @@ -24,7 +24,7 @@ export class ModuleConverter extends ConverterNodeComponent<ts.ModuleDeclaration
convert(context: Context, node: ts.ModuleDeclaration): Reflection | undefined {
const reflection = context.isInherit && context.inheritParent === node
? <DeclarationReflection> context.scope
: createDeclaration(context, node, ReflectionKind.Module);
: createDeclaration(context, node, ReflectionKind.Namespace);
context.withScope(reflection, () => {
if (node.body) {
this.owner.convertNode(context, node.body);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/converter/plugins/CommentPlugin.ts
Expand Up @@ -137,7 +137,7 @@ export class CommentPlugin extends ConverterComponent {
comment.removeTags('event');
}

if (reflection.kindOf(ReflectionKind.ExternalModule)) {
if (reflection.kindOf(ReflectionKind.Module)) {
comment.removeTags('packagedocumentation');
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@ export class CommentPlugin extends ConverterComponent {
const comment = parseComment(rawComment, reflection.comment);
this.applyModifiers(reflection, comment);
this.removeExcludedTags(comment);
} else if (reflection.kindOf(ReflectionKind.Module)) {
} else if (reflection.kindOf(ReflectionKind.Namespace)) {
this.storeModuleComment(rawComment, reflection);
} else {
const comment = parseComment(rawComment, reflection.comment);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/plugins/DynamicModulePlugin.ts
Expand Up @@ -52,7 +52,7 @@ export class DynamicModulePlugin extends ConverterComponent {
* @param node The node that is currently processed if available.
*/
private onDeclaration(context: Context, reflection: Reflection, node?: ts.Node) {
if (reflection.kindOf(ReflectionKind.ExternalModule)) {
if (reflection.kindOf(ReflectionKind.Module)) {
let name = reflection.name;
if (!name.includes('/')) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/plugins/GroupPlugin.ts
Expand Up @@ -17,8 +17,8 @@ export class GroupPlugin extends ConverterComponent {
*/
static WEIGHTS = [
ReflectionKind.Global,
ReflectionKind.ExternalModule,
ReflectionKind.Module,
ReflectionKind.Namespace,
ReflectionKind.Enum,
ReflectionKind.EnumMember,
ReflectionKind.Class,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/models/reflections/abstract.ts
Expand Up @@ -36,8 +36,8 @@ export function resetReflectionID() {
*/
export enum ReflectionKind {
Global = 0,
ExternalModule = 1 << 0,
Module = 1 << 1,
Module = 1 << 0,
Namespace = 1 << 1,
Enum = 1 << 2,
EnumMember = 1 << 4,
Variable = 1 << 5,
Expand Down Expand Up @@ -66,7 +66,7 @@ export enum ReflectionKind {
FunctionOrMethod = ReflectionKind.Function | Method,
ClassMember = Accessor | Constructor | Method | Property | Event,
SomeSignature = CallSignature | IndexSignature | ConstructorSignature | GetSignature | SetSignature,
SomeModule = Module | ExternalModule,
SomeModule = Namespace | Module,
SomeType = Interface | TypeLiteral | TypeParameter | TypeAlias,
SomeValue = Variable | Function | ObjectLiteral
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/output/themes/DefaultTheme.ts
Expand Up @@ -61,7 +61,7 @@ export class DefaultTheme extends Theme {
directory: 'enums',
template: 'reflection.hbs'
}, {
kind: [ReflectionKind.Module, ReflectionKind.ExternalModule],
kind: [ReflectionKind.Namespace, ReflectionKind.Module],
isLeaf: false,
directory: 'modules',
template: 'reflection.hbs'
Expand Down Expand Up @@ -375,7 +375,7 @@ export class NavigationBuilder {
let target = someModule.parent;
let inScope = (someModule === this.entryPoint);
while (target) {
if (target.kindOf(ReflectionKind.ExternalModule)) {
if (target.kindOf(ReflectionKind.Module)) {
return;
}
if (this.entryPoint === target) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/converter/alias/specs.json
Expand Up @@ -8,7 +8,7 @@
"id": 1,
"name": "\"alias\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -629,7 +629,7 @@
],
"groups": [
{
"title": "External modules",
"title": "Modules",
"kind": 1,
"children": [
1
Expand Down
24 changes: 12 additions & 12 deletions src/test/converter/class/specs-with-lump-categories.json
Expand Up @@ -8,7 +8,7 @@
"id": 1,
"name": "\"access\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -336,7 +336,7 @@
"id": 15,
"name": "\"class\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -1794,7 +1794,7 @@
"id": 77,
"name": "\"clodule-with-subclass\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -1940,7 +1940,7 @@
"id": 82,
"name": "\"constructor-properties\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -2411,7 +2411,7 @@
"id": 103,
"name": "\"decorators\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -2778,7 +2778,7 @@
"id": 147,
"name": "\"events\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -2855,7 +2855,7 @@
"id": 120,
"name": "\"events-overloads\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -3280,7 +3280,7 @@
"id": 150,
"name": "\"generic-class\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -3717,7 +3717,7 @@
"id": 168,
"name": "\"getter-setter\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -3924,7 +3924,7 @@
"id": 180,
"name": "\"this\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -4018,7 +4018,7 @@
"id": 184,
"name": "\"type-operator\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -4200,7 +4200,7 @@
],
"groups": [
{
"title": "External modules",
"title": "Modules",
"kind": 1,
"children": [
1,
Expand Down
24 changes: 12 additions & 12 deletions src/test/converter/class/specs-without-exported.json
Expand Up @@ -8,7 +8,7 @@
"id": 1,
"name": "\"access\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -336,7 +336,7 @@
"id": 15,
"name": "\"class\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -1677,7 +1677,7 @@
"id": 71,
"name": "\"clodule-with-subclass\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -1823,7 +1823,7 @@
"id": 76,
"name": "\"constructor-properties\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand All @@ -1840,7 +1840,7 @@
"id": 77,
"name": "\"decorators\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand All @@ -1857,7 +1857,7 @@
"id": 79,
"name": "\"events\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand All @@ -1874,7 +1874,7 @@
"id": 78,
"name": "\"events-overloads\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand All @@ -1891,7 +1891,7 @@
"id": 80,
"name": "\"generic-class\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand All @@ -1908,7 +1908,7 @@
"id": 81,
"name": "\"getter-setter\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand All @@ -1925,7 +1925,7 @@
"id": 82,
"name": "\"this\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -2019,7 +2019,7 @@
"id": 86,
"name": "\"type-operator\"",
"kind": 1,
"kindString": "External module",
"kindString": "Module",
"flags": {
"isExported": true
},
Expand Down Expand Up @@ -2201,7 +2201,7 @@
],
"groups": [
{
"title": "External modules",
"title": "Modules",
"kind": 1,
"children": [
1,
Expand Down

0 comments on commit 295ccdd

Please sign in to comment.