Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed May 21, 2024
1 parent fdf5c8c commit b9047d1
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/html/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn usage_to_md(
doc_nodes: &[DocNodeWithContext],
url: &str,
) -> String {
let usage = if let UrlResolveKind::Symbol { symbol, file } =
let usage = if let UrlResolveKind::Symbol { symbol, file: _ } =
ctx.get_current_resolve()
{
let mut parts = symbol.split('.').collect::<Vec<&str>>();
Expand Down
1 change: 1 addition & 0 deletions tests/html_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ async fn html_doc_files_rewrite() {
"./~/Hello.html",
"./~/Hello.world.html",
"./~/index.html",
"foo/~/default.html",
"foo/~/index.html",
"foo/~/x.html",
"fuse.js",
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/html_test__html_doc_files_rewrite-16.snap
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Type Aliases</h2></div><div class="namespaceSection"><div class="namespaceItem"
<span class="hover:bg-Interface/15">Hello</span>
</a>
</li></ul><a class="flex items-center gap-0.5" href="..&#x2F;.&#x2F;all_symbols.html">
<span class="leading-none">view all 6 symbols</span><svg
<span class="leading-none">view all 7 symbols</span><svg
width="16"
height="16"
viewBox="0 0 16 16"
Expand Down
35 changes: 34 additions & 1 deletion tests/snapshots/html_test__html_doc_files_rewrite-17.snap
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,39 @@ Functions</h2></div><div class="namespaceSection"><div class="namespaceItem" ><d
</div>
</div></div>
</section>
<section class="section" id="Variables">
<div>
<h2 class="anchorable mb-1"><a href="#Variables" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
width="16"
height="16"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clip-path="url(#clip0_1081_1237)">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M6.80328 2.8656C6.68736 2.99 6.62425 3.15454 6.62725 3.32456C6.63025 3.49457 6.69913 3.65678 6.81936 3.77702C6.9396 3.89725 7.10181 3.96613 7.27182 3.96913C7.44184 3.97213 7.60638 3.90902 7.73078 3.7931L8.82453 2.69935C8.98712 2.53676 9.18015 2.40778 9.39259 2.31978C9.60503 2.23179 9.83272 2.1865 10.0627 2.1865C10.2926 2.1865 10.5203 2.23179 10.7327 2.31978C10.9452 2.40778 11.1382 2.53676 11.3008 2.69935C11.4634 2.86194 11.5923 3.05497 11.6803 3.2674C11.7683 3.47984 11.8136 3.70753 11.8136 3.93747C11.8136 4.16741 11.7683 4.3951 11.6803 4.60754C11.5923 4.81998 11.4634 5.013 11.3008 5.1756L9.11328 7.3631C8.95075 7.52581 8.75775 7.65488 8.5453 7.74295C8.33285 7.83102 8.10513 7.87635 7.87516 7.87635C7.64518 7.87635 7.41746 7.83102 7.20501 7.74295C6.99256 7.65488 6.79956 7.52581 6.63703 7.3631C6.51263 7.24718 6.34809 7.18407 6.17807 7.18707C6.00806 7.19007 5.84585 7.25894 5.72561 7.37918C5.60538 7.49942 5.5365 7.66163 5.5335 7.83164C5.5305 8.00165 5.59361 8.1662 5.70953 8.2906C5.99391 8.57501 6.33154 8.80062 6.70312 8.95455C7.0747 9.10847 7.47296 9.18769 7.87516 9.18769C8.27736 9.18769 8.67562 9.10847 9.0472 8.95455C9.41878 8.80062 9.7564 8.57501 10.0408 8.2906L12.2283 6.1031C12.8026 5.52874 13.1253 4.74974 13.1253 3.93747C13.1253 3.12521 12.8026 2.34621 12.2283 1.77185C11.6539 1.19749 10.8749 0.874817 10.0627 0.874817C9.25039 0.874817 8.47139 1.19749 7.89703 1.77185L6.80328 2.8656ZM2.69953 11.3006C2.53682 11.1381 2.40774 10.9451 2.31968 10.7326C2.23161 10.5202 2.18628 10.2924 2.18628 10.0625C2.18628 9.8325 2.23161 9.60477 2.31968 9.39233C2.40774 9.17988 2.53682 8.98688 2.69953 8.82435L4.88703 6.63685C5.04956 6.47414 5.24256 6.34506 5.45501 6.25699C5.66746 6.16893 5.89518 6.1236 6.12516 6.1236C6.35513 6.1236 6.58285 6.16893 6.7953 6.25699C7.00775 6.34506 7.20075 6.47414 7.36328 6.63685C7.48768 6.75277 7.65223 6.81588 7.82224 6.81288C7.99225 6.80988 8.15446 6.741 8.2747 6.62077C8.39494 6.50053 8.46381 6.33832 8.46681 6.1683C8.46981 5.99829 8.4067 5.83375 8.29078 5.70935C8.0064 5.42494 7.66878 5.19933 7.2972 5.0454C6.92562 4.89148 6.52736 4.81225 6.12516 4.81225C5.72296 4.81225 5.3247 4.89148 4.95312 5.0454C4.58154 5.19933 4.24391 5.42494 3.95953 5.70935L1.77203 7.89685C1.19767 8.47121 0.875 9.25021 0.875 10.0625C0.875 10.8747 1.19767 11.6537 1.77203 12.2281C2.34639 12.8025 3.12539 13.1251 3.93766 13.1251C4.74992 13.1251 5.52892 12.8025 6.10328 12.2281L7.19703 11.1343C7.31295 11.0099 7.37606 10.8454 7.37306 10.6754C7.37006 10.5054 7.30119 10.3432 7.18095 10.2229C7.06071 10.1027 6.8985 10.0338 6.72849 10.0308C6.55848 10.0278 6.39393 10.0909 6.26953 10.2068L5.17578 11.3006C5.01325 11.4633 4.82025 11.5924 4.6078 11.6805C4.39535 11.7685 4.16763 11.8138 3.93766 11.8138C3.70768 11.8138 3.47996 11.7685 3.26751 11.6805C3.05506 11.5924 2.86206 11.4633 2.69953 11.3006Z"
fill="currentColor"
/>
</g>
<defs>
<clipPath id="clip0_1081_1237">
<rect width="14" height="14" fill="white" />
</clipPath>
</defs>
</svg>
</a>
Variables</h2></div><div class="namespaceSection"><div class="namespaceItem" ><div class="docNodeKindIcon"><div class="text-Variable bg-Variable/15" title="Variable">v</div></div>
<div class="namespaceItemContent">
<a href="..&#x2F;..&#x2F;.&#x2F;foo&#x2F;~&#x2F;default.html" title="default">default</a>

<div><div class="markdown_summary"><p>The default export item.</p>
</div></div>
</div>
</div></div>
</section>
</div>
</div>
</section>
Expand Down Expand Up @@ -108,7 +141,7 @@ Functions</h2></div><div class="namespaceSection"><div class="namespaceItem" ><d
<span class="hover:bg-Interface/15">Hello</span>
</a>
</li></ul><a class="flex items-center gap-0.5" href="..&#x2F;..&#x2F;.&#x2F;all_symbols.html">
<span class="leading-none">view all 6 symbols</span><svg
<span class="leading-none">view all 7 symbols</span><svg
width="16"
height="16"
viewBox="0 0 16 16"
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/html_test__html_doc_files_rewrite-2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ expression: "files.get(\"./index.html\").unwrap()"
<span class="hover:bg-Interface/15">Hello</span>
</a>
</li></ul><a class="flex items-center gap-0.5" href=".&#x2F;all_symbols.html">
<span class="leading-none">view all 6 symbols</span><svg
<span class="leading-none">view all 7 symbols</span><svg
width="16"
height="16"
viewBox="0 0 16 16"
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/html_test__html_doc_files_rewrite-23.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ source: tests/html_test.rs
expression: "files.get(\"search_index.js\").unwrap()"
---
(function () {
window.DENO_DOC_SEARCH_INDEX = {"nodes":[{"kind":["class"],"name":"A","file":".","location":{"filename":".","line":45,"col":0,"byteIndex":741},"declarationKind":"private","deprecated":false},{"kind":["class"],"name":"B","file":".","location":{"filename":".","line":48,"col":0,"byteIndex":770},"declarationKind":"export","deprecated":false},{"kind":["class"],"name":"Bar","file":".","location":{"filename":".","line":31,"col":0,"byteIndex":588},"declarationKind":"export","deprecated":false},{"kind":["typeAlias"],"name":"Baz","file":".","location":{"filename":".","line":41,"col":0,"byteIndex":702},"declarationKind":"export","deprecated":false},{"kind":["class"],"name":"Foo","file":".","location":{"filename":".","line":25,"col":0,"byteIndex":488},"declarationKind":"export","deprecated":false},{"kind":["class"],"name":"Foobar","file":".","location":{"filename":".","line":34,"col":0,"byteIndex":622},"declarationKind":"export","deprecated":false},{"kind":["interface"],"name":"Hello","file":".","location":{"filename":".","line":37,"col":0,"byteIndex":655},"declarationKind":"export","deprecated":false},{"kind":["function"],"name":"x","file":"foo","location":{"filename":"foo","line":1,"col":0,"byteIndex":0},"declarationKind":"export","deprecated":false}]};
window.DENO_DOC_SEARCH_INDEX = {"nodes":[{"kind":["class"],"name":"A","file":".","location":{"filename":".","line":45,"col":0,"byteIndex":741},"declarationKind":"private","deprecated":false},{"kind":["class"],"name":"B","file":".","location":{"filename":".","line":48,"col":0,"byteIndex":770},"declarationKind":"export","deprecated":false},{"kind":["class"],"name":"Bar","file":".","location":{"filename":".","line":31,"col":0,"byteIndex":588},"declarationKind":"export","deprecated":false},{"kind":["typeAlias"],"name":"Baz","file":".","location":{"filename":".","line":41,"col":0,"byteIndex":702},"declarationKind":"export","deprecated":false},{"kind":["class"],"name":"Foo","file":".","location":{"filename":".","line":25,"col":0,"byteIndex":488},"declarationKind":"export","deprecated":false},{"kind":["class"],"name":"Foobar","file":".","location":{"filename":".","line":34,"col":0,"byteIndex":622},"declarationKind":"export","deprecated":false},{"kind":["interface"],"name":"Hello","file":".","location":{"filename":".","line":37,"col":0,"byteIndex":655},"declarationKind":"export","deprecated":false},{"kind":["variable"],"name":"default","file":"foo","location":{"filename":"foo","line":7,"col":6,"byteIndex":167},"declarationKind":"export","deprecated":false},{"kind":["function"],"name":"x","file":"foo","location":{"filename":"foo","line":1,"col":0,"byteIndex":0},"declarationKind":"export","deprecated":false}]};
})()
9 changes: 8 additions & 1 deletion tests/snapshots/html_test__html_doc_files_rewrite.snap
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ expression: "files.get(\"./all_symbols.html\").unwrap()"
</defs>
</svg>
</a>
<a href=".&#x2F;.&#x2F;foo&#x2F;~&#x2F;index.html" class="contextLink">foo</a></h2></div><div class="namespaceSection"><div class="namespaceItem" ><div class="docNodeKindIcon"><div class="text-Function bg-Function/15" title="Function">f</div></div>
<a href=".&#x2F;.&#x2F;foo&#x2F;~&#x2F;index.html" class="contextLink">foo</a></h2></div><div class="namespaceSection"><div class="namespaceItem" ><div class="docNodeKindIcon"><div class="text-Variable bg-Variable/15" title="Variable">v</div></div>
<div class="namespaceItemContent">
<a href=".&#x2F;.&#x2F;foo&#x2F;~&#x2F;default.html" title="default">default</a>

<div><div class="markdown_summary"><p>The default export item.</p>
</div></div>
</div>
</div><div class="namespaceItem" ><div class="docNodeKindIcon"><div class="text-Function bg-Function/15" title="Function">f</div></div>
<div class="namespaceItemContent">
<a href=".&#x2F;.&#x2F;foo&#x2F;~&#x2F;x.html" title="x">x</a>

Expand Down
32 changes: 32 additions & 0 deletions tests/testdata/module_doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,38 @@
}
]
}
},
{
"header": {
"title": "Variables",
"anchor": {
"id": "Variables"
},
"href": null,
"doc": null
},
"content": {
"kind": "namespace_section",
"content": [
{
"tags": [],
"doc_node_kind_ctx": [
{
"kind": "Variable",
"char": "v",
"title": "Variable",
"title_lowercase": "variable",
"title_plural": "Variables"
}
],
"origin_name": null,
"href": "../.././foo/~/default.html",
"name": "default",
"docs": "<div class=\"markdown_summary\"><p>The default export item.</p>\n</div>",
"deprecated": false
}
]
}
}
]
}
Expand Down
4 changes: 0 additions & 4 deletions tests/testdata/multiple/a.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,3 @@ class A {}

