UNPKG

4.76 kBTypeScriptView Raw
1import { type Reflection } from "./abstract";
2import { ContainerReflection } from "./container";
3import { type Type } from "../types";
4import type * as ts from "typescript";
5import { ReflectionKind } from "./kind";
6import { type CommentDisplayPart } from "../comments";
7import { ReflectionSymbolId } from "./ReflectionSymbolId";
8import type { Serializer } from "../../serialization/serializer";
9import type { Deserializer, JSONOutput } from "../../serialization/index";
10import type { FileRegistry } from "../FileRegistry";
11/**
12 * A reflection that represents the root of the project.
13 *
14 * The project reflection acts as a global index, one may receive all reflections
15 * and source files of the processed project through this reflection.
16 * @category Reflections
17 */
18export declare class ProjectReflection extends ContainerReflection {
19 readonly variant = "project";
20 private symbolToReflectionIdMap;
21 private reflectionIdToSymbolIdMap;
22 private reflectionIdToSymbolMap;
23 private referenceGraph?;
24 private reflectionChildren;
25 /**
26 * A list of all reflections within the project. DO NOT MUTATE THIS OBJECT.
27 * All mutation should be done via {@link registerReflection} and {@link removeReflection}
28 * to ensure that links to reflections remain valid.
29 *
30 * This may be replaced with a `Map<number, Reflection>` someday.
31 */
32 reflections: {
33 [id: number]: Reflection;
34 };
35 /**
36 * The name of the package that this reflection documents according to package.json.
37 */
38 packageName?: string;
39 /**
40 * The version of the package that this reflection documents according to package.json.
41 */
42 packageVersion?: string;
43 /**
44 * The contents of the readme.md file of the project when found.
45 */
46 readme?: CommentDisplayPart[];
47 /**
48 * Object which describes where to find content for relative links.
49 */
50 readonly files: FileRegistry;
51 constructor(name: string, registry: FileRegistry);
52 /**
53 * Return whether this reflection is the root / project reflection.
54 */
55 isProject(): this is ProjectReflection;
56 /**
57 * Return a list of all reflections in this project of a certain kind.
58 *
59 * @param kind The desired kind of reflection.
60 * @returns An array containing all reflections with the desired kind.
61 */
62 getReflectionsByKind(kind: ReflectionKind): Reflection[];
63 /**
64 * Registers the given reflection so that it can be quickly looked up by helper methods.
65 * Should be called for *every* reflection added to the project.
66 */
67 registerReflection(reflection: Reflection, symbol: ts.Symbol | undefined, filePath: string | undefined): void;
68 /**
69 * Removes references to reflections contained within the provided type.
70 * Plugins which overwrite types on reflections should pass the type to this
71 * method before overwriting the property.
72 * @since 0.26.6
73 */
74 removeTypeReflections(type: Type | undefined): void;
75 /**
76 * Removes a reflection from the documentation. Can be used by plugins to filter reflections
77 * out of the generated documentation. Has no effect if the reflection is not present in the
78 * project.
79 */
80 removeReflection(reflection: Reflection): void;
81 /**
82 * Remove a reflection without updating the parent reflection to remove references to the removed reflection.
83 */
84 private _removeReflection;
85 /**
86 * Gets the reflection registered for the given reflection ID, or undefined if it is not present
87 * in the project.
88 */
89 getReflectionById(id: number): Reflection | undefined;
90 /**
91 * Gets the reflection associated with the given symbol, if it exists.
92 * @internal
93 */
94 getReflectionFromSymbol(symbol: ts.Symbol): Reflection | undefined;
95 /**
96 * Gets the reflection associated with the given symbol id, if it exists.
97 * If there are multiple reflections associated with this symbol, gets the first one.
98 * @internal
99 */
100 getReflectionFromSymbolId(symbolId: ReflectionSymbolId): Reflection | undefined;
101 /** @internal */
102 getReflectionsFromSymbolId(symbolId: ReflectionSymbolId): Reflection[];
103 /** @internal */
104 getSymbolIdFromReflection(reflection: Reflection): ReflectionSymbolId | undefined;
105 /** @internal */
106 registerSymbolId(reflection: Reflection, id: ReflectionSymbolId): void;
107 /**
108 * THIS MAY NOT BE USED AFTER CONVERSION HAS FINISHED.
109 * @internal
110 */
111 getSymbolFromReflection(reflection: Reflection): ts.Symbol | undefined;
112 private getReferenceGraph;
113 toObject(serializer: Serializer): JSONOutput.ProjectReflection;
114 fromObject(de: Deserializer, obj: JSONOutput.ProjectReflection): void;
115}