API
MarkdownThemeContext

MarkdownThemeContext

The theme context class that is provided as context on the rendering of every page.

It is heavily influenced by the equivalent DefaultThemeRenderContext from the default theme.

This class can be used to customize the theme output by extending the class and overriding the templates, partials and helpers.

Constructors

new MarkdownThemeContext()

new MarkdownThemeContext(theme, page, options): MarkdownThemeContext

Parameters

ParameterTypeDescription
themeMarkdownThemeThe theme instance.
pageMarkdownPageEvent<Reflection>The current page event.
optionsOptionsThe options provided to the application.

Returns

MarkdownThemeContext

Methods

General context aware helper methods not bound to any specific models that can be used by the theme resources.

getRelativeUrl()

getRelativeUrl(url, ignorePublicPath): string

Returns the relative URL (from the current page context url).

If public path is set, it will be used as the base URL.

Parameters

ParameterTypeDescription
urlstringThe URL to make relative.
ignorePublicPathbooleanWhether to ignore the public path.

Returns

string

Properties

Properties are passed into the constructor and are used to provide context to the theme.

internationalization

internationalization: Internationalization


i18n

i18n: TranslationProxy


page

readonly page: MarkdownPageEvent<Reflection>

The current page event.


options

readonly options: Options

The options provided to the application.

Resources

Theme resources are the main building blocks for the theme context. They are split into three namespaces: templates, partials and helpers.

templates

templates: object

Then templates namespace holds the main templates for the theme and are mapped to single pages and configured in the MarkdownTheme.

All templates return a string that is passed back to the renderer. Internally templates call partials and helpers.

document()

document: (page) => string

Template that maps to a project document.

Parameters
ParameterType
pageMarkdownPageEvent<DocumentReflection>
Returns

string

project()

project: (page) => string

Template that maps to the root project reflection. This will be the index page / documentation root page.

Parameters
ParameterType
pageMarkdownPageEvent<ProjectReflection>
Returns

string

readme()

readme: (page) => string

Template that specifically maps to the resolved readme file. This template is not used when ‘readme’ is set to ‘none’.

Parameters
ParameterType
pageMarkdownPageEvent<ProjectReflection>
Returns

string

reflection()

reflection: (page) => string

Template that maps to individual reflection models.

Parameters
ParameterType
pageMarkdownPageEvent<DeclarationReflection>
Returns

string


partials

partials: object

The partials namespace holds the partials for the theme and are used by templates to map speficic models to page output.

Please note that partials::

  • Take a model param (that references a specific TypeDoc model) and an options param if required.
  • Can call other partials and helpers.
  • Must return a string.

Partials are categorised by their use:

  • Page Partials: Partials that render core page elements such as header and breadcrumbs.
  • Container Partials: Partials that are used to render reflection groups and categories.
  • Member Partials: Partials that render specific parts of reflections.
  • Comment Partials: Partials that render comments.
  • Type Partials: Partials that render specific TypeDoc model types.

comment()

comment: (model, options) => string

Parameters
ParameterType
modelComment
optionsobject
options.headingLevel?number
options.showSummary?boolean
options.showTags?boolean
options.isTableColumn?boolean
Returns

string

body()

body: (model, options) => string

Parameters
ParameterType
modelContainerReflection
optionsobject
options.headingLevelnumber
Returns

string

categories()

categories: (model, options) => string

Parameters
ParameterType
modelReflectionCategory[]
optionsobject
options.headingLevelnumber
Returns

string

groups()

groups: (model, options) => string

Parameters
ParameterType
modelReflectionGroup[]
optionsobject
options.headingLevelnumber
options.kindReflectionKind
Returns

string

members()

members: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection[]
optionsobject
options.headingLevelnumber
Returns

string

accessor()

accessor: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection
optionsobject
options.headingLevelnumber
Returns

string

constructor()

constructor: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection
optionsobject
options.headingLevelnumber
Returns

string

memberContainer()

memberContainer: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection
optionsobject
options.headingLevelnumber
options.nested?boolean
Returns

string

declaration()

declaration: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection
optionsobject
options.headingLevelnumber
options.nested?boolean
Returns

string

declarationTitle()

declarationTitle: (model) => string

Parameters
ParameterType
modelDeclarationReflection
Returns

string

documents()

documents: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection | ProjectReflection | ContainerReflection
optionsobject
options.headingLevelnumber
Returns

string

enumMembersTable()

enumMembersTable: (model) => string

Parameters
ParameterType
modelDeclarationReflection[]
Returns

string