/** @internal */
export class B {}

/** A module's default export item. */
const default_: number = 0;
export { default_ as default }
7 changes: 7 additions & 0 deletions tests/testdata/multiple/b.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export function x(_n = 0) {}

/** The default export item.
*
* This item reproduces the issue reported in {@link https://github.com/jsr-io/jsr/issues/459}
*/
const default_: number = 0;
export { default_ as default }
105 changes: 105 additions & 0 deletions tests/testdata/symbol_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,111 @@
"document_navigation": "<ul><li><a href=\"#type\" title=\"Type\">Type</a></li></ul>"
}
},
{
"html_head_ctx": {
"title": "default - documentation",
"current_file": "foo",
"stylesheet_url": "../../styles.css",
"page_stylesheet_url": "../../page.css",
"url_search_index": "../../search_index.js",
"script_js": "../../script.js",
"fuse_js": "../../fuse.js",
"url_search": "../../search.js"
},
"symbol_group_ctx": {
"name": "default",
"symbols": [
{
"kind": {
"kind": "Variable",
"char": "v",
"title": "Variable",
"title_lowercase": "variable",
"title_plural": "Variables"
},
"tags": [],
"subtitle": null,
"content": [
{
"kind": "other",
"value": {
"id": "",
"docs": "<div class=\"markdown\"><p>The default export item.</p>\n<p>This item reproduces the issue reported in <a href=\"https://github.com/jsr-io/jsr/issues/459\" rel=\"nofollow\">https://github.com/jsr-io/jsr/issues/459</a></p>\n</div>",
"sections": [
{
"header": {
"title": "Type",
"anchor": {
"id": "type"
},
"href": null,
"doc": null
},
"content": {
"kind": "doc_entry",
"content": [
{
"id": "variable_default",
"name": "",
"name_href": null,
"content": "<span>number</span>",
"anchor": {
"id": "variable_default"
},
"tags": [],
"js_doc": null,
"source_href": null
}
]
}
}
]
}
}
],
"deprecated": null,
"source_href": null
}
]
},
"breadcrumbs_ctx": {
"parts": [
{
"name": "index",
"href": "../../",
"is_symbol": false,
"is_first_symbol": false
},
{
"name": "foo",
"href": "../.././foo/~/index.html",
"is_symbol": false,
"is_first_symbol": false
},
{
"name": "default",
"href": "../.././foo/~/default.html",
"is_symbol": true,
"is_first_symbol": true
}
]
},
"toc_ctx": {
"usages": {
"usages": [
{
"name": "",
"content": "<div class=\"markdown\"><pre class=\"highlight\"><code>import module from \"foo\";\n</code><button class=\"context_button\" data-copy=\"import module from &quot;foo&quot;;\n\"><svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect x=\"2\" y=\"2\" width=\"7\" height=\"7\" fill=\"none\"></rect>\n<rect x=\"6\" y=\"6\" width=\"7\" height=\"7\" fill=\"none\"></rect>\n<path d=\"M1.55566 2.7C1.55566 2.03726 2.09292 1.5 2.75566 1.5H8.75566C9.41841 1.5 9.95566 2.03726 9.95566 2.7V5.1H12.3557C13.0184 5.1 13.5557 5.63726 13.5557 6.3V12.3C13.5557 12.9627 13.0184 13.5 12.3557 13.5H6.35566C5.69292 13.5 5.15566 12.9627 5.15566 12.3V9.9H2.75566C2.09292 9.9 1.55566 9.36274 1.55566 8.7V2.7ZM6.35566 9.9V12.3H12.3557V6.3H9.95566V8.7C9.95566 9.36274 9.41841 9.9 8.75566 9.9H6.35566ZM8.75566 8.7V2.7H2.75566V8.7H8.75566Z\" fill=\"#232323\"></path>\n</svg>\n</button><code></code></pre>\n</div>",
"icon": null,
"additional_css": ""
}
],
"composed": false
},
"top_symbols": null,
"document_navigation": "<ul><li><a href=\"#type\" title=\"Type\">Type</a></li></ul>"
}
},
{
"html_head_ctx": {
"title": "x - documentation",
Expand Down
15 changes: 15 additions & 0 deletions tests/testdata/symbol_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@
"declarationKind": "export",
"deprecated": false
},
{
"kind": [
"variable"
],
"name": "default",
"file": "foo",
"location": {
"filename": "foo",
"line": 7,
"col": 6,
"byteIndex": 167
},
"declarationKind": "export",
"deprecated": false
},
{
"kind": [
"function"
Expand Down

0 comments on commit b9047d1

Please sign in to comment.