or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

application.mdconfiguration.mdconverter.mdindex.mdinternationalization.mdmodels.mdoutput.mdserialization.md
tile.json

tessl/npm-typedoc

Create api documentation for TypeScript projects.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/typedoc@0.28.x

To install, run

npx @tessl/cli install tessl/npm-typedoc@0.28.0

index.mddocs/

TypeDoc

TypeDoc is a comprehensive documentation generator specifically designed for TypeScript projects that automatically creates API documentation from TypeScript source code and JSDoc comments. It provides extensive customization options including multiple output formats, configurable themes, support for monorepos and workspaces, and deep integration with TypeScript's type system to generate rich, navigable documentation.

Package Information

  • Package Name: typedoc
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install typedoc
  • Peer Dependencies: typescript (5.0.x - 5.9.x)

Core Imports

import { Application } from "typedoc";

For CommonJS:

const { Application } = require("typedoc");

Entry Point Exports

// Main entry point
import { Application, Models, Configuration } from "typedoc";

// Browser-compatible subset
import * as TypeDocBrowser from "typedoc/browser";

// Model types only
import * as Models from "typedoc/models";

// Debug utilities (unstable API)
import { debugReflectionLifetimes, debugRendererUrls } from "typedoc/debug";

Basic Usage

import { Application } from "typedoc";

// Create TypeDoc application
const app = await Application.bootstrapWithPlugins({
  entryPoints: ["src/index.ts"],
  out: "docs",
  theme: "default",
});

// Convert TypeScript project to documentation
const project = await app.convert();

if (project) {
  // Generate HTML documentation
  await app.generateDocs(project, "docs");
  
  // Or generate JSON output
  await app.generateJson(project, "docs/api.json");
}

CLI Usage

TypeDoc provides a comprehensive command-line interface:

# Basic documentation generation
typedoc src/index.ts

# With custom output directory and theme
typedoc --out docs --theme default src/

# Generate JSON output
typedoc --json docs/api.json src/

# Watch mode for development
typedoc --watch src/

Architecture

TypeDoc is built around several key components:

  • Application: Core orchestrator managing the entire documentation generation process
  • Converter: Transforms TypeScript source code and symbols into reflection objects
  • Models: Rich object model representing all documentation elements (reflections, types, comments)
  • Output System: Renders documentation from reflections to various formats (HTML, JSON)
  • Configuration: Comprehensive options system supporting multiple configuration sources
  • Serialization: Converts reflections to/from JSON for storage and processing
  • Internationalization: Multi-language support for documentation output

Capabilities

Application Management

Core application orchestration for TypeDoc documentation generation, including bootstrapping, plugin loading, and conversion coordination.

class Application extends AbstractComponent<Application, ApplicationEvents> {
  readonly options: Options;
  readonly converter: Converter;
  readonly renderer: Renderer;
  readonly serializer: Serializer;
  readonly internationalization: Internationalization;
  readonly logger: Logger;

  static bootstrap(options?: Partial<TypeDocOptions>): Promise<Application>;
  static bootstrapWithPlugins(
    options: Partial<TypeDocOptions>,
    readers: OptionsReader[]
  ): Promise<Application>;
  
  convert(): Promise<ProjectReflection | undefined>;
  convertAndWatch(success: (project: ProjectReflection) => Promise<void>): Promise<never>;
  generateDocs(project: ProjectReflection, out: string): Promise<void>;
  generateJson(project: ProjectReflection, out: string): Promise<void>;
  validate(project: ProjectReflection): void;
}

Application Management

Documentation Models

Complete object model representing TypeScript documentation elements including reflections, types, comments, and source references.

// Core reflection types
abstract class Reflection {
  readonly id: ReflectionId;
  readonly name: string;
  readonly kind: ReflectionKind;
  readonly flags: ReflectionFlag;
  comment?: Comment;
  readonly parent?: Reflection;
}

class ProjectReflection extends ContainerReflection {
  readonly packageVersion?: string;
  readonly readme?: string;
  readonly changelog?: string;
}

class DeclarationReflection extends ContainerReflection {
  type?: Type;
  defaultValue?: string;
  overwrites?: ReferenceType;
  inheritedFrom?: ReferenceType;
  implementationOf?: ReferenceType;
  extendedTypes?: Type[];
  extendedBy?: ReferenceType[];
  implementedTypes?: Type[];
  implementedBy?: ReferenceType[];
}

// Type system
abstract class Type {
  abstract readonly type: keyof TypeKindMap;
  toString(): string;
  visit<T>(visitor: TypeVisitor<T>): T;
}

Documentation Models

TypeScript Conversion

Converter system that transforms TypeScript source code, symbols, and AST nodes into TypeDoc's reflection model.

class Converter extends AbstractComponent<Application, ConverterEvents> {
  convert(entryPoints: readonly DocumentationEntryPoint[]): ProjectReflection | undefined;
  convertSymbol(context: Context, symbol: ts.Symbol): Reflection | undefined;
}

class Context {
  readonly program: ts.Program;
  readonly project: ProjectReflection;
  readonly scope: Reflection;
  
  createDeclarationReflection(
    kind: ReflectionKind,
    symbol?: ts.Symbol,
    exportSymbol?: ts.Symbol,
    name?: string
  ): DeclarationReflection;
  
  finalizeDeclarationReflection(reflection: DeclarationReflection): void;
}

TypeScript Conversion