hierarchy()

hierarchy: (model, options) => string

Parameters
ParameterType
modelDeclarationHierarchy
optionsobject
options.headingLevelnumber
Returns

string

indexSignature()

indexSignature: (model) => string

Parameters
ParameterType
modelSignatureReflection
Returns

string

inheritance()

inheritance: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection | SignatureReflection
optionsobject
options.headingLevelnumber
Returns

string

memberTitle()

memberTitle: (model) => string

Parameters
ParameterType
modelDeclarationReflection
Returns

string

memberWithGroups()

memberWithGroups: (model, options) => string

Renders a top-level member that contains group and child members such as Classes, Interfaces and Enums.

Parameters
ParameterType
modelDeclarationReflection
optionsobject
options.headingLevelnumber
Returns

string

parametersList()

parametersList: (model) => string

Parameters
ParameterType
modelParameterReflection[]
Returns

string

parametersTable()

parametersTable: (model) => string

Parameters
ParameterType
modelParameterReflection[]
Returns

string

propertiesTable()

propertiesTable: (model, options?) => string

Renders a collection of properties in a table.

There is no association list partial for properties as these are handled as a standard list of members.

Parameters
ParameterType
modelDeclarationReflection[]
options?object
options.isEventProps?boolean
Returns

string

referenceMember()

referenceMember: (model) => string

Parameters
ParameterType
modelReferenceReflection
Returns

string

reflectionIndex()

reflectionIndex: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection | ProjectReflection
optionsobject
options.headingLevelnumber
Returns

string

signature()

signature: (model, options) => string

Parameters
ParameterType
modelSignatureReflection
optionsobject
options.headingLevelnumber
options.nested?boolean
options.accessor?string
options.multipleSignatures?boolean
Returns

string

signatureParameters()

signatureParameters: (model) => string

Parameters
ParameterType
modelParameterReflection[]
Returns

string

signatureReturns()

signatureReturns: (model, options) => string

Parameters
ParameterType
modelSignatureReflection
optionsobject
options.headingLevelnumber
Returns

string

signatureTitle()

signatureTitle: (model, options?) => string

Parameters
ParameterType
modelSignatureReflection
options?object
options.accessor?string
options.includeType?boolean
Returns

string

signatures()

signatures: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection
optionsobject
options.headingLevelnumber
options.nested?boolean
Returns

string

sources()

sources: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection | SignatureReflection
optionsobject
options.headingLevelnumber
Returns

string

member()

member: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection
optionsobject
options.headingLevelnumber
options.nested?boolean
Returns

string

typeAndParent()

typeAndParent: (model) => string

Parameters
ParameterType
modelReferenceType | ArrayType
Returns

string

typeArguments()

typeArguments: (model, options?) => string

Parameters
ParameterType
modelSomeType[]
options?object
options.forceCollapse?boolean
Returns

string

typeDeclaration()

typeDeclaration: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection
optionsobject
options.headingLevelnumber
Returns

string

typeDeclarationList()

typeDeclarationList: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection[]
optionsobject
options.headingLevelnumber
Returns

string

typeDeclarationTable()

typeDeclarationTable: (model, options) => string

Parameters
ParameterType
modelDeclarationReflection[]
optionsobject
options.kind?ReflectionKind
Returns

string

typeParametersList()

typeParametersList: (model) => string

Parameters
ParameterType
modelTypeParameterReflection[]
Returns

string

typeParametersTable()

typeParametersTable: (model) => string

Parameters
ParameterType
modelTypeParameterReflection[]
Returns

string

breadcrumbs: () => string

Returns

string

footer: () => string

Returns

string

header: () => string

Returns

string

packagesIndex()

packagesIndex: (model) => string

Parameters
ParameterType
modelProjectReflection
Returns

string

pageTitle()

pageTitle: () => string

Returns

string

arrayType()

arrayType: (model) => string

Parameters
ParameterType
modelArrayType
Returns

string

conditionalType()

conditionalType: (model) => string

Parameters
ParameterType
modelConditionalType
Returns

string

indexAccessType()

indexAccessType: (model) => string

Parameters
ParameterType
modelIndexedAccessType
Returns

string

inferredType()

inferredType: (model) => string

Parameters
ParameterType
modelInferredType
Returns

string

intersectionType()

intersectionType: (model) => string

Parameters
ParameterType
modelIntersectionType
Returns

string

intrinsicType()

intrinsicType: (model) => string

Parameters
ParameterType
modelIntrinsicType
Returns

string

literalType()

literalType: (model) => string

