Skip to content

Commit

Permalink
fix: Circular dependencies
Browse files Browse the repository at this point in the history
Closes #1172
  • Loading branch information
Gerrit0 committed Jan 15, 2020
1 parent 90d4c30 commit 64a9323
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/index.ts
Expand Up @@ -12,10 +12,6 @@ export { DefaultTheme } from './lib/output/themes/DefaultTheme';
export { NavigationItem } from './lib/output/models/NavigationItem';
export { UrlMapping } from './lib/output/models/UrlMapping';

export {
SourceFileMode
} from './lib/converter';

export {
Option, // deprecated
BindOption,
Expand All @@ -29,6 +25,7 @@ export {
TypeDocAndTSOptions,
TypeDocOptionMap,
KeyToDeclaration,
SourceFileMode,

TSConfigReader,
TypeDocReader,
Expand Down
2 changes: 0 additions & 2 deletions src/lib/converter/index.ts
Expand Up @@ -3,8 +3,6 @@ export { Converter } from './converter';

export { convertDefaultValue, convertExpression } from './convert-expression';

export { SourceFileMode } from './nodes';

import './nodes/index';
import './types/index';
import './plugins/index';
6 changes: 1 addition & 5 deletions src/lib/converter/nodes/block.ts
Expand Up @@ -4,18 +4,14 @@ import { Reflection, ReflectionKind, ReflectionFlag } from '../../models/index';
import { createDeclaration } from '../factories/index';
import { Context } from '../context';
import { Component, ConverterNodeComponent } from '../components';
import { BindOption } from '../../utils';
import { BindOption, SourceFileMode } from '../../utils';

const preferred: ts.SyntaxKind[] = [
ts.SyntaxKind.ClassDeclaration,
ts.SyntaxKind.InterfaceDeclaration,
ts.SyntaxKind.EnumDeclaration
];

export enum SourceFileMode {
File, Modules
}

@Component({name: 'node:block'})
export class BlockConverter extends ConverterNodeComponent<ts.SourceFile|ts.Block|ts.ModuleBlock> {
@BindOption('mode')
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/nodes/export.ts
Expand Up @@ -4,7 +4,7 @@ import { Reflection, ReflectionFlag, DeclarationReflection, ContainerReflection
import { Context } from '../context';
import { Component, ConverterNodeComponent } from '../components';
import { createReferenceReflection } from '../factories/reference';
import { SourceFileMode } from './block';
import { SourceFileMode } from '../../utils';

@Component({name: 'node:export'})
export class ExportConverter extends ConverterNodeComponent<ts.ExportAssignment> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/nodes/index.ts
@@ -1,6 +1,6 @@
export { AccessorConverter } from './accessor';
export { AliasConverter } from './alias';
export { BlockConverter, SourceFileMode } from './block';
export { BlockConverter } from './block';
export { ClassConverter } from './class';
export { ConstructorConverter } from './constructor';
export { EnumConverter } from './enum';
Expand Down
17 changes: 15 additions & 2 deletions src/lib/utils/index.ts
@@ -1,8 +1,21 @@
export { Option, Options, ParameterType, ParameterHint, ParameterScope, BindOption } from './options';
export {
Option,
Options,
ParameterType,
ParameterHint,
ParameterScope,
BindOption,
SourceFileMode
} from './options';
export { insertPrioritySorted, removeIfPresent } from './array';
export { Component, AbstractComponent, ChildableComponent } from './component';
export { Event, EventDispatcher } from './events';
export { normalizePath, directoryExists, ensureDirectoriesExist, writeFile } from './fs';
export {
normalizePath,
directoryExists,
ensureDirectoriesExist,
writeFile
} from './fs';
export { Logger, LogLevel, ConsoleLogger, CallbackLogger } from './loggers';
export { PluginHost } from './plugins';
export { Result } from './result';
5 changes: 4 additions & 1 deletion src/lib/utils/options/declaration.ts
@@ -1,7 +1,6 @@
import * as _ from 'lodash';
import { CompilerOptions } from 'typescript';
import { Result } from '../result';
import { SourceFileMode } from '../../converter/nodes/block';
import { IgnoredTsOptionKeys } from './sources/typescript';

/**
Expand Down Expand Up @@ -31,6 +30,10 @@ type KnownKeys<T> = {
export type TypeDocAndTSOptions = TypeDocOptions
& Pick<CompilerOptions, Exclude<KnownKeys<CompilerOptions>, IgnoredTsOptionKeys>>;

export enum SourceFileMode {
File, Modules
}

/**
* Describes all TypeDoc options. Used internally to provide better types when fetching options.
* External consumers should likely use either [[TypeDocAndTSOptions]] or [[TypeDocOptions]].
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/options/index.ts
Expand Up @@ -4,6 +4,7 @@ export { ArgumentsReader, TypeDocReader, TSConfigReader } from './readers';
export {
TypeDocOptions,
TypeDocAndTSOptions,
SourceFileMode,

TypeDocOptionMap,
KeyToDeclaration,
Expand Down
18 changes: 15 additions & 3 deletions src/lib/utils/options/sources/decorator.ts
@@ -1,6 +1,6 @@
import { DeclarationOption } from '../declaration';
import { Options } from '..';
import { BindOption } from '../options';
import { Application } from '../../../application';

const declared: DeclarationOption[] = [];

Expand All @@ -14,10 +14,22 @@ export function addDecoratedOptions(options: Options) {
* @deprecated Options should be declared on the options object. Will be removed in 0.17.
* @param option
*/
export function Option(option: DeclarationOption): PropertyDecorator {
export function Option(option: DeclarationOption) {
console.warn('The @Option decorator is deprecated and will be removed in v0.17.');
console.warn(` (Used to register ${option.name})`);
declared.push(option);

return BindOption(option.name) as any;
return function(target: { application: Application } | { options: Options }, key: PropertyKey) {
Object.defineProperty(target, key, {
get(this: { application: Application } | { options: Options }) {
if ('options' in this) {
return this.options.getValue(name);
} else {
return this.application.options.getValue(name);
}
},
enumerable: true,
configurable: true
});
};
}
3 changes: 1 addition & 2 deletions src/lib/utils/options/sources/typedoc.ts
@@ -1,6 +1,5 @@
import { Options } from '..';
import { ParameterType, ParameterHint } from '../declaration';
import { SourceFileMode } from '../../../..';
import { ParameterType, ParameterHint, SourceFileMode } from '../declaration';

export function addTypeDocOptions(options: Options) {
options.addDeclaration({
Expand Down
3 changes: 1 addition & 2 deletions src/test/converter.test.ts
Expand Up @@ -2,7 +2,6 @@ import { Application, resetReflectionID, normalizePath, ProjectReflection } from
import * as FS from 'fs';
import * as Path from 'path';
import { deepStrictEqual as equal, ok } from 'assert';
import { SourceFileMode } from '../lib/converter/nodes/block';
import { ScriptTarget, ModuleKind, JsxEmit } from 'typescript';

import json = require('./converter/class/specs.json');
Expand All @@ -12,7 +11,7 @@ describe('Converter', function() {
const base = Path.join(__dirname, 'converter');
const app = new Application();
app.bootstrap({
mode: SourceFileMode.Modules,
mode: 'modules',
logger: 'none',
target: ScriptTarget.ES5,
module: ModuleKind.CommonJS,
Expand Down

0 comments on commit 64a9323

Please sign in to comment.