Skip to content

Commit

Permalink
Migrate to ES decorators, fix deprecated strikethrough
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Sep 3, 2023
1 parent aefeac0 commit bba61bc
Show file tree
Hide file tree
Showing 27 changed files with 206 additions and 139 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Bug Fixes

- `@property` now works as expected if used to override a method's documentation.
- Deprecated functions/methods are now correctly rendered with a struck-out name.
- `--watch` mode works again, #2378.
- Improved support for optional names within JSDoc types, #2384.
- Fixed duplicate rendering of reflection flags on signature parameters, #2385.
Expand Down
6 changes: 3 additions & 3 deletions internal-docs/components-and-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Components are slowly being removed from TypeDoc.
`isPropagationStopped`
`isDefaultPrevented`

## `@BindOption`
## `@Option`

`@BindOption` decorator can be placed on any class which has `application` or `options` fields.
It turns the field into a getter which gets the value from `this.options` or `this.application.options`
`@Option` decorator can be placed on any class which has `application` or `options` accessor.
It turns the accessor into a getter which gets the value from `this.options` or `this.application.options`
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type { RenderTemplate, RendererHooks } from "./lib/output";

export {
ArgumentsReader,
Option,
BindOption,
CommentStyle,
JSX,
Expand Down
14 changes: 7 additions & 7 deletions src/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
ChildableComponent,
Component,
} from "./utils/component";
import { Options, BindOption } from "./utils";
import { Options, Option } from "./utils";
import type { TypeDocOptions } from "./utils/options/declaration";
import { unique } from "./utils/array";
import { ok } from "assert";
Expand Down Expand Up @@ -111,16 +111,16 @@ export class Application extends ChildableComponent<
options = new Options();

/** @internal */
@BindOption("skipErrorChecking")
readonly skipErrorChecking!: boolean;
@Option("skipErrorChecking")
accessor skipErrorChecking!: boolean;

/** @internal */
@BindOption("entryPointStrategy")
readonly entryPointStrategy!: EntryPointStrategy;
@Option("entryPointStrategy")
accessor entryPointStrategy!: EntryPointStrategy;

/** @internal */
@BindOption("entryPoints")
readonly entryPoints!: string[];
@Option("entryPoints")
accessor entryPoints!: string[];

/**
* The version number of TypeDoc.
Expand Down
49 changes: 26 additions & 23 deletions src/lib/converter/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { Context } from "./context";
import { ConverterComponent } from "./components";
import { Component, ChildableComponent } from "../utils/component";
import { BindOption, MinimalSourceFile, readFile } from "../utils";
import { Option, MinimalSourceFile, readFile } from "../utils";
import { convertType } from "./types";
import { ConverterEvents } from "./converter-events";
import { convertSymbol } from "./symbols";
Expand Down Expand Up @@ -49,50 +49,53 @@ export class Converter extends ChildableComponent<
ConverterComponent
> {
/** @internal */
@BindOption("externalPattern")
externalPattern!: string[];
@Option("externalPattern")
accessor externalPattern!: string[];
private externalPatternCache?: Minimatch[];
private excludeCache?: Minimatch[];

/** @internal */
@BindOption("excludeExternals")
excludeExternals!: boolean;
@Option("excludeExternals")
accessor excludeExternals!: boolean;

/** @internal */
@BindOption("excludeNotDocumented")
excludeNotDocumented!: boolean;
@Option("excludeNotDocumented")
accessor excludeNotDocumented!: boolean;

/** @internal */
@BindOption("excludePrivate")
excludePrivate!: boolean;
@Option("excludePrivate")
accessor excludePrivate!: boolean;

/** @internal */
@BindOption("excludeProtected")
excludeProtected!: boolean;
@Option("excludeProtected")
accessor excludeProtected!: boolean;

/** @internal */
@BindOption("excludeReferences")
excludeReferences!: boolean;
@Option("excludeReferences")
accessor excludeReferences!: boolean;

/** @internal */
@BindOption("commentStyle")
commentStyle!: CommentStyle;
@Option("commentStyle")
accessor commentStyle!: CommentStyle;

/** @internal */
@BindOption("validation")
validation!: ValidationOptions;
@Option("validation")
accessor validation!: ValidationOptions;

