Skip to content

Commit 8becb05

Browse files
committed
code review (3)
1 parent 96c0c26 commit 8becb05

File tree

4 files changed

+328
-136
lines changed

4 files changed

+328
-136
lines changed
Lines changed: 210 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,275 @@
11
import { ListItem } from 'mdast';
22

3+
/**
4+
* Represents an entry in a hierarchical structure, extending from ApiDocMetadataEntry.
5+
* It includes children entries organized in a hierarchy.
6+
*/
37
export interface HierarchizedEntry extends ApiDocMetadataEntry {
4-
hierarchyChildren: Array<ApiDocMetadataEntry>;
8+
/**
9+
* List of child entries that are part of this entry's hierarchy.
10+
*/
11+
hierarchyChildren: ApiDocMetadataEntry[];
512
}
613

14+
/**
15+
* Contains metadata related to changes, additions, removals, and deprecated statuses of an entry.
16+
*/
717
export interface Meta {
8-
changes: Array<ApiDocMetadataChange>;
9-
added?: Array<string>;
10-
napiVersion?: Array<string>;
11-
deprecated?: Array<string>;
12-
removed?: Array<string>;
18+
/**
19+
* A list of changes associated with the entry.
20+
*/
21+
changes: ApiDocMetadataChange[];
22+
23+
/**
24+
* A list of added versions or entities for the entry.
25+
*/
26+
added: string[];
27+
28+
/**
29+
* A list of NAPI (Node API) versions related to the entry.
30+
*/
31+
napiVersion: string[];
32+
33+
/**
34+
* A list of versions where the entry was deprecated.
35+
*/
36+
deprecated: string[];
37+
38+
/**
39+
* A list of versions where the entry was removed.
40+
*/
41+
removed: string[];
1342
}
1443

44+
/**
45+
* Base interface for sections in the API documentation, representing common properties.
46+
*/
1547
export interface SectionBase {
48+
/**
49+
* The type of section (e.g., 'module', 'method', 'property').
50+
*/
1651
type: string;
52+
53+
/**
54+
* The name of the section.
55+
*/
1756
name: string;
57+
58+
/**
59+
* Raw text content associated with the section.
60+
*/
1861
textRaw: string;
62+
63+
/**
64+
* Display name of the section.
65+
*/
1966
displayName?: string;
67+
68+
/**
69+
* A detailed description of the section.
70+
*/
2071
desc: string;
72+
73+
/**
74+
* A brief description of the section.
75+
*/
2176
shortDesc?: string;
77+
78+
/**
79+
* Stability index of the section.
80+
*/
2281
stability?: number;
82+
83+
/**
84+
* Descriptive text related to the stability of the section (E.G. "Experimental").
85+
*/
2386
stabilityText?: string;
24-
meta?: Meta;
87+
88+
/**
89+
* Metadata associated with the section.
90+
*/
91+
meta: Meta;
2592
}
2693

94+
/**
95+
* Represents a module section, which can contain other modules, classes, methods, properties, and other sections.
96+
*/
2797
export interface ModuleSection extends SectionBase {
98+
/**
99+
* The type of section. Always 'module' for this interface.
100+
*/
28101
type: 'module';
102+
103+
/**
104+
* Source of the module (File path).
105+
*/
29106
source: string;
30-
miscs?: Array<MiscSection>;
31-
modules?: Array<ModuleSection>;
32-
classes?: Array<SignatureSection>;
33-
methods?: Array<MethodSignature>;
34-
properties?: Array<PropertySection>;
107+
108+
/**
109+
* Miscellaneous sections associated with the module.
110+
*/
111+
miscs?: MiscSection[];
112+
113+
/**
114+
* Submodules within this module.
115+
*/
116+
modules?: ModuleSection[];
117+
118+
/**
119+
* Classes within this module.
120+
*/
121+
classes?: SignatureSection[];
122+
123+
/**
124+
* Methods within this module.
125+
*/
126+
methods?: MethodSignature[];
127+
128+
/**
129+
* Properties within this module.
130+
*/
131+
properties?: PropertySection[];
132+
133+
/**
134+
* Global definitions associated with the module.
135+
*/
35136
globals?: ModuleSection | { type: 'global' };
36-
signatures?: Array<SignatureSection>;
137+
138+
/**
139+
* Signatures (e.g., functions, methods) associated with this module.
140+
*/
141+
signatures?: SignatureSection[];
37142
}
38143

