|
1 | 1 | import { ListItem } from 'mdast'; |
2 | 2 |
|
| 3 | +/** |
| 4 | + * Represents an entry in a hierarchical structure, extending from ApiDocMetadataEntry. |
| 5 | + * It includes children entries organized in a hierarchy. |
| 6 | + */ |
3 | 7 | 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[]; |
5 | 12 | } |
6 | 13 |
|
| 14 | +/** |
| 15 | + * Contains metadata related to changes, additions, removals, and deprecated statuses of an entry. |
| 16 | + */ |
7 | 17 | 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[]; |
13 | 42 | } |
14 | 43 |
|
| 44 | +/** |
| 45 | + * Base interface for sections in the API documentation, representing common properties. |
| 46 | + */ |
15 | 47 | export interface SectionBase { |
| 48 | + /** |
| 49 | + * The type of section (e.g., 'module', 'method', 'property'). |
| 50 | + */ |
16 | 51 | type: string; |
| 52 | + |
| 53 | + /** |
| 54 | + * The name of the section. |
| 55 | + */ |
17 | 56 | name: string; |
| 57 | + |
| 58 | + /** |
| 59 | + * Raw text content associated with the section. |
| 60 | + */ |
18 | 61 | textRaw: string; |
| 62 | + |
| 63 | + /** |
| 64 | + * Display name of the section. |
| 65 | + */ |
19 | 66 | displayName?: string; |
| 67 | + |
| 68 | + /** |
| 69 | + * A detailed description of the section. |
| 70 | + */ |
20 | 71 | desc: string; |
| 72 | + |
| 73 | + /** |
| 74 | + * A brief description of the section. |
| 75 | + */ |
21 | 76 | shortDesc?: string; |
| 77 | + |
| 78 | + /** |
| 79 | + * Stability index of the section. |
| 80 | + */ |
22 | 81 | stability?: number; |
| 82 | + |
| 83 | + /** |
| 84 | + * Descriptive text related to the stability of the section (E.G. "Experimental"). |
| 85 | + */ |
23 | 86 | stabilityText?: string; |
24 | | - meta?: Meta; |
| 87 | + |
| 88 | + /** |
| 89 | + * Metadata associated with the section. |
| 90 | + */ |
| 91 | + meta: Meta; |
25 | 92 | } |
26 | 93 |
|
| 94 | +/** |
| 95 | + * Represents a module section, which can contain other modules, classes, methods, properties, and other sections. |
| 96 | + */ |
27 | 97 | export interface ModuleSection extends SectionBase { |
| 98 | + /** |
| 99 | + * The type of section. Always 'module' for this interface. |
| 100 | + */ |
28 | 101 | type: 'module'; |
| 102 | + |
| 103 | + /** |
| 104 | + * Source of the module (File path). |
| 105 | + */ |
29 | 106 | 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 | + */ |
35 | 136 | globals?: ModuleSection | { type: 'global' }; |
36 | | - signatures?: Array<SignatureSection>; |
| 137 | + |
| 138 | + /** |
| 139 | + * Signatures (e.g., functions, methods) associated with this module. |
| 140 | + */ |
| 141 | + signatures?: SignatureSection[]; |
37 | 142 | } |
38 | 143 |
|
| 144 | +/** |
| 145 | + * Represents a signature section for methods, constructors, or classes. |
| 146 | + */ |
39 | 147 | export interface SignatureSection extends SectionBase { |
| 148 | + /** |
| 149 | + * The type of section. It can be one of 'class', 'ctor' (constructor), 'classMethod', or 'method'. |
| 150 | + */ |
40 | 151 | type: 'class' | 'ctor' | 'classMethod' | 'method'; |
41 | | - signatures: Array<MethodSignature>; |
| 152 | + |
| 153 | + /** |
| 154 | + * A list of method signatures within this section. |
| 155 | + */ |
| 156 | + signatures: MethodSignature[]; |
42 | 157 | } |
43 | 158 |
|
| 159 | +/** |
| 160 | + * All possible types of sections. |
| 161 | + */ |
44 | 162 | export type Section = |
45 | 163 | | SignatureSection |
46 | 164 | | PropertySection |
47 | 165 | | EventSection |
48 | 166 | | MiscSection; |
49 | 167 |
|
| 168 | +/** |
| 169 | + * Represents a parameter for methods or functions. |
| 170 | + */ |
50 | 171 | export interface Parameter { |
| 172 | + /** |
| 173 | + * The name of the parameter. |
| 174 | + */ |
51 | 175 | name: string; |
| 176 | + |
| 177 | + /** |
| 178 | + * Indicates if the parameter is optional. |
| 179 | + */ |
52 | 180 | optional?: boolean; |
| 181 | + |
| 182 | + /** |
| 183 | + * The default value for the parameter. |
| 184 | + */ |
53 | 185 | default?: string; |
54 | 186 | } |
55 | 187 |
|
| 188 | +/** |
| 189 | + * Represents a method signature, including its parameters and return type. |
| 190 | + */ |
56 | 191 | 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 | + */ |
58 | 200 | return?: string; |
59 | 201 | } |
60 | 202 |
|
| 203 | +/** |
| 204 | + * Represents a property section in the API documentation. |
| 205 | + */ |
61 | 206 | export interface PropertySection extends SectionBase { |
| 207 | + /** |
| 208 | + * The type of section. Always 'property' for this interface. |
| 209 | + */ |
62 | 210 | type: 'property'; |
| 211 | + |
| 212 | + /** |
| 213 | + * Arbitrary key-value pairs for the property. |
| 214 | + */ |
63 | 215 | [key: string]: string | undefined; |
64 | 216 | } |
65 | 217 |
|
| 218 | +/** |
| 219 | + * Represents an event section, typically containing event parameters. |
| 220 | + */ |
66 | 221 | export interface EventSection extends SectionBase { |
| 222 | + /** |
| 223 | + * The type of section. Always 'event' for this interface. |
| 224 | + */ |
67 | 225 | type: 'event'; |
68 | | - params: Array<ListItem>; |
| 226 | + |
| 227 | + /** |
| 228 | + * A list of parameters associated with the event. |
| 229 | + */ |
| 230 | + params: ListItem[]; |
69 | 231 | } |
70 | 232 |
|
| 233 | +/** |
| 234 | + * Represents a miscellaneous section with arbitrary content. |
| 235 | + */ |
71 | 236 | export interface MiscSection extends SectionBase { |
| 237 | + /** |
| 238 | + * The type of section. Always 'misc' for this interface. |
| 239 | + */ |
72 | 240 | type: 'misc'; |
| 241 | + |
73 | 242 | [key: string]: string | undefined; |
74 | 243 | } |
75 | 244 |
|
76 | | -export interface List { |
| 245 | +/** |
| 246 | + * Represents a list of parameters. |
| 247 | + */ |
| 248 | +export interface ParameterList { |
| 249 | + /** |
| 250 | + * Raw parameter description |
| 251 | + */ |
77 | 252 | textRaw: string; |
| 253 | + |
| 254 | + /** |
| 255 | + * A short description of the parameter. |
| 256 | + */ |
78 | 257 | desc?: string; |
| 258 | + |
| 259 | + /** |
| 260 | + * The name of the parameter. |
| 261 | + */ |
79 | 262 | name: string; |
| 263 | + |
| 264 | + /** |
| 265 | + * The type of the parameter (E.G. string, boolean). |
| 266 | + */ |
80 | 267 | type?: string; |
| 268 | + |
| 269 | + /** |
| 270 | + * The default value. |
| 271 | + */ |
81 | 272 | default?: string; |
82 | | - options?: List; |
| 273 | + |
| 274 | + options?: ParameterList; |
83 | 275 | } |
0 commit comments