UNPKG

14.1 kBTypeScriptView Raw
1import { MarkdownPageEvent } from '../events';
2import { MarkdownTheme } from '../theme';
3import { MarkdownRenderer, PackageMetaData } from '../types';
4import { Internationalization, Options, Reflection } from 'typedoc';
5/**
6 * The theme context class that is provided as context on the rendering of every page.
7 *
8 * It is heavily influenced by the equivalent [DefaultThemeRenderContext](https://typedoc.org/api/classes/DefaultThemeRenderContext.html) from the default theme.
9 *
10 * This class can be used to customize the theme output by extending the class and overriding the templates, partials and helpers.
11 *
12 * @groupDescription Properties
13 *
14 * Properties are passed into the constructor and are used to provide context to the theme.
15 *
16 * @groupDescription Methods
17 *
18 * General context aware helper methods not bound to any specific models that can be used by the theme resources.
19 *
20 * @groupDescription Resources
21 *
22 * Theme resources are the main building blocks for the theme context. They are split into three namespaces: `templates`, `partials` and `helpers`.
23 *
24 * @privateRemarks
25 *
26 * In order to create cleaner code, internally individual templates located in the `resources/templates` directory are bound to the this.
27 *
28 * @group Theme Classes
29 */
30export declare class MarkdownThemeContext {
31 /**
32 * The theme instance.
33 */
34 private theme;
35 /**
36 * The current page event.
37 */
38 readonly page: MarkdownPageEvent<Reflection>;
39 /**
40 * The options provided to the application.
41 */
42 readonly options: Options;
43 internationalization: Internationalization.Internationalization;
44 i18n: Internationalization.TranslationProxy;
45 /**
46 *
47 */
48 constructor(
49 /**
50 * The theme instance.
51 */
52 theme: MarkdownTheme,
53 /**
54 * The current page event.
55 */
56 page: MarkdownPageEvent<Reflection>,
57 /**
58 * The options provided to the application.
59 */
60 options: Options);
61 /**
62 * Holds meta data for individual packages (if entryPointStrategy equals `packages`).
63 *
64 * This is required for generating package specific documentation.
65 */
66 private packagesMetaData;
67 /**
68 * Then `templates` namespace holds the main templates for the theme and are mapped to single pages and configured in the MarkdownTheme.
69 *
70 * All templates return a string that is passed back to the renderer. Internally templates call partials and helpers.
71 *
72 * @group Resources
73 */
74 templates: {
75 document: (page: MarkdownPageEvent<import("typedoc").DocumentReflection>) => string;
76 project: (page: MarkdownPageEvent<import("typedoc").ProjectReflection>) => string;
77 readme: (page: MarkdownPageEvent<import("typedoc").ProjectReflection>) => string;
78 reflection: (page: MarkdownPageEvent<import("typedoc").DeclarationReflection>) => string;
79 };
80 /** The `partials` namespace holds the partials for the theme and are used by templates to map speficic models to page output.
81 *
82 * Please note that partials::
83 *
84 * - Take a `model` param (that references a specific TypeDoc model) and an `options` param if required.
85 * - Can call other partials and helpers.
86 * - Must return a string.
87 *
88 * Partials are categorised by their use:
89 *
90 * - Page Partials: Partials that render core page elements such as header and breadcrumbs.
91 * - Container Partials: Partials that are used to render reflection groups and categories.
92 * - Member Partials: Partials that render specific parts of reflections.
93 * - Comment Partials: Partials that render comments.
94 * - Type Partials: Partials that render specific TypeDoc model types.
95 *
96 * @group Resources
97 **/
98 partials: {
99 comment: (model: import("typedoc").Comment, options?: {
100 headingLevel?: number | undefined;
101 showSummary?: boolean | undefined;
102 showTags?: boolean | undefined;
103 showReturns?: boolean | undefined;
104 isTableColumn?: boolean | undefined;
105 }) => string;
106 body: (model: import("typedoc").ContainerReflection, options: {
107 headingLevel: number;
108 }) => string;
109 categories: (model: import("typedoc").ReflectionCategory[], options: {
110 headingLevel: number;
111 }) => string;
112 groups: (model: import("typedoc").ReflectionGroup[], options: {
113 headingLevel: number;
114 kind: import("typedoc").ReflectionKind;
115 }) => string;
116 members: (model: import("typedoc").DeclarationReflection[], options: {
117 headingLevel: number;
118 }) => string;
119 accessor: (model: import("typedoc").DeclarationReflection, options: {
120 headingLevel: number;
121 }) => string;
122 constructor: (model: import("typedoc").DeclarationReflection, options: {
123 headingLevel: number;
124 }) => string;
125 memberContainer: (model: import("typedoc").DeclarationReflection, options: {
126 headingLevel: number;
127 nested?: boolean | undefined;
128 }) => string;
129 declaration: (model: import("typedoc").DeclarationReflection, options?: {
130 headingLevel: number;
131 nested?: boolean | undefined;
132 }) => string;
133 declarationTitle: (model: import("typedoc").DeclarationReflection) => string;
134 documents: (model: import("typedoc").ProjectReflection | import("typedoc").DeclarationReflection | import("typedoc").ContainerReflection, options: {
135 headingLevel: number;
136 }) => string;
137 enumMembersTable: (model: import("typedoc").DeclarationReflection[]) => string;
138 hierarchy: (model: import("typedoc").DeclarationHierarchy, options: {
139 headingLevel: number;
140 }) => string;
141 indexSignature: (model: import("typedoc").SignatureReflection) => string;
142 inheritance: (model: import("typedoc").DeclarationReflection | import("typedoc").SignatureReflection, options: {
143 headingLevel: number;
144 }) => string;
145 memberTitle: (model: import("typedoc").DeclarationReflection) => string;
146 memberWithGroups: (model: import("typedoc").DeclarationReflection, options: {
147 headingLevel: number;
148 }) => string;
149 parametersList: (model: import("typedoc").ParameterReflection[]) => string;
150 parametersTable: (model: import("typedoc").ParameterReflection[]) => string;
151 propertiesTable: (model: import("typedoc").DeclarationReflection[], options?: {
152 isEventProps: boolean;
153 } | undefined) => string;
154 referenceMember: (model: import("typedoc").ReferenceReflection) => string;
155 reflectionIndex: (model: import("typedoc").ProjectReflection | import("typedoc").DeclarationReflection, options: {
156 headingLevel: number;
157 }) => string;
158 signature: (model: import("typedoc").SignatureReflection, options: {
159 headingLevel: number;
160 nested?: boolean | undefined;
161 accessor?: string | undefined;
162 multipleSignatures?: boolean | undefined;
163 }) => string;
164 signatureParameters: (model: import("typedoc").ParameterReflection[]) => string;
165 signatureReturns: (model: import("typedoc").SignatureReflection, options: {
166 headingLevel: number;
167 }) => string;
168 signatureTitle: (model: import("typedoc").SignatureReflection, options?: {
169 accessor?: string | undefined;
170 includeType?: boolean | undefined;
171 } | undefined) => string;
172 signatures: (model: import("typedoc").DeclarationReflection, options: {
173 headingLevel: number;
174 nested?: boolean | undefined;
175 }) => string;
176 sources: (model: import("typedoc").DeclarationReflection | import("typedoc").SignatureReflection, options: {
177 headingLevel: number;
178 }) => string;
179 member: (model: import("typedoc").DeclarationReflection, options: {
180 headingLevel: number;
181 nested?: boolean | undefined;
182 }) => string;
183 typeAndParent: (model: import("typedoc").ArrayType | import("typedoc").ReferenceType) => string;
184 typeArguments: (model: import("typedoc").SomeType[], options?: {
185 forceCollapse?: boolean | undefined;
186 } | undefined) => string;
187 typeDeclaration: (model: import("typedoc").DeclarationReflection, options: {
188 headingLevel: number;
189 }) => string;
190 typeDeclarationList: (model: import("typedoc").DeclarationReflection[], options: {
191 headingLevel: number;
192 }) => string;
193 typeDeclarationTable: (model: import("typedoc").DeclarationReflection[], options: {
194 kind?: import("typedoc").ReflectionKind | undefined;
195 }) => string;
196 typeParametersList: (model: import("typedoc").TypeParameterReflection[]) => string;
197 typeParametersTable: (model: import("typedoc").TypeParameterReflection[]) => string;
198 breadcrumbs: () => string;
199 footer: () => string;
200 header: () => string;
201 packagesIndex: (model: import("typedoc").ProjectReflection) => string;
202 pageTitle: () => string;
203 arrayType: (model: import("typedoc").ArrayType) => string;
204 conditionalType: (model: import("typedoc").ConditionalType) => string;
205 indexAccessType: (model: import("typedoc").IndexedAccessType) => string;
206 inferredType: (model: import("typedoc").InferredType) => string;
207 intersectionType: (model: import("typedoc").IntersectionType) => string;
208 intrinsicType: (model: import("typedoc").IntrinsicType) => string;
209 literalType: (model: import("typedoc").LiteralType) => string;
210 namedTupleType: (model: import("typedoc").NamedTupleMember) => string;
211 queryType: (model: import("typedoc").QueryType) => string;
212 referenceType: (model: import("typedoc").ReferenceType) => string;
213 declarationType: (model: import("typedoc").DeclarationReflection) => string;
214 functionType: (model: import("typedoc").SignatureReflection[], options?: {
215 forceParameterType: boolean;
216 } | undefined) => string;
217 reflectionType: (model: import("typedoc").ReflectionType, options?: {
218 forceCollapse?: boolean | undefined;
219 } | undefined) => string;
220 someType: (model?: import("typedoc").SomeType | undefined) => string;
221 tupleType: (model: import("typedoc").TupleType) => string;
222 typeOperatorType: (model: import("typedoc").TypeOperatorType) => string;
223 unionType: (model: import("typedoc").UnionType) => string;
224 unknownType: (model: import("typedoc").UnknownType) => string;
225 };
226 /**
227 * The `helpers` namespace holds the helpers for the theme and are smaller utility functions that return snippets or text or other data transformations.
228 *
229 * Please note that partials:
230 *
231 * - Take a `model` param (that references a specific TypeDoc model) and an `options` param if required.
232 * - Can reference other helpers but should not reference partials.
233 * - Can return strings or other models.
234 *
235 * @group Resources
236 */
237 helpers: {
238 getAngleBracket: (bracket: "<" | ">") => string;
239 getCommentParts: (model: import("typedoc").CommentDisplayPart[]) => string;
240 getDeclarationType: (model: import("typedoc").DeclarationReflection) => import("typedoc").SomeType | undefined;
241 getDescriptionForComment: (comment: import("typedoc").Comment) => string | null;
242 getFlattenedDeclarations: (model: import("typedoc").DeclarationReflection[], options?: {
243 includeSignatures: boolean;
244 } | undefined) => import("typedoc").DeclarationReflection[];
245 getGroupIndexList: (children: import("typedoc").DeclarationReflection[] | import("typedoc").DocumentReflection[]) => string;
246 getGroupIndexTable: (children: import("typedoc").DeclarationReflection[] | import("typedoc").DocumentReflection[]) => string;
247 getGroupIndex: (group: import("typedoc").ReflectionCategory | import("typedoc").ReflectionGroup) => any;
248 getHierarchyType: (model: import("typedoc").SomeType, options?: {
249 isTarget: boolean;
250 } | undefined) => string;
251 getKeyword: (model: import("typedoc").ReflectionKind) => string;
252 getModifier: (model: import("typedoc").DeclarationReflection) => string | null;
253 getParameterDefaultValue: (model: import("typedoc").ParameterReflection) => string;
254 getProjectName: (stringWithPlaceholders: string, page: MarkdownPageEvent<Reflection>) => string;
255 getPropertyDefaultValue: (model: import("typedoc").DeclarationReflection) => string | null;
256 getReflectionFlags: (reflectionFlags: import("typedoc").ReflectionFlags) => string;
257 getReturnType: (model?: import("typedoc").SomeType | undefined) => string;
258 isGroupKind: (model: import("typedoc").DeclarationReflection | import("typedoc").SignatureReflection) => boolean;
259 useTableFormat: (key: "properties" | "parameters" | "enums" | "typeDeclarations" | "propertyMembers", reflectionKind?: import("typedoc").ReflectionKind | undefined) => boolean;
260 };
261 /**
262 * Returns the package meta data for a given package name when entrypointStrategy is set to `packages`.
263 *
264 * @param packageName - The package name as per `name` field from `package.json`.
265 *
266 * @internal
267 */
268 getPackageMetaData(packageName: string): PackageMetaData | undefined;
269 /**
270 * Returns the relative URL (from the current page context url).
271 *
272 * If public path is set, it will be used as the base URL.
273 *
274 * @param url - The URL to make relative.
275 * @param ignorePublicPath - Whether to ignore the public path.
276 */
277 getRelativeUrl(url: string, ignorePublicPath?: boolean): string;
278 /**
279 * Hook into the TypeDoc rendering system.
280 *
281 * @internal
282 */
283 hook: MarkdownRenderer['markdownHooks']['emit'];
284}