Skip to content

Commit e3fa70e

Browse files
authored
feat: add typings for htmlAsJSON (#692)
1 parent 4258a05 commit e3fa70e

17 files changed

+455
-19
lines changed

js/deno.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "0.0.0",
44
"exports": {
55
".": "./mod.ts",
6-
"./types": "./types.d.ts"
6+
"./types": "./types.d.ts",
7+
"./html-types": "./html_types.d.ts"
78
},
89
"exclude": [
910
"!**"

js/html_types.d.ts

Lines changed: 374 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,374 @@
1+
// Copyright 2018-2025 the Deno authors. All rights reserved. MIT license.
2+
3+
export interface HtmlHeadCtx {
4+
title: string;
5+
current_file: string;
6+
stylesheet_url: string;
7+
page_stylesheet_url: string;
8+
reset_stylesheet_url: string;
9+
url_search_index: string;
10+
script_js: string;
11+
fuse_js: string;
12+
url_search: string;
13+
head_inject: string | null;
14+
disable_search: boolean;
15+
}
16+
17+
export interface CategoriesPanelCtx {
18+
categories: CategoriesPanelCategoryCtx[];
19+
all_symbols_href: string;
20+
total_symbols: number;
21+
}
22+
23+
export interface CategoriesPanelCategoryCtx {
24+
name: string;
25+
href: string;
26+
active: boolean;
27+
}
28+
29+
export type Page = IndexCtx | AllSymbolsCtx | SymbolPageCtx | Redirect | Search;
30+
31+
export interface PageBase {
32+
kind: "IndexCtx" | "AllSymbolsCtx" | "SymbolPageCtx";
33+
html_head_ctx: HtmlHeadCtx;
34+
disable_search: boolean;
35+
categories_panel: CategoriesPanelCtx | null;
36+
breadcrumbs_ctx: BreadcrumbsCtx;
37+
}
38+
39+
export interface IndexCtx extends PageBase {
40+
kind: "IndexCtx";
41+
overview: SymbolContentCtx | null;
42+
module_doc: ModuleDocCtx | null;
43+
usage: UsagesCtx | null;
44+
toc_ctx: ToCCtx;
45+
}
46+
47+
export interface AllSymbolsCtx extends PageBase {
48+
kind: "AllSymbolsCtx";
49+
content: SymbolContentCtx;
50+
}
51+
52+
export interface SymbolPageCtx extends PageBase {
53+
kind: "SymbolPageCtx";
54+
symbol_group_ctx: SymbolGroupCtx;
55+
toc_ctx: ToCCtx;
56+
}
57+
58+
export interface Redirect {
59+
kind: "redirect";
60+
path: string;
61+
}
62+
63+
export interface Search {
64+
kind: "search";
65+
path: SearchIndexNode[];
66+
}
67+
68+
export interface SlimKindCtx {
69+
char: string;
70+
kind: string;
71+
title: string;
72+
}
73+
74+
export interface SearchIndexNode {
75+
kind: SlimKindCtx[];
76+
name: string;
77+
file: string;
78+
doc: string;
79+
url: string;
80+
category?: string;
81+
deprecated: boolean;
82+
}
83+
84+
export interface ToCCtx {
85+
usages: UsagesCtx | null;
86+
top_symbols: TopSymbolsCtx | null;
87+
document_navigation_str: string | null;
88+
document_navigation: ToCEntry[];
89+
}
90+
91+
export interface ToCEntry {
92+
level: number;
93+
content: string;
94+
anchor: string;
95+
}
96+
97+
export interface UsagesCtx {
98+
usages: UsageCtx[];
99+
composed: boolean;
100+
}
101+
102+
export interface UsageCtx {
103+
name: string;
104+
content: string;
105+
icon: string | null;
106+
additional_css: string;
107+
}
108+
109+
export interface BreadcrumbsCtx {
110+
parts: BreadcrumbCtx[];
111+
}
112+
113+
export interface BreadcrumbCtx {
114+
name: string;
115+
href: string;
116+
is_symbol: boolean;
117+
is_first_symbol: boolean;
118+
}
119+
120+
export interface TopSymbolsCtx {
121+
symbols: TopSymbolCtx[];
122+
total_symbols: number;
123+
all_symbols_href: string;
124+
}
125+
126+
export interface TopSymbolCtx {
127+
kind: DocNodeKindCtx[];
128+
name: string;
129+
href: string;
130+
}
131+
132+
export interface ModuleDocCtx {
133+
deprecated: string | null;
134+
sections: SymbolContentCtx;
135+
}
136+
137+
export interface DocNodeKindCtx {
138+
kind: string;
139+
char: string;
140+
title: string;
141+
title_lowercase: string;
142+
title_plural: string;
143+
}
144+
145+
export interface SymbolContentCtx {
146+
id: string;
147+
docs: string | null;
148+
sections: SectionCtx[];
149+
}
150+
151+
export interface SectionCtx {
152+
header: SectionHeaderCtx;
153+
content: SectionContentCtx;
154+
}
155+
156+
export interface SectionHeaderCtx {
157+
title: string;
158+
anchor: AnchorCtx;
159+
href: string | null;
160+
doc: string | null;
161+
}
162+
163+
export interface AnchorCtx {
164+
id: string;
165+
}
166+
167+
export interface SymbolGroupCtx {
168+
name: string;
169+
symbols: SymbolCtx[];
170+
}
171+
172+
export interface SymbolCtx {
173+
kind: DocNodeKindCtx;
174+
usage: UsagesCtx | null;
175+
tags: Tag[];
176+
subtitle: DocBlockSubtitleCtx | null;
177+
content: SymbolInnerCtx[];
178+
deprecated: string | null;
179+
source_href: string | null;
180+
}
181+
182+
export type DocBlockSubtitleCtx =
183+
| DocBlockSubtitleClassCtx
184+
| DocBlockSubtitleInterfaceCtx;
185+
186+
export interface DocBlockSubtitleClassCtx {
187+
kind: "class";
188+
value: DocBlockSubtitleClassValueCtx;
189+
}
190+
export interface DocBlockSubtitleClassValueCtx {
191+
implements: string[] | null;
192+
extends: DocBlockClassSubtitleExtendsCtx | null;
193+
}
194+
195+
export interface DocBlockClassSubtitleExtendsCtx {
196+
href: string | null;
197+
symbol: string;
198+
type_args: string;
199+
}
200+
201+
export interface DocBlockSubtitleInterfaceCtx {
202+
kind: "interface";
203+
value: DocBlockSubtitleInterfaceValueCtx;
204+
}
205+
206+
export interface DocBlockSubtitleInterfaceValueCtx {
207+
extends: string[];
208+
}
209+
210+
export type SymbolInnerCtx = SymbolInnerFunctionCtx | SymbolInnerOtherCtx;
211+
212+
export interface SymbolInnerFunctionCtx {
213+
kind: "function";
214+
value: FunctionCtx;
215+
}
216+
217+
export interface SymbolInnerOtherCtx {
218+
kind: "other";
219+
value: SymbolContentCtx;
220+
}
221+
222+
export interface FunctionCtx {
223+
functions: OverloadRenderCtx[];
224+
}
225+
226+
export interface OverloadRenderCtx {
227+
id: string;
228+
anchor: AnchorCtx;
229+
name: string;
230+
summary: string;
231+
deprecated: string | null;
232+
content: SymbolContentCtx;
233+
}
234+
235+
export type SectionContentCtx =
236+
| SectionContentDocEntryCtx
237+
| SectionContentExampleCtx
238+
| SectionContentIndexSignatureCtx
239+
| SectionContentNamespaceSectionCtx
240+
| SectionContentNamespaceSeeCtx
241+
| SectionContentEmptyCtx;
242+
243+
export interface SectionContentDocEntryCtx {
244+
kind: "doc_entry";
245+
content: DocEntryCtx[];
246+
}
247+
248+
export interface SectionContentExampleCtx {
249+
kind: "example";
250+
content: ExampleCtx[];
251+
}
252+
253+
export interface SectionContentIndexSignatureCtx {
254+
kind: "index_signature";
255+
content: IndexSignatureCtx[];
256+
}
257+
258+
export interface SectionContentNamespaceSectionCtx {
259+
kind: "namespace_section";
260+
content: NamespaceNodeCtx[];
261+
}
262+
263+
export interface SectionContentNamespaceSeeCtx {
264+
kind: "see";
265+
content: string[];
266+
}
267+
268+
export interface SectionContentEmptyCtx {
269+
kind: "empty";
270+
}
271+
272+
export interface DocEntryCtx {
273+
id: string;
274+
name: string | null;
275+
name_href: string | null;
276+
content: string;
277+
anchor: AnchorCtx;
278+
tags: Tag[];
279+
js_doc: string | null;
280+
source_href: string | null;
281+
}
282+
283+
export interface ExampleCtx {
284+
anchor: AnchorCtx;
285+
id: string;
286+
title: string;
287+
markdown_title: string;
288+
markdown_body: string;
289+
}
290+
291+
export interface IndexSignatureCtx {
292+
id: string;
293+
anchor: AnchorCtx;
294+
readonly: boolean;
295+
params: string;
296+
ts_type: string;
297+
source_href: string | null;
298+
}
299+
300+
export interface NamespaceNodeCtx {
301+
id: string;
302+
anchor: AnchorCtx;
303+
tags: Tag[];
304+
doc_node_kind_ctx: DocNodeKindCtx[];
305+
href: string;
306+
name: string;
307+
docs: string | null;
308+
deprecated: boolean;
309+
subitems: NamespaceNodeSubItemCtx[];
310+
}
311+
312+
export interface NamespaceNodeSubItemCtx {
313+
title: string;
314+
href: string;
315+
}
316+
317+
export type Tag =
318+
| TagNew
319+
| TagAbstract
320+
| TagDeprecated
321+
| TagWriteonly
322+
| TagReadonly
323+
| TagProtected
324+
| TagPrivate
325+
| TagOptional
326+
| TagUnstable
327+
| TagPermissions
328+
| TagOther;
329+
330+
export interface TagNew {
331+
kind: "new";
332+
}
333+
334+
export interface TagAbstract {
335+
kind: "abstract";
336+
}
337+
338+
export interface TagDeprecated {
339+
kind: "deprecated";
340+
}
341+
342+
export interface TagWriteonly {
343+
kind: "writeonly";
344+
}
345+
346+
export interface TagReadonly {
347+
kind: "readonly";
348+
}
349+
350+
export interface TagProtected {
351+
kind: "protected";
352+
}
353+
354+
export interface TagPrivate {
355+
kind: "private";
356+
}
357+
358+
export interface TagOptional {
359+
kind: "optional";
360+
}
361+
362+
export interface TagUnstable {
363+
kind: "unstable";
364+
}
365+
366+
export interface TagPermissions {
367+
kind: "permissions";
368+
value: string[];
369+
}
370+
371+
export interface TagOther {
372+
kind: "other";
373+
value: string;
374+
}

0 commit comments

Comments
 (0)