Configuration System

Comprehensive configuration management supporting multiple option sources, type-safe declarations, and validation.

class Options extends EventDispatcher<OptionsEvents, EventsWithArgument> {
  addDeclaration(declaration: DeclarationOption): void;
  getValue<K extends keyof TypeDocOptions>(name: K): TypeDocOptions[K];
  setValue<K extends keyof TypeDocOptions>(name: K, value: TypeDocOptions[K]): void;
  isSet(name: keyof TypeDocOptions): boolean;
  read(logger: Logger): void;
}

// Option readers
class ArgumentsReader implements OptionsReader {
  constructor(priority: number);
  read(container: Options, logger: Logger, cwd: string): void;
}

class TypeDocReader implements OptionsReader {
  read(container: Options, logger: Logger, cwd: string): void;
}

class TSConfigReader implements OptionsReader {
  read(container: Options, logger: Logger, cwd: string): void;
}

Configuration System

Output and Rendering

Output generation system including themes, renderers, routing, and multiple output formats with extensive customization options.

class Renderer extends AbstractComponent<Application, RendererEvents> {
  render(project: ProjectReflection, outputDirectory: string): Promise<void>;
  renderDocument(page: PageEvent<Reflection>): string;
}

abstract class Theme {
  abstract render(page: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>): string;
  abstract getUrls(project: ProjectReflection): UrlMapping[];
  abstract getNavigation(project: ProjectReflection): NavigationElement;
}

class DefaultTheme extends Theme {
  render(page: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>): string;
  getUrls(project: ProjectReflection): UrlMapping[];
  getNavigation(project: ProjectReflection): NavigationElement;
}

Output and Rendering

JSON Serialization

Serialization system for converting reflections to/from JSON format, enabling data exchange and custom processing workflows.

class Serializer extends AbstractComponent<Application, SerializerEvents> {
  projectToObject(project: ProjectReflection, out: string): JSONOutput.ProjectReflection;
  toObject(value: unknown): unknown;
}

class Deserializer {
  reviveProject(project: JSONOutput.ProjectReflection, name?: string): ProjectReflection;
  revive<T>(obj: any, root: T): T;
}

namespace JSONOutput {
  interface ProjectReflection extends Reflection {
    packageVersion?: string;
    readme?: string;
    changelog?: string;
    children?: DeclarationReflection[];
    groups?: ReflectionGroup[];
    categories?: ReflectionCategory[];
  }
}

JSON Serialization

Internationalization

Multi-language support system for localizing TypeDoc's output interface and messages.

class Internationalization {
  setLocale(locale: string): void;
  resetLocale(): void;
  addTranslations(locale: string, translations: Partial<TranslatableStrings>): void;
  proxy(): TranslationProxy;
}

function i18n(key: TranslatedString, ...args: any[]): string;

interface TranslatableStrings {
  theme_implements: string;
  theme_indexable: string;
  theme_type_declaration: string;
  theme_constructor: string;
  theme_property: string;
  theme_method: string;
  theme_call_signature: string;
  // ... many more translation keys
}

Internationalization

Core Types

Application Events

interface ApplicationEvents {
  BOOTSTRAP_END: [Application];
  REVIVE: [ProjectReflection, JSONOutput.ProjectReflection];
}

Reflection Enums

enum ReflectionKind {
  Project = 0x1,
  Module = 0x2,
  Namespace = 0x4,
  Enum = 0x8,
  EnumMember = 0x10,
  Variable = 0x20,
  Function = 0x40,
  Class = 0x80,
  Interface = 0x100,
  Constructor = 0x200,
  Property = 0x400,
  Method = 0x800,
  CallSignature = 0x1000,
  IndexSignature = 0x2000,
  ConstructorSignature = 0x4000,
  Parameter = 0x8000,
  TypeLiteral = 0x10000,
  TypeParameter = 0x20000,
  Accessor = 0x40000,
  GetSignature = 0x80000,
  SetSignature = 0x100000,
  ObjectLiteral = 0x200000,
  TypeAlias = 0x400000,
  Reference = 0x800000,
  Document = 0x1000000,
}

enum ReflectionFlag {
  None = 0,
  Private = 1,
  Protected = 2,
  Public = 4,
  Static = 8,
  External = 16,
  Optional = 32,
  Rest = 64,
  Abstract = 128,
  Const = 256,
  Readonly = 512,
  Inherited = 1024,
}

Configuration Enums

enum ParameterType {
  String = "string",
  Number = "number",
  Boolean = "boolean",
  Map = "map",
  Mixed = "mixed",
  Array = "array",
  PathArray = "pathArray",
  ModuleArray = "moduleArray",
  GlobArray = "globArray",
  Object = "object",
  Flags = "flags",
  Path = "path",
  Module = "module",
  Glob = "glob",
}

enum CommentStyle {
  JSDoc = "jsdoc",
  Block = "block", 
  Line = "line",
  All = "all",
}

enum EntryPointStrategy {
  Resolve = "resolve",
  Expand = "expand",
  Packages = "packages",
  Merge = "merge",
}

Utility Types

type GlobString = string & { __globBrand: never };
type NormalizedPath = string & { __normalizedPathBrand: never };
type TranslatedString = string & { __translatedBrand: never };

interface MinimalSourceFile {
  fileName: string;
  text: string;
}

interface ComponentPath {
  path: string;
  last?: boolean;
}