UNPKG

5.8 kBTypeScriptView Raw
1import { Theme } from "../../theme.js";
2import type { Renderer } from "../../renderer.js";
3import { ReflectionKind, ProjectReflection, type ContainerReflection, DeclarationReflection, type Reflection, type DocumentReflection } from "../../../models/index.js";
4import { type RenderTemplate, UrlMapping } from "../../models/UrlMapping.js";
5import type { PageEvent } from "../../events.js";
6import type { MarkedPlugin } from "../../plugins/index.js";
7import { DefaultThemeRenderContext } from "./DefaultThemeRenderContext.js";
8import { JSX } from "../../../utils/index.js";
9export interface NavigationElement {
10 text: string;
11 path?: string;
12 kind?: ReflectionKind;
13 class?: string;
14 children?: NavigationElement[];
15}
16export declare class DefaultTheme extends Theme {
17 usedFileNames: Set<string>;
18 private accessor sluggerConfiguration;
19 /** @internal */
20 markedPlugin: MarkedPlugin;
21 /**
22 * The icons which will actually be rendered. The source of truth lives on the theme, and
23 * the {@link DefaultThemeRenderContext.icons} member will produce references to these.
24 *
25 * These icons will be written twice. Once to an `icons.svg` file in the assets directory
26 * which will be referenced by icons on the context, and once to an `icons.js` file so that
27 * references to the icons can be dynamically embedded within the page for use by the search
28 * dropdown and when loading the page on `file://` urls.
29 *
30 * Custom themes may overwrite this entire object or individual properties on it to customize
31 * the icons used within the page, however TypeDoc currently assumes that all icons are svg
32 * elements, so custom themes must also use svg elements.
33 */
34 icons: {
35 search: () => JSX.Element;
36 anchor: () => JSX.Element;
37 1: () => JSX.Element;
38 2: () => JSX.Element;
39 4: () => JSX.Element;
40 8: () => JSX.Element;
41 16: () => JSX.Element;
42 32: () => JSX.Element;
43 64: () => JSX.Element;
44 128: () => JSX.Element;
45 256: () => JSX.Element;
46 512: () => JSX.Element;
47 1024: () => JSX.Element;
48 2048: () => JSX.Element;
49 4096: () => JSX.Element;
50 8192: () => JSX.Element;
51 16384: () => JSX.Element;
52 32768: () => JSX.Element;
53 65536: () => JSX.Element;
54 131072: () => JSX.Element;
55 262144: () => JSX.Element;
56 524288: () => JSX.Element;
57 1048576: () => JSX.Element;
58 2097152: () => JSX.Element;
59 4194304: () => JSX.Element;
60 8388608: () => JSX.Element;
61 checkbox: () => JSX.Element;
62 chevronDown: () => JSX.Element;
63 menu: () => JSX.Element;
64 chevronSmall: () => JSX.Element;
65 folder: () => JSX.Element;
66 alertNote: () => JSX.Element;
67 alertTip: () => JSX.Element;
68 alertImportant: () => JSX.Element;
69 alertWarning: () => JSX.Element;
70 alertCaution: () => JSX.Element;
71 };
72 getRenderContext(pageEvent: PageEvent<Reflection>): DefaultThemeRenderContext;
73 documentTemplate: (pageEvent: PageEvent<DocumentReflection>) => JSX.Element;
74 reflectionTemplate: (pageEvent: PageEvent<ContainerReflection>) => JSX.Element;
75 indexTemplate: (pageEvent: PageEvent<ProjectReflection>) => JSX.Element;
76 hierarchyTemplate: (pageEvent: PageEvent<ProjectReflection>) => JSX.Element;
77 defaultLayoutTemplate: (pageEvent: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>) => JSX.Element;
78 getReflectionClasses(reflection: DeclarationReflection | DocumentReflection): string;
79 /**
80 * Mappings of reflections kinds to templates used by this theme.
81 */
82 private mappings;
83 static URL_PREFIX: RegExp;
84 /**
85 * Create a new DefaultTheme instance.
86 *
87 * @param renderer The renderer this theme is attached to.
88 */
89 constructor(renderer: Renderer);
90 /**
91 * Map the models of the given project to the desired output files.
92 *
93 * @param project The project whose urls should be generated.
94 * @returns A list of {@link UrlMapping} instances defining which models
95 * should be rendered to which files.
96 */
97 getUrls(project: ProjectReflection): UrlMapping[];
98 /**
99 * @param reflection The reflection the url should be generated for.
100 */
101 getFileName(reflection: Reflection): string;
102 /**
103 * Return the template mapping for the given reflection.
104 *
105 * @param reflection The reflection whose mapping should be resolved.
106 * @returns The found mapping or undefined if no mapping could be found.
107 */
108 private getMapping;
109 /**
110 * Build the url for the the given reflection and all of its children.
111 *
112 * @param reflection The reflection the url should be created for.
113 * @param urls The array the url should be appended to.
114 * @returns The altered urls array.
115 */
116 buildUrls(reflection: DeclarationReflection | DocumentReflection, urls: UrlMapping[]): UrlMapping[];
117 render(page: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>): string;
118 private _navigationCache;
119 /**
120 * If implementing a custom theme, it is recommended to override {@link buildNavigation} instead.
121 */
122 getNavigation(project: ProjectReflection): NavigationElement[];
123 buildNavigation(project: ProjectReflection): NavigationElement[];
124 /**
125 * Generate an anchor url for the given reflection and all of its children.
126 *
127 * @param reflection The reflection an anchor url should be created for.
128 * @param container The nearest reflection having an own document.
129 */
130 applyAnchorUrl(reflection: Reflection, container: Reflection): void;
131}