UNPKG

2.38 kBTypeScriptView Raw
1import { Reflection, type TraverseCallback } from "./abstract";
2import { ReflectionCategory } from "../ReflectionCategory";
3import { ReflectionGroup } from "../ReflectionGroup";
4import type { ReflectionKind } from "./kind";
5import type { Serializer, JSONOutput, Deserializer } from "../../serialization";
6import type { DocumentReflection } from "./document";
7import type { DeclarationReflection } from "./declaration";
8/**
9 * @category Reflections
10 */
11export declare abstract class ContainerReflection extends Reflection {
12 /**
13 * The children of this reflection. Do not add reflections to this array
14 * manually. Instead call {@link addChild}.
15 */
16 children?: Array<DeclarationReflection>;
17 /**
18 * Documents associated with this reflection.
19 *
20 * These are not children as including them as children requires code handle both
21 * types, despite being mostly unrelated and handled separately.
22 *
23 * Including them here in a separate array neatly handles that problem, but also
24 * introduces another one for rendering. When rendering, documents should really
25 * actually be considered part of the "children" of a reflection. For this reason,
26 * we also maintain a list of child declarations with child documents which is used
27 * when rendering.
28 */
29 documents?: Array<DocumentReflection>;
30 /**
31 * Union of the {@link children} and {@link documents} arrays which dictates the
32 * sort order for rendering.
33 */
34 childrenIncludingDocuments?: Array<DeclarationReflection | DocumentReflection>;
35 /**
36 * All children grouped by their kind.
37 */
38 groups?: ReflectionGroup[];
39 /**
40 * All children grouped by their category.
41 */
42 categories?: ReflectionCategory[];
43 /**
44 * Return a list of all children of a certain kind.
45 *
46 * @param kind The desired kind of children.
47 * @returns An array containing all children with the desired kind.
48 */
49 getChildrenByKind(kind: ReflectionKind): DeclarationReflection[];
50 addChild(child: DeclarationReflection | DocumentReflection): void;
51 removeChild(child: DeclarationReflection | DocumentReflection): void;
52 traverse(callback: TraverseCallback): void;
53 toObject(serializer: Serializer): JSONOutput.ContainerReflection;
54 fromObject(de: Deserializer, obj: JSONOutput.ContainerReflection): void;
55}