UNPKG

5.9 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.dev/license
7 */
8/** The JSON data file format for extracted API reference info. */
9export interface EntryCollection {
10 moduleName: string;
11 normalizedModuleName: string;
12 moduleLabel: string;
13 entries: DocEntry[];
14}
15/** Type of top-level documentation entry. */
16export declare enum EntryType {
17 Block = "block",
18 Component = "component",
19 Constant = "constant",
20 Decorator = "decorator",
21 Directive = "directive",
22 Element = "element",
23 Enum = "enum",
24 Function = "function",
25 Interface = "interface",
26 NgModule = "ng_module",
27 Pipe = "pipe",
28 TypeAlias = "type_alias",
29 UndecoratedClass = "undecorated_class",
30 InitializerApiFunction = "initializer_api_function"
31}
32/** Types of class members */
33export declare enum MemberType {
34 Property = "property",
35 Method = "method",
36 Getter = "getter",
37 Setter = "setter",
38 EnumItem = "enum_item"
39}
40export declare enum DecoratorType {
41 Class = "class",
42 Member = "member",
43 Parameter = "parameter"
44}
45/** Informational tags applicable to class members. */
46export declare enum MemberTags {
47 Abstract = "abstract",
48 Static = "static",
49 Readonly = "readonly",
50 Protected = "protected",
51 Optional = "optional",
52 Input = "input",
53 Output = "output",
54 Inherited = "override"
55}
56/** Documentation entity for single JsDoc tag. */
57export interface JsDocTagEntry {
58 name: string;
59 comment: string;
60}
61/** Documentation entity for single generic parameter. */
62export interface GenericEntry {
63 name: string;
64 constraint: string | undefined;
65 default: string | undefined;
66}
67export interface SourceEntry {
68 filePath: string;
69 startLine: number;
70 endLine: number;
71}
72export interface DocEntryWithSourceInfo extends DocEntry {
73 source: SourceEntry;
74}
75/** Base type for all documentation entities. */
76export interface DocEntry {
77 entryType: EntryType;
78 name: string;
79 description: string;
80 rawComment: string;
81 jsdocTags: JsDocTagEntry[];
82}
83/** Documentation entity for a constant. */
84export interface ConstantEntry extends DocEntry {
85 type: string;
86}
87/** Documentation entity for a type alias. */
88export interface TypeAliasEntry extends ConstantEntry {
89 generics: GenericEntry[];
90}
91/** Documentation entity for a TypeScript class. */
92export interface ClassEntry extends DocEntry {
93 isAbstract: boolean;
94 members: MemberEntry[];
95 extends?: string;
96 generics: GenericEntry[];
97 implements: string[];
98}
99/** Documentation entity for a TypeScript interface. */
100export type InterfaceEntry = ClassEntry;
101/** Documentation entity for a TypeScript enum. */
102export interface EnumEntry extends DocEntry {
103 members: EnumMemberEntry[];
104}
105/** Documentation entity for an Angular decorator. */
106export interface DecoratorEntry extends DocEntry {
107 decoratorType: DecoratorType;
108 members: PropertyEntry[];
109}
110/** Documentation entity for an Angular directives and components. */
111export interface DirectiveEntry extends ClassEntry {
112 selector: string;
113 exportAs: string[];
114 isStandalone: boolean;
115}
116export interface PipeEntry extends ClassEntry {
117 pipeName: string;
118 isStandalone: boolean;
119}
120export interface FunctionSignatureMetadata extends DocEntry {
121 params: ParameterEntry[];
122 returnType: string;
123 returnDescription?: string;
124 generics: GenericEntry[];
125 isNewType: boolean;
126}
127/** Sub-entry for a single class or enum member. */
128export interface MemberEntry {
129 name: string;
130 memberType: MemberType;
131 memberTags: MemberTags[];
132 description: string;
133 jsdocTags: JsDocTagEntry[];
134}
135/** Sub-entry for an enum member. */
136export interface EnumMemberEntry extends MemberEntry {
137 type: string;
138 value: string;
139}
140/** Sub-entry for a class property. */
141export interface PropertyEntry extends MemberEntry {
142 type: string;
143 inputAlias?: string;
144 outputAlias?: string;
145 isRequiredInput?: boolean;
146}
147/** Sub-entry for a class method. */
148export type MethodEntry = MemberEntry & FunctionEntry;
149/** Sub-entry for a single function parameter. */
150export interface ParameterEntry {
151 name: string;
152 description: string;
153 type: string;
154 isOptional: boolean;
155 isRestParam: boolean;
156}
157export type FunctionEntry = FunctionDefinitionEntry & DocEntry & {
158 implementation: FunctionSignatureMetadata;
159};
160/** Interface describing a function with overload signatures. */
161export interface FunctionDefinitionEntry {
162 name: string;
163 signatures: FunctionSignatureMetadata[];
164 implementation: FunctionSignatureMetadata | null;
165}
166/**
167 * Docs entry describing an initializer API function.
168 *
169 * An initializer API function is a function that is invoked as
170 * initializer of class members. The function may hold additional
171 * sub functions, like `.required`.
172 *
173 * Known popular initializer APIs are `input()`, `output()`, `model()`.
174 *
175 * Initializer APIs are often constructed typed in complex ways so this
176 * entry type allows for readable "parsing" and interpretation of such
177 * constructs. Initializer APIs are explicitly denoted via a JSDoc tag.
178 */
179export interface InitializerApiFunctionEntry extends DocEntry {
180 callFunction: FunctionDefinitionEntry;
181 subFunctions: FunctionDefinitionEntry[];
182 __docsMetadata__?: {
183 /**
184 * Whether types should be shown in the signature
185 * preview of docs.
186 *
187 * By default, for readability purposes, types are omitted, but
188 * shorter initializer API functions like `output` may decide to
189 * render these types.
190 */
191 showTypesInSignaturePreview?: boolean;
192 };
193}
194export declare function isDocEntryWithSourceInfo(entry: DocEntry): entry is DocEntryWithSourceInfo;