UNPKG

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