Skip to main content

Page Templates


docsgen uses React components as page templates for each kind of TypeScript symbol. Each template is composed of reusable section components that you can toggle, replace, or fully override.


Built-in Templates

ClassPage

Used for TypeScript classes. Sections: mdx, intro, parameters, properties, methods, usage.

The intro section shows the class name, description, source location, import statement, type definition, and npm install command. Parameters shows constructor parameters. Properties and Methods list class members. Usage renders @example JSDoc blocks.

ComponentPage

Used for React components (auto-detected by return type). Sections: mdx, intro, usage, properties.

The properties section renders both a compact table overview and detailed per-prop documentation, making it ideal for component API reference.

FunctionPage

Used for standalone functions. Sections: mdx, intro, usage, parameters, returns.

Shows function signature, parameters table, and return type documentation.

EnumPage

Used for TypeScript enums. Sections: mdx, intro, preview.

The preview section shows all enum members and their values.

TypePage

Used for type aliases. Sections: mdx, intro, preview, returns.

Preview shows the type definition. Returns shows the structure for complex types.

VarPage

Used for exported variables and constants. Sections: mdx, intro, preview, returns.

Same structure as TypePage.

DefaultPage

Fallback for any reflection kind not covered above. Sections: mdx, intro.


Section Components

Each section is built from smaller components that can be used independently (including via the @import directive):

ComponentDescription
NameSymbol name as a heading.
DescriptionJSDoc description text.
SourcesSource file location link.
ImportImport statement code block.
DefinitionFull type/class definition.
Npmnpm install command.
PreviewCompact type preview.
ParametersParameter table and details. Supports display="table" or display="block".
PropertiesObject/interface property documentation.
MethodsClass method documentation.
ReturnsReturn type documentation.
ReturnsPreviewCompact return type preview.
Examples@example JSDoc content.
GenericsGeneric type parameter documentation.
SignatureFunction/method signature.

Customizing Templates

Toggle Sections

Disable a section by setting it to false in the pages configuration:

{
pages: {
class: {
methods: false,
usage: false,
},
},
}

Replace a Section

Pass a function that receives PagePropsType and returns a React node:

{
pages: {
function: {
intro: (props) => {
return (
<>
<h1>{props.reflection.name}</h1>
<p>Custom intro content</p>
</>
);
},
},
},
}

Full Page Override

Use the custom key to replace the entire template:

{
pages: {
class: {
custom: (props) => {
const { reflection, packageOptions, pluginOptions } = props;
return (
<div>
<h1>{reflection.name}</h1>
<pre>{JSON.stringify(reflection, null, 2)}</pre>
</div>
);
},
},
},
}

When custom is provided, all other section options are ignored.


PagePropsType

Every page template and section component receives PagePropsType, which includes:

PropertyTypeDescription
reflectionJSONOutput.SomeReflectionThe TypeDoc reflection data for this symbol.
pluginOptionsPluginOptionsGlobal plugin configuration.
packageOptionsPackageOptionsPackage-level configuration for this symbol's package.
reflectionsTreeProjectReflection[]Full reflection trees for all packages (for cross-referencing).
npmNamestringnpm package name.
packageNamestringCleaned package title.
Summary

docsgen provides seven built-in page templates covering classes, components, functions, enums, types, variables, and a default fallback. Each template is composed of toggleable section components. Use the pages configuration to disable sections, replace them with custom renderers, or override entire pages.