UNPKG

1.87 kBTypeScriptView Raw
1import type { ProjectReflection } from "../models/reflections/project.js";
2import type { RenderTemplate, UrlMapping } from "./models/UrlMapping.js";
3import { RendererComponent } from "./components.js";
4import type { PageEvent } from "./events.js";
5import type { Reflection } from "../models/index.js";
6import type { Slugger } from "./themes/default/Slugger.js";
7/**
8 * Base class of all themes.
9 *
10 * The theme class controls which files will be created through the {@link Theme.getUrls}
11 * function. It returns an array of {@link UrlMapping} instances defining the target files, models
12 * and templates to use. Additionally themes can subscribe to the events emitted by
13 * {@link Renderer} to control and manipulate the output process.
14 */
15export declare abstract class Theme extends RendererComponent {
16 private sluggers;
17 /**
18 * Map the models of the given project to the desired output files.
19 * It is assumed that with the project structure:
20 * ```text
21 * A
22 * |- B
23 * |- C
24 * ```
25 * If `B` has a UrlMapping, then `A` also has a UrlMapping, and `C` may or
26 * may not have a UrlMapping. If `B` does not have a UrlMapping, then `A`
27 * may or may not have a UrlMapping, but `C` must not have a UrlMapping.
28 *
29 * @param project The project whose urls should be generated.
30 * @returns A list of {@link UrlMapping} instances defining which models
31 * should be rendered to which files.
32 */
33 abstract getUrls(project: ProjectReflection): UrlMapping<Reflection>[];
34 /**
35 * Renders the provided page to a string, which will be written to disk by the {@link Renderer}
36 */
37 abstract render(page: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>): string;
38 setSlugger(reflection: Reflection, slugger: Slugger): void;
39 getSlugger(reflection: Reflection): Slugger;
40}