Parameters
ParameterType
modelLiteralType
Returns

string

namedTupleType()

namedTupleType: (model) => string

Parameters
ParameterType
modelNamedTupleMember
Returns

string

queryType()

queryType: (model) => string

Parameters
ParameterType
modelQueryType
Returns

string

referenceType()

referenceType: (model) => string

Parameters
ParameterType
modelReferenceType
Returns

string

declarationType()

declarationType: (model) => string

Parameters
ParameterType
modelDeclarationReflection
Returns

string

functionType()

functionType: (model, options?) => string

Parameters
ParameterType
modelSignatureReflection[]
options?object
options.forceParameterType?boolean
Returns

string

reflectionType()

reflectionType: (model, options?) => string

Parameters
ParameterType
modelReflectionType
options?object
options.forceCollapse?boolean
Returns

string

someType()

someType: (model?) => string

Parameters
ParameterType
model?SomeType
Returns

string

tupleType()

tupleType: (model) => string

Parameters
ParameterType
modelTupleType
Returns

string

typeOperatorType()

typeOperatorType: (model) => string

Parameters
ParameterType
modelTypeOperatorType
Returns

string

unionType()

unionType: (model) => string

Parameters
ParameterType
modelUnionType
Returns

string

unknownType()

unknownType: (model) => string

Parameters
ParameterType
modelUnknownType
Returns

string


helpers

helpers: object

The helpers namespace holds the helpers for the theme and are smaller utility functions that return snippets or text or other data transformations.

Please note that partials:

  • Take a model param (that references a specific TypeDoc model) and an options param if required.
  • Can reference other helpers but should not reference partials.
  • Can return strings or other models.

getAngleBracket()

getAngleBracket: (bracket) => string

Parameters
ParameterType
bracket"<" | ">"
Returns

string

getCommentParts()

getCommentParts: (model) => string

Parameters
ParameterType
modelCommentDisplayPart[]
Returns

string

getDeclarationType()

getDeclarationType: (model) => undefined | SomeType

Parameters
ParameterType
modelDeclarationReflection
Returns

undefined | SomeType

getDescriptionForComment()

getDescriptionForComment: (comment) => null | string

Parameters
ParameterType
commentComment
Returns

null | string

getFlattenedDeclarations()

getFlattenedDeclarations: (model, options?) => DeclarationReflection[]

Parameters
ParameterType
modelDeclarationReflection[]
options?object
options.includeSignatures?boolean
Returns

DeclarationReflection[]

getGroupIndexList()

getGroupIndexList: (children) => string

Parameters
ParameterType
childrenDocumentReflection[] | DeclarationReflection[]
Returns

string

getGroupIndexTable()

getGroupIndexTable: (children) => string

Parameters
ParameterType
childrenDocumentReflection[] | DeclarationReflection[]
Returns

string

getGroupIndex()

getGroupIndex: (group) => any

Parameters
ParameterType
groupReflectionCategory | ReflectionGroup
Returns

any

getHierarchyType()

getHierarchyType: (model, options?) => string

Parameters
ParameterType
modelSomeType
options?object
options.isTarget?boolean
Returns

string

getKeyword()

getKeyword: (model) => string

Parameters
ParameterType
modelReflectionKind
Returns

string

getModifier()

getModifier: (model) => null | string

Parameters
ParameterType
modelDeclarationReflection
Returns

null | string

getParameterDefaultValue()

getParameterDefaultValue: (model) => string

Parameters
ParameterType
modelParameterReflection
Returns

string

getProjectName()

getProjectName: (stringWithPlaceholders, page) => string

Parameters
ParameterType
stringWithPlaceholdersstring
pageMarkdownPageEvent<Reflection>
Returns

string

getPropertyDefaultValue()

getPropertyDefaultValue: (model) => null | string

Parameters
ParameterType
modelDeclarationReflection
Returns

null | string

getReflectionFlags()

getReflectionFlags: (reflectionFlags) => string

Parameters
ParameterType
reflectionFlagsReflectionFlags
Returns

string

getReturnType()

getReturnType: (model?) => string

Parameters
ParameterType
model?SomeType
Returns

string

isGroupKind()

isGroupKind: (model) => boolean

Parameters
ParameterType
modelDeclarationReflection | SignatureReflection
Returns

boolean

useTableFormat()

useTableFormat: (key, reflectionKind?) => boolean

Parameters
ParameterType
key"parameters" | "properties" | "enums" | "typeDeclarations" | "propertyMembers"
reflectionKind?ReflectionKind
Returns

boolean