UNPKG

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