Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Options

Maintains a collection of option declarations split into TypeDoc options and TypeScript options. Ensures options are of the correct type for calling code.

Option Discovery

Since plugins commonly add custom options, and TypeDoc does not permit options which have not been declared to be set, options must be read twice. The first time options are read, a noop logger is passed so that any errors are ignored. Then, after loading plugins, options are read again, this time with the logger specified by the application.

Options are read in a specific order.

  1. argv (0) - Must be read first since it should change the files read when passing --options or --tsconfig.
  2. typedoc-json (100) - Read next so that it can specify the tsconfig.json file to read.
  3. tsconfig-json (200) - Last config file reader, cannot specify the typedoc.json file to read.
  4. argv (300) - Read argv again since any options set there should override those set in config files.

Hierarchy

  • Options

Index

Constructors

constructor

  • new Options(logger: Logger): Options
  • Parameters

    • logger: Logger

    Returns Options

Properties

Private _compilerOptions

_compilerOptions: any

Private _declarations

_declarations: any

Private _fileNames

_fileNames: any

Private _logger

_logger: any

Private _projectReferences

_projectReferences: any

Private _readers

_readers: any

Private _setOptions

_setOptions: any

Private _values

_values: any

Methods

addDeclaration

  • Adds an option declaration to the container with extra type checking to ensure that the runtime type is consistent with the declared type.

    Type parameters

    Parameters

    • declaration: { name: K } & KeyToDeclaration<K>

      The option declaration that should be added.

    Returns void

  • Adds an option declaration to the container.

    Parameters

    • declaration: Readonly<DeclarationOption>

      The option declaration that should be added.

    Returns void

addDeclarations

  • Adds the given declarations to the container

    privateremarks

    This function explicitly provides a way out of the strict typing enforced by addDeclaration. It should only be used with careful validation of the declaration map. Internally, it is only used for adding TS options

    Parameters

    Returns void

addDefaultDeclarations

  • addDefaultDeclarations(): void
  • Adds the option declarations declared by the TypeDoc and all supported TypeScript declarations.

    Returns void

addReader

  • Adds an option reader that will be used to read configuration values from the command line, configuration files, or other locations.

    Parameters

    Returns void

freeze

  • freeze(): void
  • Marks the options as readonly, enables caching when fetching options, which improves performance.

    Returns void

getCompilerOptions

  • Gets the set compiler options.

    Returns Readonly<CompilerOptions>

getDeclaration

  • Gets a declaration by one of its names.

    Parameters

    • name: string

    Returns Readonly<DeclarationOption>

getDeclarations

  • Gets all declared options.

    Returns Readonly<DeclarationOption>[]

getFileNames

  • getFileNames(): readonly string[]
  • Gets the file names discovered through reading a tsconfig file.

    Returns readonly string[]

getProjectReferences

  • Gets the project references - used in solution style tsconfig setups.

    Returns readonly ProjectReference[]

getRawValues

  • Gets all of the TypeDoc option values defined in this option container.

    Returns Readonly<Partial<TypeDocOptions>>

getValue

  • getValue<K>(name: K): TypeDocOptionValues[K]
  • getValue(name: string): unknown
  • Gets a value for the given option key, throwing if the option has not been declared.

    Type parameters

    Parameters

    • name: K

    Returns TypeDocOptionValues[K]

  • Parameters

    • name: string

    Returns unknown

isFrozen

  • isFrozen(): boolean
  • Checks if the options object has been frozen, preventing future changes to option values.

    Returns boolean

isSet

  • Checks if the given option's value is deeply strict equal to the default.

    Parameters

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

read

  • read(logger: Logger): void
  • Parameters

    • logger: Logger

    Returns void

removeDeclarationByName

  • removeDeclarationByName(name: string): void
  • Removes a declared option. WARNING: This is probably a bad idea. If you do this you will probably cause a crash when code assumes that an option that it declared still exists.

    Parameters

    • name: string

    Returns void

removeReaderByName

  • removeReaderByName(name: string): void
  • Removes all readers of a given name.

    Parameters

    • name: string

    Returns void

reset

  • reset(): void
  • Resets the option bag to all default values.

    Returns void

setCompilerOptions

  • Sets the compiler options that will be used to get a TS program.

    Parameters

    Returns void

setLogger

  • setLogger(logger: Logger): void
  • Sets the logger used when an option declaration fails to be added.

    Parameters

    • logger: Logger

    Returns void

setValue

  • setValue<K>(name: K, value: TypeDocOptions[K], configPath?: string): void
  • setValue(name: string, value: unknown, configPath?: string): void
  • Sets the given declared option. Throws if setting the option fails.

    Type parameters

    Parameters

    • name: K
    • value: TypeDocOptions[K]
    • Optional configPath: string

      the directory to resolve Path type values against

    Returns void

  • Parameters

    • name: string
    • value: unknown
    • Optional configPath: string

    Returns void

Generated using TypeDoc