144+
/**
145+
* Represents a signature section for methods, constructors, or classes.
146+
*/
39147
export interface SignatureSection extends SectionBase {
148+
/**
149+
* The type of section. It can be one of 'class', 'ctor' (constructor), 'classMethod', or 'method'.
150+
*/
40151
type: 'class' | 'ctor' | 'classMethod' | 'method';
41-
signatures: Array<MethodSignature>;
152+
153+
/**
154+
* A list of method signatures within this section.
155+
*/
156+
signatures: MethodSignature[];
42157
}
43158

159+
/**
160+
* All possible types of sections.
161+
*/
44162
export type Section =
45163
| SignatureSection
46164
| PropertySection
47165
| EventSection
48166
| MiscSection;
49167

168+
/**
169+
* Represents a parameter for methods or functions.
170+
*/
50171
export interface Parameter {
172+
/**
173+
* The name of the parameter.
174+
*/
51175
name: string;
176+
177+
/**
178+
* Indicates if the parameter is optional.
179+
*/
52180
optional?: boolean;
181+
182+
/**
183+
* The default value for the parameter.
184+
*/
53185
default?: string;
54186
}
55187

188+
/**
189+
* Represents a method signature, including its parameters and return type.
190+
*/
56191
export interface MethodSignature {
57-
params: Array<Parameter>;
192+
/**
193+
* A list of parameters for the method.
194+
*/
195+
params: Parameter[];
196+
197+
/**
198+
* The return type of the method.
199+
*/
58200
return?: string;
59201
}
60202

203+
/**
204+
* Represents a property section in the API documentation.
205+
*/
61206
export interface PropertySection extends SectionBase {
207+
/**
208+
* The type of section. Always 'property' for this interface.
209+
*/
62210
type: 'property';
211+
212+
/**
213+
* Arbitrary key-value pairs for the property.
214+
*/
63215
[key: string]: string | undefined;
64216
}
65217

218+
/**
219+
* Represents an event section, typically containing event parameters.
220+
*/
66221
export interface EventSection extends SectionBase {
222+
/**
223+
* The type of section. Always 'event' for this interface.
224+
*/
67225
type: 'event';
68-
params: Array<ListItem>;
226+
227+
/**
228+
* A list of parameters associated with the event.
229+
*/
230+
params: ListItem[];
69231
}
70232

233+
/**
234+
* Represents a miscellaneous section with arbitrary content.
235+
*/
71236
export interface MiscSection extends SectionBase {
237+
/**
238+
* The type of section. Always 'misc' for this interface.
239+
*/
72240
type: 'misc';
241+
73242
[key: string]: string | undefined;
74243
}
75244

76-
export interface List {
245+
/**
246+
* Represents a list of parameters.
247+
*/
248+
export interface ParameterList {
249+
/**
250+
* Raw parameter description
251+
*/
77252
textRaw: string;
253+
254+
/**
255+
* A short description of the parameter.
256+
*/
78257
desc?: string;
258+
259+
/**
260+
* The name of the parameter.
261+
*/
79262
name: string;
263+
264+
/**
265+
* The type of the parameter (E.G. string, boolean).
266+
*/
80267
type?: string;
268+
269+
/**
270+
* The default value.
271+
*/
81272
default?: string;
82-
options?: List;
273+
274+
options?: ParameterList;
83275
}

0 commit comments

Comments
 (0)