UNPKG

5.8 kBTypeScriptView Raw
1import type { ProjectReflection } from "../models/reflections/project";
2import type { RenderTemplate, UrlMapping } from "./models/UrlMapping";
3import type { DeclarationReflection, DocumentReflection, Reflection, ReflectionKind } from "../models";
4/**
5 * An event emitted by the {@link Renderer} class at the very beginning and
6 * ending of the entire rendering process.
7 *
8 * @see {@link Renderer.EVENT_BEGIN}
9 * @see {@link Renderer.EVENT_END}
10 */
11export declare class RendererEvent {
12 /**
13 * The project the renderer is currently processing.
14 */
15 readonly project: ProjectReflection;
16 /**
17 * The path of the directory the documentation should be written to.
18 */
19 readonly outputDirectory: string;
20 /**
21 * A list of all pages that should be generated.
22 *
23 * This list can be altered during the {@link Renderer.EVENT_BEGIN} event.
24 */
25 urls?: UrlMapping<Reflection>[];
26 /**
27 * Triggered before the renderer starts rendering a project.
28 * @event
29 */
30 static readonly BEGIN = "beginRender";
31 /**
32 * Triggered after the renderer has written all documents.
33 * @event
34 */
35 static readonly END = "endRender";
36 constructor(outputDirectory: string, project: ProjectReflection);
37 /**
38 * Create an {@link PageEvent} event based on this event and the given url mapping.
39 *
40 * @internal
41 * @param mapping The mapping that defines the generated {@link PageEvent} state.
42 * @returns A newly created {@link PageEvent} instance.
43 */
44 createPageEvent<Model>(mapping: UrlMapping<Model>): [RenderTemplate<PageEvent<Model>>, PageEvent<Model>];
45}
46export interface PageHeading {
47 link: string;
48 text: string;
49 level?: number;
50 kind?: ReflectionKind;
51 classes?: string;
52}
53/**
54 * An event emitted by the {@link Renderer} class before and after the
55 * markup of a page is rendered.
56 *
57 * @see {@link Renderer.EVENT_BEGIN_PAGE}
58 * @see {@link Renderer.EVENT_END_PAGE}
59 */
60export declare class PageEvent<out Model = unknown> {
61 /**
62 * The project the renderer is currently processing.
63 */
64 project: ProjectReflection;
65 /**
66 * The filename the page will be written to.
67 */
68 filename: string;
69 /**
70 * The url this page will be located at.
71 */
72 url: string;
73 /**
74 * The model that should be rendered on this page.
75 */
76 readonly model: Model;
77 /**
78 * The final html content of this page.
79 *
80 * Should be rendered by layout templates and can be modified by plugins.
81 */
82 contents?: string;
83 /**
84 * Links to content within this page that should be rendered in the page navigation.
85 * This is built when rendering the document content.
86 */
87 pageHeadings: PageHeading[];
88 /**
89 * Sections of the page, generally set by `@group`s
90 */
91 pageSections: {
92 title: string;
93 headings: PageHeading[];
94 }[];
95 /**
96 * Start a new section of the page. Sections are collapsible within
97 * the "On This Page" sidebar.
98 */
99 startNewSection(title: string): void;
100 /**
101 * Triggered before a document will be rendered.
102 * @event
103 */
104 static readonly BEGIN = "beginPage";
105 /**
106 * Triggered after a document has been rendered, just before it is written to disc.
107 * @event
108 */
109 static readonly END = "endPage";
110 constructor(model: Model);
111 /** @deprecated use the single constructor arg instead, will be removed in 0.27 */
112 constructor(name: string, model: Model);
113}
114/**
115 * An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
116 *
117 * @see {@link MarkdownEvent.PARSE}
118 */
119export declare class MarkdownEvent {
120 /**
121 * The unparsed original text.
122 */
123 readonly originalText: string;
124 /**
125 * The parsed output.
126 */
127 parsedText: string;
128 /**
129 * The page that this markdown is being parsed for.
130 */
131 readonly page: PageEvent;
132 /**
133 * Triggered on the renderer when this plugin parses a markdown string.
134 * @event
135 */
136 static readonly PARSE = "parseMarkdown";
137 constructor(page: PageEvent, originalText: string, parsedText: string);
138}
139/**
140 * An event emitted when the search index is being prepared.
141 */
142export declare class IndexEvent {
143 /**
144 * Triggered on the renderer when the search index is being prepared.
145 * @event
146 */
147 static readonly PREPARE_INDEX = "prepareIndex";
148 /**
149 * May be filtered by plugins to reduce the results available.
150 * Additional items *should not* be added to this array.
151 *
152 * If you remove an index from this array, you must also remove the
153 * same index from {@link searchFields}. The {@link removeResult} helper
154 * will do this for you.
155 */
156 searchResults: Array<DeclarationReflection | DocumentReflection>;
157 /**
158 * Additional search fields to be used when creating the search index.
159 * `name`, `comment` and `document` may be specified to overwrite TypeDoc's search fields.
160 *
161 * Do not use `id` as a custom search field.
162 */
163 searchFields: Record<string, string>[];
164 /**
165 * Weights for the fields defined in `searchFields`. The default will weight
166 * `name` as 10x more important than comment and document content.
167 *
168 * If a field added to {@link searchFields} is not added to this object, it
169 * will **not** be searchable.
170 *
171 * Do not replace this object, instead, set new properties on it for custom search
172 * fields added by your plugin.
173 */
174 readonly searchFieldWeights: Record<string, number>;
175 /**
176 * Remove a search result by index.
177 */
178 removeResult(index: number): void;
179 constructor(searchResults: Array<DeclarationReflection | DocumentReflection>);
180}