From ef0c17e5c8d2680f8451027180dc9d9b25938100 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Tue, 14 Jan 2020 12:47:14 -0700 Subject: [PATCH] feat: Add `@BindOption` Closes #1165 --- src/index.ts | 3 +- src/lib/application.ts | 44 +--- src/lib/cli.ts | 28 +-- src/lib/converter/converter.ts | 44 +--- src/lib/converter/nodes/block.ts | 13 +- src/lib/converter/plugins/CategoryPlugin.ts | 22 +- src/lib/converter/plugins/GitHubPlugin.ts | 10 +- src/lib/converter/plugins/PackagePlugin.ts | 7 +- src/lib/output/plugins/MarkedLinksPlugin.ts | 8 +- src/lib/output/plugins/MarkedPlugin.ts | 18 +- src/lib/output/renderer.ts | 46 +---- src/lib/utils/index.ts | 2 +- src/lib/utils/options/index.ts | 2 +- src/lib/utils/options/options.ts | 47 ++++- src/lib/utils/options/sources/decorator.ts | 33 +-- src/lib/utils/options/sources/index.ts | 3 +- src/lib/utils/options/sources/typedoc.ts | 189 ++++++++++++++++++ src/lib/utils/plugins.ts | 8 +- .../renderer/specs/classes/_mixin_.base.html | 4 +- .../classes/_mixin_.someclasswithmixin.html | 16 +- .../specs/interfaces/_mixin_.mixin1type.html | 8 +- .../specs/interfaces/_mixin_.mixin2.html | 12 +- src/test/renderer/specs/modules/_mixin_.html | 14 +- 23 files changed, 320 insertions(+), 261 deletions(-) create mode 100644 src/lib/utils/options/sources/typedoc.ts diff --git a/src/index.ts b/src/index.ts index ba160bc43..7e00ee89c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,7 +17,8 @@ export { } from './lib/converter'; export { - Option, + Option, // deprecated + BindOption, Options, OptionsReader, ParameterHint, diff --git a/src/lib/application.ts b/src/lib/application.ts index 9c95ef799..14d855d40 100644 --- a/src/lib/application.ts +++ b/src/lib/application.ts @@ -23,8 +23,7 @@ import { Component, DUMMY_APPLICATION_OWNER } from './utils/component'; -import { Option, Options, ParameterType } from './utils'; -import { ParameterHint } from './utils/options'; +import { Options, BindOption } from './utils'; import { TypeDocAndTSOptions } from './utils/options/declaration'; import { addDecoratedOptions } from './utils/options/sources'; @@ -71,51 +70,22 @@ export class Application extends ChildableComponent< plugins: PluginHost; - @Option({ - name: 'logger', - help: "Specify the logger that should be used, 'none' or 'console'", - defaultValue: 'console', - type: ParameterType.Mixed - }) + @BindOption('logger') loggerType!: string | Function; - @Option({ - name: 'ignoreCompilerErrors', - help: 'Should TypeDoc generate documentation pages even after the compiler has returned errors?', - type: ParameterType.Boolean - }) + @BindOption('ignoreCompilerErrors') ignoreCompilerErrors!: boolean; - @Option({ - name: 'exclude', - help: 'Define patterns for excluded files when specifying paths.', - type: ParameterType.Array - }) + @BindOption('exclude') exclude!: Array; - @Option({ - name: 'inputFiles', - help: 'The initial input files to expand and then pass to TS.', - type: ParameterType.Array - }) + @BindOption('inputFiles') inputFiles!: string[]; - @Option({ - name: 'options', - help: "Specify a json option file that should be loaded. If not specified TypeDoc will look for 'typedoc.json' in the current directory.", - type: ParameterType.String, - hint: ParameterHint.File, - defaultValue: process.cwd() - }) + @BindOption('options') optionsFile!: string; - @Option({ - name: 'tsconfig', - help: "Specify a typescript config file that should be loaded. If not specified TypeDoc will look for 'tsconfig.json' in the current directory.", - type: ParameterType.String, - hint: ParameterHint.File, - defaultValue: process.cwd() - }) + @BindOption('tsconfig') project!: string; /** diff --git a/src/lib/cli.ts b/src/lib/cli.ts index 2dfc8b5c5..1e48ea729 100644 --- a/src/lib/cli.ts +++ b/src/lib/cli.ts @@ -1,7 +1,7 @@ import * as typescript from 'typescript'; import { Application } from './application'; -import { Option, ParameterHint, ParameterType } from './utils/options'; +import { BindOption } from './utils/options'; import { getOptionsHelp } from './utils/options/help'; import { ArgumentsReader, TypeDocReader } from './utils/options/readers'; import { TSConfigReader } from './utils/options/readers/tsconfig'; @@ -16,34 +16,16 @@ export const enum ExitCode { } export class CliApplication extends Application { - @Option({ - name: 'out', - help: 'Specifies the location the documentation should be written to.', - hint: ParameterHint.Directory - }) + @BindOption('out') out!: string; - @Option({ - name: 'json', - help: 'Specifies the location and file name a json file describing the project is written to.', - hint: ParameterHint.File - }) + @BindOption('json') json!: string; - @Option({ - name: 'version', - short: 'v', - help: 'Print the TypeDoc\'s version.', - type: ParameterType.Boolean - }) + @BindOption('version') version!: boolean; - @Option({ - name: 'help', - short: 'h', - help: 'Print this message.', - type: ParameterType.Boolean - }) + @BindOption('help') help!: boolean; /** diff --git a/src/lib/converter/converter.ts b/src/lib/converter/converter.ts index 954beccb0..e65ca05c2 100644 --- a/src/lib/converter/converter.ts +++ b/src/lib/converter/converter.ts @@ -3,12 +3,11 @@ import * as _ts from '../ts-internal'; import * as _ from 'lodash'; import { Application } from '../application'; -import { ParameterType } from '../utils/options/declaration'; import { Reflection, Type, ProjectReflection } from '../models/index'; import { Context } from './context'; import { ConverterComponent, ConverterNodeComponent, ConverterTypeComponent, TypeTypeConverter, TypeNodeConverter } from './components'; import { Component, ChildableComponent, ComponentClass } from '../utils/component'; -import { Option } from '../utils'; +import { BindOption } from '../utils'; import { normalizePath } from '../utils/fs'; import { createMinimatch } from '../utils/paths'; @@ -35,52 +34,25 @@ export class Converter extends ChildableComponent; - @Option({ - name: 'includeDeclarations', - help: 'Turn on parsing of .d.ts declaration files.', - type: ParameterType.Boolean - }) + @BindOption('includeDeclarations') includeDeclarations!: boolean; - @Option({ - name: 'excludeExternals', - help: 'Prevent externally resolved TypeScript files from being documented.', - type: ParameterType.Boolean - }) + @BindOption('excludeExternals') excludeExternals!: boolean; - @Option({ - name: 'excludeNotExported', - help: 'Prevent symbols that are not exported from being documented.', - type: ParameterType.Boolean - }) + @BindOption('excludeNotExported') excludeNotExported!: boolean; - @Option({ - name: 'excludePrivate', - help: 'Ignores private variables and methods', - type: ParameterType.Boolean - }) + @BindOption('excludePrivate') excludePrivate!: boolean; - @Option({ - name: 'excludeProtected', - help: 'Ignores protected variables and methods', - type: ParameterType.Boolean - }) + @BindOption('excludeProtected') excludeProtected!: boolean; /** diff --git a/src/lib/converter/nodes/block.ts b/src/lib/converter/nodes/block.ts index 6f851fed8..2b1e386df 100644 --- a/src/lib/converter/nodes/block.ts +++ b/src/lib/converter/nodes/block.ts @@ -4,7 +4,7 @@ import { Reflection, ReflectionKind, ReflectionFlag } from '../../models/index'; import { createDeclaration } from '../factories/index'; import { Context } from '../context'; import { Component, ConverterNodeComponent } from '../components'; -import { Option, ParameterType } from '../../utils'; +import { BindOption } from '../../utils'; const preferred: ts.SyntaxKind[] = [ ts.SyntaxKind.ClassDeclaration, @@ -18,16 +18,7 @@ export enum SourceFileMode { @Component({name: 'node:block'}) export class BlockConverter extends ConverterNodeComponent { - @Option({ - name: 'mode', - help: "Specifies the output mode the project is used to be compiled with: 'file' or 'modules'", - type: ParameterType.Map, - map: { - 'file': SourceFileMode.File, - 'modules': SourceFileMode.Modules - }, - defaultValue: SourceFileMode.Modules - }) + @BindOption('mode') mode!: SourceFileMode; /** diff --git a/src/lib/converter/plugins/CategoryPlugin.ts b/src/lib/converter/plugins/CategoryPlugin.ts index eb3817a45..d2e4fa846 100644 --- a/src/lib/converter/plugins/CategoryPlugin.ts +++ b/src/lib/converter/plugins/CategoryPlugin.ts @@ -3,7 +3,7 @@ import { ReflectionCategory } from '../../models/ReflectionCategory'; import { Component, ConverterComponent } from '../components'; import { Converter } from '../converter'; import { Context } from '../context'; -import { ParameterType, Option } from '../../utils'; +import { BindOption } from '../../utils'; import { Comment } from '../../models/comments/index'; /** @@ -13,27 +13,13 @@ import { Comment } from '../../models/comments/index'; */ @Component({name: 'category'}) export class CategoryPlugin extends ConverterComponent { - @Option({ - name: 'defaultCategory', - help: 'Specifies the default category for reflections without a category.', - type: ParameterType.String, - defaultValue: 'Other' - }) + @BindOption('defaultCategory') defaultCategory!: string; - @Option({ - name: 'categoryOrder', - help: 'Specifies the order in which categories appear. * indicates the relative order for categories not in the list.', - type: ParameterType.Array - }) + @BindOption('categoryOrder') categoryOrder!: string[]; - @Option({ - name: 'categorizeByGroup', - help: 'Specifies whether categorization will be done at the group level.', - type: ParameterType.Boolean, - defaultValue: true - }) + @BindOption('categorizeByGroup') categorizeByGroup!: boolean; // For use in static methods diff --git a/src/lib/converter/plugins/GitHubPlugin.ts b/src/lib/converter/plugins/GitHubPlugin.ts index 09e98fe1b..813f39542 100644 --- a/src/lib/converter/plugins/GitHubPlugin.ts +++ b/src/lib/converter/plugins/GitHubPlugin.ts @@ -6,7 +6,7 @@ import { Component, ConverterComponent } from '../components'; import { BasePath } from '../utils/base-path'; import { Converter } from '../converter'; import { Context } from '../context'; -import { Option, ParameterType } from '../../utils'; +import { BindOption } from '../../utils'; /** * Stores data of a repository. @@ -28,7 +28,7 @@ export class Repository { files: string[] = []; /** - * The user/organisation name of this repository on GitHub. + * The user/organization name of this repository on GitHub. */ gitHubUser?: string; @@ -162,11 +162,7 @@ export class GitHubPlugin extends ConverterComponent { */ private ignoredPaths: string[] = []; - @Option({ - name: 'gitRevision', - help: 'Use specified revision instead of the last revision for linking to GitHub source files.', - type: ParameterType.String - }) + @BindOption('gitRevision') gitRevision!: string; /** diff --git a/src/lib/converter/plugins/PackagePlugin.ts b/src/lib/converter/plugins/PackagePlugin.ts index a4dbb66c7..d18b91ad3 100644 --- a/src/lib/converter/plugins/PackagePlugin.ts +++ b/src/lib/converter/plugins/PackagePlugin.ts @@ -6,7 +6,7 @@ import { Reflection } from '../../models/reflections/abstract'; import { Component, ConverterComponent } from '../components'; import { Converter } from '../converter'; import { Context } from '../context'; -import { Option } from '../../utils'; +import { BindOption } from '../../utils'; /** * A handler that tries to find the package.json and readme.md files of the @@ -18,10 +18,7 @@ import { Option } from '../../utils'; */ @Component({name: 'package'}) export class PackagePlugin extends ConverterComponent { - @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.' - }) + @BindOption('readme') readme!: string; /** diff --git a/src/lib/output/plugins/MarkedLinksPlugin.ts b/src/lib/output/plugins/MarkedLinksPlugin.ts index 5cd192df6..cd2307d70 100644 --- a/src/lib/output/plugins/MarkedLinksPlugin.ts +++ b/src/lib/output/plugins/MarkedLinksPlugin.ts @@ -3,7 +3,7 @@ import * as Util from 'util'; import { Reflection } from '../../models/reflections/abstract'; import { Component, ContextAwareRendererComponent } from '../components'; import { MarkdownEvent, RendererEvent } from '../events'; -import { ParameterType, Option } from '../../utils'; +import { BindOption } from '../../utils'; /** * A plugin that builds links in markdown texts. @@ -20,11 +20,7 @@ export class MarkedLinksPlugin extends ContextAwareRendererComponent { */ private inlineTag: RegExp = /(?:\[(.+?)\])?\{@(link|linkcode|linkplain)\s+((?:.|\n)+?)\}/gi; - @Option({ - name: 'listInvalidSymbolLinks', - help: 'Emits a list of broken symbol [[navigation]] links after documentation generation', - type: ParameterType.Boolean - }) + @BindOption('listInvalidSymbolLinks') listInvalidSymbolLinks!: boolean; private warnings: string[] = []; diff --git a/src/lib/output/plugins/MarkedPlugin.ts b/src/lib/output/plugins/MarkedPlugin.ts index 9f50b292b..6bcf9df26 100644 --- a/src/lib/output/plugins/MarkedPlugin.ts +++ b/src/lib/output/plugins/MarkedPlugin.ts @@ -6,7 +6,7 @@ import * as Handlebars from 'handlebars'; import { Component, ContextAwareRendererComponent } from '../components'; import { RendererEvent, MarkdownEvent } from '../events'; -import { Option, ParameterHint } from '../../utils'; +import { BindOption } from '../../utils'; const customMarkedRenderer = new Marked.Renderer(); @@ -52,18 +52,10 @@ customMarkedRenderer.heading = (text, level, _, slugger) => { */ @Component({name: 'marked'}) export class MarkedPlugin extends ContextAwareRendererComponent { - @Option({ - name: 'includes', - help: 'Specifies the location to look for included documents (use [[include:FILENAME]] in comments).', - hint: ParameterHint.Directory - }) + @BindOption('includes') includeSource!: string; - @Option({ - name: 'media', - help: 'Specifies the location with media files that should be copied to the output directory.', - hint: ParameterHint.Directory - }) + @BindOption('media') mediaSource!: string; /** @@ -104,9 +96,9 @@ export class MarkedPlugin extends ContextAwareRendererComponent { } /** - * Highlight the synatx of the given text using HighlightJS. + * Highlight the syntax of the given text using HighlightJS. * - * @param text The text taht should be highlightes. + * @param text The text that should be highlighted. * @param lang The language that should be used to highlight the string. * @return A html string with syntax highlighting. */ diff --git a/src/lib/output/renderer.ts b/src/lib/output/renderer.ts index 0d50e7107..8f1b6aafe 100644 --- a/src/lib/output/renderer.ts +++ b/src/lib/output/renderer.ts @@ -21,12 +21,12 @@ import { writeFile } from '../utils/fs'; import { DefaultTheme } from './themes/DefaultTheme'; import { RendererComponent } from './components'; import { Component, ChildableComponent } from '../utils/component'; -import { ParameterType, Option } from '../utils'; +import { BindOption } from '../utils'; /** * The renderer processes a [[ProjectReflection]] using a [[BaseTheme]] instance and writes * the emitted html documents to a output directory. You can specify which theme should be used - * using the ```--theme ``` commandline argument. + * using the ```--theme ``` command line argument. * * Subclasses of [[BasePlugin]] that have registered themselves in the [[Renderer.PLUGIN_CLASSES]] * will be automatically initialized. Most of the core functionality is provided as separate plugins. @@ -61,53 +61,25 @@ export class Renderer extends ChildableComponent */ theme?: Theme; - @Option({ - name: 'theme', - help: 'Specify the path to the theme that should be used or \'default\' or \'minimal\' to use built-in themes.', - type: ParameterType.String, - defaultValue: 'default' - }) + @BindOption('theme') themeName!: string; - @Option({ - name: 'disableOutputCheck', - help: 'Should TypeDoc disable the testing and cleaning of the output directory?', - type: ParameterType.Boolean - }) + @BindOption('disableOutputCheck') disableOutputCheck!: boolean; - @Option({ - name: 'gaID', - help: 'Set the Google Analytics tracking ID and activate tracking code.' - }) + @BindOption('gaID') gaID!: string; - @Option({ - name: 'gaSite', - help: 'Set the site name for Google Analytics. Defaults to `auto`.', - defaultValue: 'auto' - }) + @BindOption('gaSite') gaSite!: string; - @Option({ - name: 'hideGenerator', - help: 'Do not print the TypeDoc link at the end of the page.', - type: ParameterType.Boolean - }) + @BindOption('hideGenerator') hideGenerator!: boolean; - @Option({ - name: 'entryPoint', - help: 'Specifies the fully qualified name of the root symbol. Defaults to global namespace.', - type: ParameterType.String - }) + @BindOption('entryPoint') entryPoint!: string; - @Option({ - name: 'toc', - help: 'Define the contents of the top level table of contents as a comma-separated list of global symbols.', - type: ParameterType.Array - }) + @BindOption('toc') toc!: string[]; /** diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index a2edcd952..8ee093b44 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -1,4 +1,4 @@ -export { Option, Options, ParameterType, ParameterHint, ParameterScope } from './options'; +export { Option, Options, ParameterType, ParameterHint, ParameterScope, BindOption } from './options'; export { insertPrioritySorted, removeIfPresent } from './array'; export { Component, AbstractComponent, ChildableComponent } from './component'; export { Event, EventDispatcher } from './events'; diff --git a/src/lib/utils/options/index.ts b/src/lib/utils/options/index.ts index 0cdda1b29..3a7ffdccd 100644 --- a/src/lib/utils/options/index.ts +++ b/src/lib/utils/options/index.ts @@ -1,4 +1,4 @@ -export { Options, OptionsReader } from './options'; +export { Options, OptionsReader, BindOption } from './options'; export { Option } from './sources'; export { ArgumentsReader, TypeDocReader, TSConfigReader } from './readers'; export { diff --git a/src/lib/utils/options/options.ts b/src/lib/utils/options/options.ts index 80c12d11f..64184381b 100644 --- a/src/lib/utils/options/options.ts +++ b/src/lib/utils/options/options.ts @@ -1,11 +1,12 @@ import * as _ from 'lodash'; import * as ts from 'typescript'; -import { DeclarationOption, ParameterScope, convert, TypeDocOptions, KeyToDeclaration, TypeDocAndTSOptions } from './declaration'; +import { DeclarationOption, ParameterScope, convert, TypeDocOptions, KeyToDeclaration, TypeDocAndTSOptions, TypeDocOptionMap } from './declaration'; import { Logger } from '../loggers'; import { Result, Ok, Err } from '../result'; import { insertPrioritySorted } from '../array'; -import { addTSOptions, addDecoratedOptions } from './sources'; +import { addTSOptions, addTypeDocOptions } from './sources'; +import { Application } from '../../..'; /** * Describes an option reader that discovers user configuration and converts it to the @@ -96,12 +97,11 @@ export class Options { } /** - * Adds the option declarations declared by TypeDoc's `@Option` decorator - * and all supported TypeScript declarations. + * Adds the option declarations declared by the TypeDoc and all supported TypeScript declarations. */ addDefaultDeclarations() { addTSOptions(this); - addDecoratedOptions(this); + addTypeDocOptions(this); } /** @@ -321,3 +321,40 @@ export class Options { return errors.length ? Err(errors) : Ok(void 0); } } + +/** + * Binds an option to the given property. Does not register the option. + * + * @since v0.16.3 + */ +export function BindOption(name: K): + ( + target: ({ application: Application } | { options: Options }) & { [K2 in IK]: TypeDocOptions[K] }, + key: IK + ) => void; + +/** + * Binds an option to the given property. Does not register the option. + * @since v0.16.3 + * + * @privateRemarks + * This overload is intended for plugin use only with looser type checks. Do not use internally. + */ +export function BindOption(name: string): + (target: { application: Application } | { options: Options }) => void; + +export function BindOption(name: string) { + 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 + }); + }; +} diff --git a/src/lib/utils/options/sources/decorator.ts b/src/lib/utils/options/sources/decorator.ts index 76cda86b4..0a255eb2a 100644 --- a/src/lib/utils/options/sources/decorator.ts +++ b/src/lib/utils/options/sources/decorator.ts @@ -1,6 +1,6 @@ -import { DeclarationOption, TypeDocOptionMap, KeyToDeclaration } from '../declaration'; +import { DeclarationOption } from '../declaration'; import { Options } from '..'; -import { Application } from '../../../application'; +import { BindOption } from '../options'; const declared: DeclarationOption[] = []; @@ -8,35 +8,16 @@ export function addDecoratedOptions(options: Options) { options.addDeclarations(declared); } -/** - * Declares the given option and binds it to the decorated property. - * @param option - */ -export function Option(option: { name: K } & KeyToDeclaration); - /** * Declares the given option and binds it to the decorated property without strict checks. * - * @privateRemarks - * Intended for plugin use only. SHOULD NOT BE USED INTERNALLY. + * @deprecated Options should be declared on the options object. Will be removed in 0.17. * @param option */ -export function Option(option: DeclarationOption); - -export function Option(option: DeclarationOption) { +export function Option(option: DeclarationOption): PropertyDecorator { + 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 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(option.name); - } else { - return this.application.options.getValue(option.name); - } - }, - enumerable: true, - configurable: true - }); - }; + return BindOption(option.name) as any; } diff --git a/src/lib/utils/options/sources/index.ts b/src/lib/utils/options/sources/index.ts index d96bf19c8..bb350e33c 100644 --- a/src/lib/utils/options/sources/index.ts +++ b/src/lib/utils/options/sources/index.ts @@ -1,2 +1,3 @@ -export { addTSOptions } from './typescript'; export { addDecoratedOptions, Option } from './decorator'; +export { addTSOptions } from './typescript'; +export { addTypeDocOptions } from './typedoc'; diff --git a/src/lib/utils/options/sources/typedoc.ts b/src/lib/utils/options/sources/typedoc.ts new file mode 100644 index 000000000..d9afbb34a --- /dev/null +++ b/src/lib/utils/options/sources/typedoc.ts @@ -0,0 +1,189 @@ +import { Options } from '..'; +import { ParameterType, ParameterHint } from '../declaration'; +import { SourceFileMode } from '../../../..'; + +export function addTypeDocOptions(options: Options) { + options.addDeclaration({ + name: 'options', + help: "Specify a json option file that should be loaded. If not specified TypeDoc will look for 'typedoc.json' in the current directory", + hint: ParameterHint.File, + defaultValue: process.cwd() + }); + options.addDeclaration({ + name: 'tsconfig', + help: "Specify a typescript config file that should be loaded. If not specified TypeDoc will look for 'tsconfig.json' in the current directory.", + hint: ParameterHint.File, + defaultValue: process.cwd() + }); + + options.addDeclaration({ + name: 'inputFiles', + help: 'The initial input files to expand and then pass to TS.', + type: ParameterType.Array + }); + + options.addDeclaration({ + name: 'mode', + help: "Specifies the output mode the project is used to be compiled with: 'file' or 'modules'", + type: ParameterType.Map, + map: { + 'file': SourceFileMode.File, + 'modules': SourceFileMode.Modules + }, + defaultValue: SourceFileMode.Modules + }); + options.addDeclaration({ + name: 'includeDeclarations', + help: 'Turn on parsing of .d.ts declaration files.', + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'entryPoint', + help: 'Specifies the fully qualified name of the root symbol. Defaults to global namespace.', + type: ParameterType.String + }); + options.addDeclaration({ + name: 'exclude', + help: 'Define patterns for excluded files when specifying paths.', + type: ParameterType.Array + }); + options.addDeclaration({ + name: 'externalPattern', + help: 'Define patterns for files that should be considered being external.', + type: ParameterType.Array + }); + options.addDeclaration({ + name: 'excludeExternals', + help: 'Prevent externally resolved TypeScript files from being documented.', + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'excludeNotExported', + help: 'Prevent symbols that are not exported from being documented.', + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'excludePrivate', + help: 'Ignores private variables and methods', + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'excludeProtected', + help: 'Ignores protected variables and methods', + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'ignoreCompilerErrors', + help: 'Should TypeDoc generate documentation pages even after the compiler has returned errors?', + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'includes', + help: 'Specifies the location to look for included documents (use [[include:FILENAME]] in comments).', + hint: ParameterHint.Directory + }); + options.addDeclaration({ + name: 'media', + help: 'Specifies the location with media files that should be copied to the output directory.', + hint: ParameterHint.Directory + }); + + options.addDeclaration({ + name: 'out', + help: 'Specifies the location the documentation should be written to.', + hint: ParameterHint.Directory + }); + options.addDeclaration({ + name: 'json', + help: 'Specifies the location and file name a json file describing the project is written to.', + hint: ParameterHint.File + }); + + options.addDeclaration({ + name: 'theme', + help: 'Specify the path to the theme that should be used or \'default\' or \'minimal\' to use built-in themes.', + type: ParameterType.String, + defaultValue: 'default' + }); + options.addDeclaration({ + name: 'name', + help: 'Set the name of the project that will be used in the header of the template.' + }); + options.addDeclaration({ + 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.' + }); + options.addDeclaration({ + name: 'defaultCategory', + help: 'Specifies the default category for reflections without a category.', + defaultValue: 'Other' + }); + options.addDeclaration({ + name: 'categoryOrder', + help: 'Specifies the order in which categories appear. * indicates the relative order for categories not in the list.', + type: ParameterType.Array + }); + options.addDeclaration({ + name: 'categorizeByGroup', + help: 'Specifies whether categorization will be done at the group level.', + type: ParameterType.Boolean, + defaultValue: true + }); + options.addDeclaration({ + name: 'gitRevision', + help: 'Use specified revision instead of the last revision for linking to GitHub source files.' + }); + options.addDeclaration({ + name: 'gaID', + help: 'Set the Google Analytics tracking ID and activate tracking code.' + }); + options.addDeclaration({ + name: 'gaSite', + help: 'Set the site name for Google Analytics. Defaults to `auto`.', + defaultValue: 'auto' + }); + options.addDeclaration({ + name: 'hideGenerator', + help: 'Do not print the TypeDoc link at the end of the page.', + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'toc', + help: 'Define the contents of the top level table of contents as a comma-separated list of global symbols.', + type: ParameterType.Array + }); + options.addDeclaration({ + name: 'disableOutputCheck', + help: 'Should TypeDoc disable the testing and cleaning of the output directory?', + type: ParameterType.Boolean + }); + + options.addDeclaration({ + name: 'help', + short: 'h', + help: 'Print this message.', + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'version', + short: 'v', + help: "Print TypeDoc's version.", + type: ParameterType.Boolean + }); + options.addDeclaration({ + name: 'plugin', + help: 'Specify the npm plugins that should be loaded. Omit to load all installed plugins, set to \'none\' to load no plugins.', + type: ParameterType.Array + }); + options.addDeclaration({ + name: 'logger', + help: "Specify the logger that should be used, 'none' or 'console'", + defaultValue: 'console', + type: ParameterType.Mixed + }); + options.addDeclaration({ + name: 'listInvalidSymbolLinks', + help: 'Emits a list of broken symbol [[navigation]] links after documentation generation', + type: ParameterType.Boolean + }); +} diff --git a/src/lib/utils/plugins.ts b/src/lib/utils/plugins.ts index 68dc9b9a9..154a7868b 100644 --- a/src/lib/utils/plugins.ts +++ b/src/lib/utils/plugins.ts @@ -3,18 +3,14 @@ import * as Path from 'path'; import { Application } from '../application'; import { AbstractComponent, Component } from './component'; -import { ParameterType, Option } from './options'; +import { BindOption } from './options'; /** * Responsible for discovering and loading plugins. */ @Component({ name: 'plugin-host', internal: true }) export class PluginHost extends AbstractComponent { - @Option({ - name: 'plugin', - help: 'Specify the npm plugins that should be loaded. Omit to load all installed plugins, set to \'none\' to load no plugins.', - type: ParameterType.Array - }) + @BindOption('plugin') plugins!: string[]; /** diff --git a/src/test/renderer/specs/classes/_mixin_.base.html b/src/test/renderer/specs/classes/_mixin_.base.html index b70a9d3f3..fc76da6bd 100644 --- a/src/test/renderer/specs/classes/_mixin_.base.html +++ b/src/test/renderer/specs/classes/_mixin_.base.html @@ -111,7 +111,7 @@