/** @internal */
@BindOption("externalSymbolLinkMappings")
externalSymbolLinkMappings!: Record<string, Record<string, string>>;
@Option("externalSymbolLinkMappings")
accessor externalSymbolLinkMappings!: Record<
string,
Record<string, string>
>;

/** @internal */
@BindOption("useTsLinkResolution")
useTsLinkResolution!: boolean;
@Option("useTsLinkResolution")
accessor useTsLinkResolution!: boolean;

/** @internal */
@BindOption("preserveLinkText")
preserveLinkText!: boolean;
@Option("preserveLinkText")
accessor preserveLinkText!: boolean;

private _config?: CommentParserConfig;
private _externalSymbolResolvers: Array<ExternalSymbolResolver> = [];
Expand Down
18 changes: 9 additions & 9 deletions src/lib/converter/plugins/CategoryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ReflectionCategory } from "../../models";
import { Component, ConverterComponent } from "../components";
import { Converter } from "../converter";
import type { Context } from "../context";
import { BindOption, getSortFunction, removeIf } from "../../utils";
import { Option, getSortFunction, removeIf } from "../../utils";

/**
* A handler that sorts and categorizes the found reflections in the resolving phase.
Expand All @@ -19,17 +19,17 @@ import { BindOption, getSortFunction, removeIf } from "../../utils";
export class CategoryPlugin extends ConverterComponent {
sortFunction!: (reflections: DeclarationReflection[]) => void;

@BindOption("defaultCategory")
defaultCategory!: string;
@Option("defaultCategory")
accessor defaultCategory!: string;

@BindOption("categoryOrder")
categoryOrder!: string[];
@Option("categoryOrder")
accessor categoryOrder!: string[];

@BindOption("categorizeByGroup")
categorizeByGroup!: boolean;
@Option("categorizeByGroup")
accessor categorizeByGroup!: boolean;

@BindOption("searchCategoryBoosts")
boosts!: Record<string, number>;
@Option("searchCategoryBoosts")
accessor boosts!: Record<string, number>;

usedBoosts = new Set<string>();

Expand Down
22 changes: 11 additions & 11 deletions src/lib/converter/plugins/CommentPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
CommentTag,
} from "../../models";
import {
BindOption,
Option,
filterMap,
removeIfPresent,
unique,
Expand Down Expand Up @@ -103,20 +103,20 @@ const NEVER_RENDERED = [
*/
@Component({ name: "comment" })
export class CommentPlugin extends ConverterComponent {
@BindOption("excludeTags")
excludeTags!: `@${string}`[];
@Option("excludeTags")
accessor excludeTags!: `@${string}`[];

@BindOption("excludeInternal")
excludeInternal!: boolean;
@Option("excludeInternal")
accessor excludeInternal!: boolean;

@BindOption("excludePrivate")
excludePrivate!: boolean;
@Option("excludePrivate")
accessor excludePrivate!: boolean;

@BindOption("excludeProtected")
excludeProtected!: boolean;
@Option("excludeProtected")
accessor excludeProtected!: boolean;

@BindOption("excludeNotDocumented")
excludeNotDocumented!: boolean;
@Option("excludeNotDocumented")
accessor excludeNotDocumented!: boolean;

private _excludeKinds: number | undefined;
private get excludeNotDocumentedKinds(): number {
Expand Down
10 changes: 5 additions & 5 deletions src/lib/converter/plugins/GroupPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Component, ConverterComponent } from "../components";
import { Converter } from "../converter";
import type { Context } from "../context";
import { getSortFunction } from "../../utils/sort";
import { BindOption, removeIf } from "../../utils";
import { Option, removeIf } from "../../utils";
import { Comment } from "../../models";

/**
Expand All @@ -21,11 +21,11 @@ import { Comment } from "../../models";
export class GroupPlugin extends ConverterComponent {
sortFunction!: (reflections: DeclarationReflection[]) => void;

@BindOption("searchGroupBoosts")
boosts!: Record<string, number>;
@Option("searchGroupBoosts")
accessor boosts!: Record<string, number>;

@BindOption("groupOrder")
groupOrder!: string[];
@Option("groupOrder")
accessor groupOrder!: string[];

usedBoosts = new Set<string>();

Expand Down
6 changes: 3 additions & 3 deletions src/lib/converter/plugins/InheritDocPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Component, ConverterComponent } from "../components";
import { Converter } from "../converter";
import type { Context } from "../context";
import type { Reflection } from "../../models/reflections/abstract";
import { BindOption, DefaultMap, ValidationOptions } from "../../utils";
import { Option, DefaultMap, ValidationOptions } from "../../utils";
import { zip } from "../../utils/array";
import { parseDeclarationReference } from "../comments/declarationReference";
import { resolveDeclarationReference } from "../comments/declarationReferenceResolver";
Expand All @@ -31,8 +31,8 @@ import { ApplicationEvents } from "../../application-events";
*/
@Component({ name: "inheritDoc" })
export class InheritDocPlugin extends ConverterComponent {
@BindOption("validation")
validation!: ValidationOptions;
@Option("validation")
accessor validation!: ValidationOptions;

// Key is depended on by Values
private dependencies = new DefaultMap<Reflection, Reflection[]>(() => []);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/converter/plugins/LinkResolverPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, ConverterComponent } from "../components";
import type { Context, ExternalResolveResult } from "../../converter";
import { ConverterEvents } from "../converter-events";
import { BindOption, ValidationOptions } from "../../utils";
import { Option, ValidationOptions } from "../../utils";
import { DeclarationReflection, ProjectReflection } from "../../models";
import { discoverAllReferenceTypes } from "../../utils/reflections";
import { ApplicationEvents } from "../../application-events";
Expand All @@ -11,8 +11,8 @@ import { ApplicationEvents } from "../../application-events";
*/
@Component({ name: "link-resolver" })
export class LinkResolverPlugin extends ConverterComponent {
@BindOption("validation")
validation!: ValidationOptions;
@Option("validation")
accessor validation!: ValidationOptions;

override initialize() {
super.initialize();
Expand Down
18 changes: 9 additions & 9 deletions src/lib/converter/plugins/PackagePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as Path from "path";
import { Component, ConverterComponent } from "../components";
import { Converter } from "../converter";
import type { Context } from "../context";
import { BindOption, EntryPointStrategy, readFile } from "../../utils";
import { Option, EntryPointStrategy, readFile } from "../../utils";
import {
deriveRootDir,
discoverInParentDir,
Expand All @@ -21,17 +21,17 @@ import { join } from "path";
*/
@Component({ name: "package" })
export class PackagePlugin extends ConverterComponent {
@BindOption("readme")
readme!: string;
@Option("readme")
accessor readme!: string;

@BindOption("entryPointStrategy")
entryPointStrategy!: EntryPointStrategy;
@Option("entryPointStrategy")
accessor entryPointStrategy!: EntryPointStrategy;

@BindOption("entryPoints")
entryPoints!: string[];
@Option("entryPoints")
accessor entryPoints!: string[];

@BindOption("includeVersion")
includeVersion!: boolean;
@Option("includeVersion")
accessor includeVersion!: boolean;

/**
* The file name of the found readme.md file.
Expand Down
26 changes: 13 additions & 13 deletions src/lib/converter/plugins/SourcePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Component, ConverterComponent } from "../components";
import { Converter } from "../converter";
import type { Context } from "../context";
import { BindOption, normalizePath, getCommonDirectory } from "../../utils";
import { Option, normalizePath, getCommonDirectory } from "../../utils";
import { isNamedNode } from "../utils/nodes";
import { dirname, relative } from "path";
import { SourceReference } from "../../models";
Expand All @@ -24,23 +24,23 @@ import { BasePath } from "../utils/base-path";
*/
@Component({ name: "source" })
export class SourcePlugin extends ConverterComponent {
@BindOption("disableSources")
readonly disableSources!: boolean;
@Option("disableSources")
accessor disableSources!: boolean;

@BindOption("gitRevision")
readonly gitRevision!: string;
@Option("gitRevision")
accessor gitRevision!: string;

@BindOption("gitRemote")
readonly gitRemote!: string;
@Option("gitRemote")
accessor gitRemote!: string;

@BindOption("disableGit")
readonly disableGit!: boolean;
@Option("disableGit")
accessor disableGit!: boolean;

@BindOption("sourceLinkTemplate")
readonly sourceLinkTemplate!: string;
@Option("sourceLinkTemplate")
accessor sourceLinkTemplate!: string;

@BindOption("basePath")
readonly basePath!: string;
@Option("basePath")
accessor basePath!: string;

/**
* All file names to find the base path from.
Expand Down

0 comments on commit bba61bc

Please sign in to comment.