Skip to content

Commit d899454

Browse files
committed
fix(html): minor cleanup and fixes
1 parent 7419a2e commit d899454

14 files changed

+129
-164
lines changed

examples/ddoc/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use clap::App;
44
use clap::Arg;
55
use deno_doc::find_nodes_by_name_recursively;
66
use deno_doc::html::HrefResolver;
7-
use deno_doc::html::ShortPath;
87
use deno_doc::html::UrlResolveKind;
98
use deno_doc::DocNodeKind;
109
use deno_doc::DocParser;
@@ -195,8 +194,10 @@ impl HrefResolver for EmptyResolver {
195194
None
196195
}
197196

198-
fn resolve_usage(&self, current_file: &ShortPath) -> Option<String> {
199-
Some(current_file.specifier.to_string())
197+
fn resolve_usage(&self, current_resolve: UrlResolveKind) -> Option<String> {
198+
current_resolve
199+
.get_file()
200+
.map(|current_file| current_file.specifier.to_string())
200201
}
201202

202203
fn resolve_source(&self, location: &deno_doc::Location) -> Option<String> {

src/html/jsdoc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::render_context::RenderContext;
22
use super::util::*;
33
use crate::html::usage::UsagesCtx;
4-
use crate::html::FileMode;
54
use crate::html::ShortPath;
65
use crate::js_doc::JsDoc;
76
use crate::js_doc::JsDocTag;
@@ -602,7 +601,7 @@ impl ModuleDocCtx {
602601
(None, None, None)
603602
};
604603

605-
if short_path.is_main && render_ctx.ctx.file_mode == FileMode::SingleDts {
604+
if !short_path.is_main {
606605
let partitions_by_kind =
607606
super::partition::partition_nodes_by_kind(module_doc_nodes, true);
608607

src/html/render_context.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl<'ctx> RenderContext<'ctx> {
221221
is_first_symbol: false,
222222
}];
223223

224-
if file.is_main {
224+
if !file.is_main {
225225
parts.push(BreadcrumbCtx {
226226
name: file.display_name(),
227227
href: self
@@ -320,11 +320,10 @@ mod test {
320320
Some(format!("{src}/{}", symbol.join(".")))
321321
}
322322

323-
fn resolve_usage(
324-
&self,
325-
current_file: &crate::html::ShortPath,
326-
) -> Option<String> {
327-
Some(current_file.specifier.to_string())
323+
fn resolve_usage(&self, current_resolve: UrlResolveKind) -> Option<String> {
324+
current_resolve
325+
.get_file()
326+
.map(|current_file| current_file.specifier.to_string())
328327
}
329328

330329
fn resolve_source(&self, location: &Location) -> Option<String> {

src/html/templates/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ summary::-webkit-details-marker {
121121
}
122122

123123
.namespaceSection {
124-
@apply grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-y-3 md:gap-x-3 md:gap-y-8;
124+
@apply grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-y-3 md:gap-x-8 md:gap-y-8;
125125
.namespaceItem {
126126
@apply flex gap-x-2.5;
127127

src/html/templates/styles.gen.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/html/usage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl UsagesCtx {
130130
let url = ctx
131131
.ctx
132132
.href_resolver
133-
.resolve_usage(ctx.get_current_resolve().get_file()?)?;
133+
.resolve_usage(ctx.get_current_resolve())?;
134134

135135
if let Some(usage_composer) = &ctx.ctx.usage_composer {
136136
let usages = usage_composer(ctx, doc_nodes, url);

src/html/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub trait HrefResolver {
225225
-> Option<String>;
226226

227227
/// Resolve the URL used in "usage" blocks.
228-
fn resolve_usage(&self, current_file: &ShortPath) -> Option<String>;
228+
fn resolve_usage(&self, current_resolve: UrlResolveKind) -> Option<String>;
229229

230230
/// Resolve the URL used in source code link buttons.
231231
fn resolve_source(&self, location: &crate::Location) -> Option<String>;

tests/html_test.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ impl HrefResolver for EmptyResolver {
6666
None
6767
}
6868

69-
fn resolve_usage(&self, current_file: &ShortPath) -> Option<String> {
70-
Some(current_file.path.clone())
69+
fn resolve_usage(&self, current_resolve: UrlResolveKind) -> Option<String> {
70+
current_resolve
71+
.get_file()
72+
.map(|current_file| current_file.path.to_string())
7173
}
7274

7375
fn resolve_source(&self, _location: &deno_doc::Location) -> Option<String> {

tests/testdata/module_doc-syntect.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,37 @@
3434
"sections": {
3535
"id": "module_doc",
3636
"docs": null,
37-
"sections": []
37+
"sections": [
38+
{
39+
"header": {
40+
"title": "Functions",
41+
"href": null,
42+
"doc": null
43+
},
44+
"content": {
45+
"kind": "namespace_section",
46+
"content": [
47+
{
48+
"tags": [],
49+
"doc_node_kind_ctx": [
50+
{
51+
"kind": "Function",
52+
"char": "f",
53+
"title": "Function",
54+
"title_lowercase": "function",
55+
"title_plural": "Functions"
56+
}
57+
],
58+
"origin_name": null,
59+
"href": "../.././foo/~/x.html",
60+
"name": "x",
61+
"docs": null,
62+
"deprecated": false
63+
}
64+
]
65+
}
66+
}
67+
]
3868
}
3969
}
4070
]

tests/testdata/module_doc-tree-sitter.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,37 @@
3434
"sections": {
3535
"id": "module_doc",
3636
"docs": null,
37-
"sections": []
37+
"sections": [
38+
{
39+
"header": {
40+
"title": "Functions",
41+
"href": null,
42+
"doc": null
43+
},
44+
"content": {
45+
"kind": "namespace_section",
46+
"content": [
47+
{
48+
"tags": [],
49+
"doc_node_kind_ctx": [
50+
{
51+
"kind": "Function",
52+
"char": "f",
53+
"title": "Function",
54+
"title_lowercase": "function",
55+
"title_plural": "Functions"
56+
}
57+
],
58+
"origin_name": null,
59+
"href": "../.././foo/~/x.html",
60+
"name": "x",
61+
"docs": null,
62+
"deprecated": false
63+
}
64+
]
65+
}
66+
}
67+
]
3868
}
3969
}
4070
]

tests/testdata/module_doc.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,37 @@
3434
"sections": {
3535
"id": "module_doc",
3636
"docs": null,
37-
"sections": []
37+
"sections": [
38+
{
39+
"header": {
40+
"title": "Functions",
41+
"href": null,
42+
"doc": null
43+
},
44+
"content": {
45+
"kind": "namespace_section",
46+
"content": [
47+
{
48+
"tags": [],
49+
"doc_node_kind_ctx": [
50+
{
51+
"kind": "Function",
52+
"char": "f",
53+
"title": "Function",
54+
"title_lowercase": "function",
55+
"title_plural": "Functions"
56+
}
57+
],
58+
"origin_name": null,
59+
"href": "../.././foo/~/x.html",
60+
"name": "x",
61+
"docs": null,
62+
"deprecated": false
63+
}
64+
]
65+
}
66+
}
67+
]
3868
}
3969
}
4070
]

tests/testdata/symbol_group-syntect.json

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@
140140
"is_symbol": false,
141141
"is_first_symbol": false
142142
},
143-
{
144-
"name": "default",
145-
"href": "../",
146-
"is_symbol": false,
147-
"is_first_symbol": false
148-
},
149143
{
150144
"name": "Bar",
151145
"href": "../././~/Bar.html",
@@ -354,12 +348,6 @@
354348
"is_symbol": false,
355349
"is_first_symbol": false
356350
},
357-
{
358-
"name": "default",
359-
"href": "../",
360-
"is_symbol": false,
361-
"is_first_symbol": false
362-
},
363351
{
364352
"name": "Foo",
365353
"href": "../././~/Foo.html",
@@ -507,12 +495,6 @@
507495
"is_symbol": false,
508496
"is_first_symbol": false
509497
},
510-
{
511-
"name": "default",
512-
"href": "../",
513-
"is_symbol": false,
514-
"is_first_symbol": false
515-
},
516498
{
517499
"name": "Foobar",
518500
"href": "../././~/Foobar.html",
@@ -679,12 +661,6 @@
679661
"is_symbol": false,
680662
"is_first_symbol": false
681663
},
682-
{
683-
"name": "default",
684-
"href": "../",
685-
"is_symbol": false,
686-
"is_first_symbol": false
687-
},
688664
{
689665
"name": "Hello",
690666
"href": "../././~/Hello.html",
@@ -850,12 +826,6 @@
850826
"is_symbol": false,
851827
"is_first_symbol": false
852828
},
853-
{
854-
"name": "default",
855-
"href": "../",
856-
"is_symbol": false,
857-
"is_first_symbol": false
858-
},
859829
{
860830
"name": "Foo",
861831
"href": "../././~/Foo.html",
@@ -1027,12 +997,6 @@
1027997
"is_symbol": false,
1028998
"is_first_symbol": false
1029999
},
1030-
{
1031-
"name": "default",
1032-
"href": "../",
1033-
"is_symbol": false,
1034-
"is_first_symbol": false
1035-
},
10361000
{
10371001
"name": "Foo",
10381002
"href": "../././~/Foo.html",
@@ -1210,12 +1174,6 @@
12101174
"is_symbol": false,
12111175
"is_first_symbol": false
12121176
},
1213-
{
1214-
"name": "default",
1215-
"href": "../",
1216-
"is_symbol": false,
1217-
"is_first_symbol": false
1218-
},
12191177
{
12201178
"name": "Foo",
12211179
"href": "../././~/Foo.html",
@@ -1393,12 +1351,6 @@
13931351
"is_symbol": false,
13941352
"is_first_symbol": false
13951353
},
1396-
{
1397-
"name": "default",
1398-
"href": "../",
1399-
"is_symbol": false,
1400-
"is_first_symbol": false
1401-
},
14021354
{
14031355
"name": "Hello",
14041356
"href": "../././~/Hello.html",
@@ -1564,6 +1516,12 @@
15641516
"is_symbol": false,
15651517
"is_first_symbol": false
15661518
},
1519+
{
1520+
"name": "foo",
1521+
"href": "../.././foo/~/index.html",
1522+
"is_symbol": false,
1523+
"is_first_symbol": false
1524+
},
15671525
{
15681526
"name": "x",
15691527
"href": "../.././foo/~/x.html",

0 commit comments

Comments
 (0)