baseProperty

baseProperty: string = "init"
@@ -128,7 +128,7 @@

baseMethod

  • Returns number

    diff --git a/src/test/renderer/specs/classes/_mixin_.someclasswithmixin.html b/src/test/renderer/specs/classes/_mixin_.someclasswithmixin.html index 07e9ddcd0..fb57a552f 100644 --- a/src/test/renderer/specs/classes/_mixin_.someclasswithmixin.html +++ b/src/test/renderer/specs/classes/_mixin_.someclasswithmixin.html @@ -124,7 +124,7 @@

    baseProperty

    Inherited from Base.baseProperty

    Overrides Base.baseProperty

    @@ -134,7 +134,7 @@

    classWithMixinProperty

    classWithMixinProperty: string = "init"
    @@ -146,7 +146,7 @@

    property1

    Inherited from Mixin1Type.property1

    Overrides Mixin1Type.property1

    @@ -157,7 +157,7 @@

    property2

    @@ -176,7 +176,7 @@

    baseMethod

    Inherited from Base.baseMethod

    Overrides Base.baseMethod

    Returns number

    @@ -193,7 +193,7 @@

    classWithMixinMethod

  • Returns string

    @@ -212,7 +212,7 @@

    method1

    Inherited from Mixin1Type.method1

    Overrides Mixin1Type.method1

    Parameters

    @@ -236,7 +236,7 @@

    method2

    Parameters

    diff --git a/src/test/renderer/specs/interfaces/_mixin_.mixin1type.html b/src/test/renderer/specs/interfaces/_mixin_.mixin1type.html index 3877cceed..83112889e 100644 --- a/src/test/renderer/specs/interfaces/_mixin_.mixin1type.html +++ b/src/test/renderer/specs/interfaces/_mixin_.mixin1type.html @@ -120,7 +120,7 @@

    baseProperty

    Inherited from Base.baseProperty

    Overrides Base.baseProperty

    @@ -131,7 +131,7 @@

    property1

    @@ -150,7 +150,7 @@

    baseMethod

    Inherited from Base.baseMethod

    Overrides Base.baseMethod

    Returns number

    @@ -168,7 +168,7 @@

    method1

    Parameters

    diff --git a/src/test/renderer/specs/interfaces/_mixin_.mixin2.html b/src/test/renderer/specs/interfaces/_mixin_.mixin2.html index 376ce372f..703dead64 100644 --- a/src/test/renderer/specs/interfaces/_mixin_.mixin2.html +++ b/src/test/renderer/specs/interfaces/_mixin_.mixin2.html @@ -122,7 +122,7 @@

    baseProperty

    Inherited from Base.baseProperty

    Overrides Base.baseProperty

    @@ -134,7 +134,7 @@

    property1

    Inherited from Mixin1Type.property1

    Overrides Mixin1Type.property1

    @@ -145,7 +145,7 @@

    property2

    @@ -164,7 +164,7 @@

    baseMethod

    Inherited from Base.baseMethod

    Overrides Base.baseMethod

    Returns number

    @@ -183,7 +183,7 @@

    method1

    Inherited from Mixin1Type.method1

    Overrides Mixin1Type.method1

    Parameters

    @@ -207,7 +207,7 @@

    method2

    Parameters

    diff --git a/src/test/renderer/specs/modules/_mixin_.html b/src/test/renderer/specs/modules/_mixin_.html index a95f9964f..74b2cd6dd 100644 --- a/src/test/renderer/specs/modules/_mixin_.html +++ b/src/test/renderer/specs/modules/_mixin_.html @@ -112,7 +112,7 @@

    AnyConstructor

    AnyConstructor<A>:
    @@ -138,7 +138,7 @@

    AnyFunction

    AnyFunction<A>: (...input: any[]) => A
    @@ -180,7 +180,7 @@

    Mixin

    Mixin<T>: InstanceType<ReturnType<T>>
    @@ -201,7 +201,7 @@

    Mixin3

    Mixin3: Mixin<Mixin3>
    @@ -224,7 +224,7 @@

    Const Mixin1Func

  • @@ -258,7 +258,7 @@

    Const Mixin2

  • @@ -292,7 +292,7 @@

    Const Mixin3