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
Parameter | Type | Description |
---|---|---|
theme | MarkdownTheme | The theme instance. |
page | MarkdownPageEvent <Reflection > | The current page event. |
options | Options | The options provided to the application. |
Returns
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
Parameter | Type | Description |
---|---|---|
url | string | The URL to make relative. |
ignorePublicPath | boolean | Whether 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
Parameter | Type |
---|---|
page | MarkdownPageEvent <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
Parameter | Type |
---|---|
page | MarkdownPageEvent <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
Parameter | Type |
---|---|
page | MarkdownPageEvent <ProjectReflection > |
Returns
string
reflection()
reflection: (
page
) =>string
Template that maps to individual reflection models.
Parameters
Parameter | Type |
---|---|
page | MarkdownPageEvent <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 anoptions
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
Parameter | Type |
---|---|
model | Comment |
options | object |
options.headingLevel ? | number |
options.showSummary ? | boolean |
options.showTags ? | boolean |
options.isTableColumn ? | boolean |
Returns
string
body()
body: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | ContainerReflection |
options | object |
options.headingLevel | number |
Returns
string
categories()
categories: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | ReflectionCategory [] |
options | object |
options.headingLevel | number |
Returns
string
groups()
groups: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | ReflectionGroup [] |
options | object |
options.headingLevel | number |
options.kind | ReflectionKind |
Returns
string
members()
members: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection [] |
options | object |
options.headingLevel | number |
Returns
string
accessor()
accessor: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
options | object |
options.headingLevel | number |
Returns
string
constructor()
constructor: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
options | object |
options.headingLevel | number |
Returns
string
memberContainer()
memberContainer: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
options | object |
options.headingLevel | number |
options.nested ? | boolean |
Returns
string
declaration()
declaration: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
options | object |
options.headingLevel | number |
options.nested ? | boolean |
Returns
string
declarationTitle()
declarationTitle: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
Returns
string
documents()
documents: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection | ProjectReflection | ContainerReflection |
options | object |
options.headingLevel | number |
Returns
string
enumMembersTable()
enumMembersTable: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection [] |
Returns
string
hierarchy()
hierarchy: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationHierarchy |
options | object |
options.headingLevel | number |
Returns
string
indexSignature()
indexSignature: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | SignatureReflection |
Returns
string
inheritance()
inheritance: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection | SignatureReflection |
options | object |
options.headingLevel | number |
Returns
string
memberTitle()
memberTitle: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
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
Parameter | Type |
---|---|
model | DeclarationReflection |
options | object |
options.headingLevel | number |
Returns
string
parametersList()
parametersList: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ParameterReflection [] |
Returns
string
parametersTable()
parametersTable: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ParameterReflection [] |
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
Parameter | Type |
---|---|
model | DeclarationReflection [] |
options ? | object |
options.isEventProps ? | boolean |
Returns
string
referenceMember()
referenceMember: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ReferenceReflection |
Returns
string
reflectionIndex()
reflectionIndex: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection | ProjectReflection |
options | object |
options.headingLevel | number |
Returns
string
signature()
signature: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | SignatureReflection |
options | object |
options.headingLevel | number |
options.nested ? | boolean |
options.accessor ? | string |
options.multipleSignatures ? | boolean |
Returns
string
signatureParameters()
signatureParameters: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ParameterReflection [] |
Returns
string
signatureReturns()
signatureReturns: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | SignatureReflection |
options | object |
options.headingLevel | number |
Returns
string
signatureTitle()
signatureTitle: (
model
,options
?) =>string
Parameters
Parameter | Type |
---|---|
model | SignatureReflection |
options ? | object |
options.accessor ? | string |
options.includeType ? | boolean |
Returns
string
signatures()
signatures: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
options | object |
options.headingLevel | number |
options.nested ? | boolean |
Returns
string
sources()
sources: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection | SignatureReflection |
options | object |
options.headingLevel | number |
Returns
string
member()
member: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
options | object |
options.headingLevel | number |
options.nested ? | boolean |
Returns
string
typeAndParent()
typeAndParent: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ReferenceType | ArrayType |
Returns
string
typeArguments()
typeArguments: (
model
,options
?) =>string
Parameters
Parameter | Type |
---|---|
model | SomeType [] |
options ? | object |
options.forceCollapse ? | boolean |
Returns
string
typeDeclaration()
typeDeclaration: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
options | object |
options.headingLevel | number |
Returns
string
typeDeclarationList()
typeDeclarationList: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection [] |
options | object |
options.headingLevel | number |
Returns
string
typeDeclarationTable()
typeDeclarationTable: (
model
,options
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection [] |
options | object |
options.kind ? | ReflectionKind |
Returns
string
typeParametersList()
typeParametersList: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | TypeParameterReflection [] |
Returns
string
typeParametersTable()
typeParametersTable: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | TypeParameterReflection [] |
Returns
string
breadcrumbs()
breadcrumbs: () =>
string
Returns
string
footer()
footer: () =>
string
Returns
string
header()
header: () =>
string
Returns
string
packagesIndex()
packagesIndex: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ProjectReflection |
Returns
string
pageTitle()
pageTitle: () =>
string
Returns
string
arrayType()
arrayType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ArrayType |
Returns
string
conditionalType()
conditionalType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ConditionalType |
Returns
string
indexAccessType()
indexAccessType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | IndexedAccessType |
Returns
string
inferredType()
inferredType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | InferredType |
Returns
string
intersectionType()
intersectionType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | IntersectionType |
Returns
string
intrinsicType()
intrinsicType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | IntrinsicType |
Returns
string
literalType()
literalType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | LiteralType |
Returns
string
namedTupleType()
namedTupleType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | NamedTupleMember |
Returns
string
queryType()
queryType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | QueryType |
Returns
string
referenceType()
referenceType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ReferenceType |
Returns
string
declarationType()
declarationType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
Returns
string
functionType()
functionType: (
model
,options
?) =>string
Parameters
Parameter | Type |
---|---|
model | SignatureReflection [] |
options ? | object |
options.forceParameterType ? | boolean |
Returns
string
reflectionType()
reflectionType: (
model
,options
?) =>string
Parameters
Parameter | Type |
---|---|
model | ReflectionType |
options ? | object |
options.forceCollapse ? | boolean |
Returns
string
someType()
someType: (
model
?) =>string
Parameters
Parameter | Type |
---|---|
model ? | SomeType |
Returns
string
tupleType()
tupleType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | TupleType |
Returns
string
typeOperatorType()
typeOperatorType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | TypeOperatorType |
Returns
string
unionType()
unionType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | UnionType |
Returns
string
unknownType()
unknownType: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | UnknownType |
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 anoptions
param if required. - Can reference other helpers but should not reference partials.
- Can return strings or other models.
getAngleBracket()
getAngleBracket: (
bracket
) =>string
Parameters
Parameter | Type |
---|---|
bracket | "<" | ">" |
Returns
string
getCommentParts()
getCommentParts: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | CommentDisplayPart [] |
Returns
string
getDeclarationType()
getDeclarationType: (
model
) =>undefined
|SomeType
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
Returns
undefined
| SomeType
getDescriptionForComment()
getDescriptionForComment: (
comment
) =>null
|string
Parameters
Parameter | Type |
---|---|
comment | Comment |
Returns
null
| string
getFlattenedDeclarations()
getFlattenedDeclarations: (
model
,options
?) =>DeclarationReflection
[]
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection [] |
options ? | object |
options.includeSignatures ? | boolean |
Returns
getGroupIndexList()
getGroupIndexList: (
children
) =>string
Parameters
Parameter | Type |
---|---|
children | DocumentReflection [] | DeclarationReflection [] |
Returns
string
getGroupIndexTable()
getGroupIndexTable: (
children
) =>string
Parameters
Parameter | Type |
---|---|
children | DocumentReflection [] | DeclarationReflection [] |
Returns
string
getGroupIndex()
getGroupIndex: (
group
) =>any
Parameters
Parameter | Type |
---|---|
group | ReflectionCategory | ReflectionGroup |
Returns
any
getHierarchyType()
getHierarchyType: (
model
,options
?) =>string
Parameters
Parameter | Type |
---|---|
model | SomeType |
options ? | object |
options.isTarget ? | boolean |
Returns
string
getKeyword()
getKeyword: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ReflectionKind |
Returns
string
getModifier()
getModifier: (
model
) =>null
|string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
Returns
null
| string
getParameterDefaultValue()
getParameterDefaultValue: (
model
) =>string
Parameters
Parameter | Type |
---|---|
model | ParameterReflection |
Returns
string
getProjectName()
getProjectName: (
stringWithPlaceholders
,page
) =>string
Parameters
Parameter | Type |
---|---|
stringWithPlaceholders | string |
page | MarkdownPageEvent <Reflection > |
Returns
string
getPropertyDefaultValue()
getPropertyDefaultValue: (
model
) =>null
|string
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection |
Returns
null
| string
getReflectionFlags()
getReflectionFlags: (
reflectionFlags
) =>string
Parameters
Parameter | Type |
---|---|
reflectionFlags | ReflectionFlags |
Returns
string
getReturnType()
getReturnType: (
model
?) =>string
Parameters
Parameter | Type |
---|---|
model ? | SomeType |
Returns
string
isGroupKind()
isGroupKind: (
model
) =>boolean
Parameters
Parameter | Type |
---|---|
model | DeclarationReflection | SignatureReflection |
Returns
boolean
useTableFormat()
useTableFormat: (
key
,reflectionKind
?) =>boolean
Parameters
Parameter | Type |
---|---|
key | "parameters" | "properties" | "enums" | "typeDeclarations" | "propertyMembers" |
reflectionKind ? | ReflectionKind |
Returns
boolean