Skip to content

Commit

Permalink
fix(html): store original name of methods (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats authored Oct 9, 2024
1 parent e701be4 commit 3aee62c
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,14 @@ impl DocNodeWithContext {
is_static: bool,
method_kind: MethodKind,
) -> Self {
let original_name = method_doc_node.name.clone();
method_doc_node.name =
qualify_drilldown_name(self.get_name(), &method_doc_node.name, is_static)
.into_boxed_str();
method_doc_node.declaration_kind = self.declaration_kind;

let mut new_node = self.create_child(Rc::new(method_doc_node));
new_node.drilldown_name = Some(original_name);
new_node.kind_with_drilldown =
DocNodeKindWithDrilldown::Method(method_kind);
new_node
Expand Down
1 change: 1 addition & 0 deletions tests/html_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ async fn html_doc_files_rewrite() {
"./~/Foo.prototype.\"><img src=x onerror=alert(1)>.html",
"./~/Foo.prototype.foo.html",
"./~/Foo.prototype.html",
"./~/Foo.prototype.test.html",
"./~/Foobar.html",
"./~/Foobar.prototype.html",
"./~/Hello.html",
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/html_test__html_doc_files_rewrite-21.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":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"A","file":".","doc":"","location":{"filename":"default","line":62,"col":0,"byteIndex":1053},"url":"././~/A.html","category":"","declarationKind":"private","deprecated":false},{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"B","file":".","doc":"","location":{"filename":"default","line":65,"col":0,"byteIndex":1082},"url":"././~/B.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"Bar","file":".","doc":"> Some quote in bar docs\n> This quote part is ignored\n> when getting the title of this doc\n\nBar docs","location":{"filename":"default","line":38,"col":0,"byteIndex":727},"url":"././~/Bar.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"TypeAlias","char":"T","title":"Type Alias","title_lowercase":"type alias","title_plural":"Type Aliases"}],"name":"Baz","file":".","doc":"","location":{"filename":"default","line":58,"col":0,"byteIndex":1014},"url":"././~/Baz.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Baz.foo","file":".","doc":"","location":{"filename":"default","line":59,"col":2,"byteIndex":1036},"url":"././~/Baz.foo.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"Foo","file":".","doc":"some Foo docs {@linkcode Bar}","location":{"filename":"default","line":25,"col":0,"byteIndex":504},"url":"././~/Foo.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Foo.bar","file":".","doc":"","location":{"filename":"default","line":26,"col":2,"byteIndex":525},"url":"././~/Foo.bar.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Foo.prototype.foo","file":".","doc":"","location":{"filename":"default","line":27,"col":2,"byteIndex":549},"url":"././~/Foo.prototype.foo.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Foo.prototype.\"&gt;&lt;img src=x onerror=alert(1)&gt;","file":".","doc":"","location":{"filename":"default","line":28,"col":2,"byteIndex":563},"url":"././~/Foo.prototype.\"><img src=x onerror=alert(1)>.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"Foobar","file":".","doc":"```ts\n// This code block is ignored when getting the title of this doc\nconst foobar = new Foobar();\n```\n\nFoobar docs\n","location":{"filename":"default","line":51,"col":0,"byteIndex":934},"url":"././~/Foobar.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Interface","char":"I","title":"Interface","title_lowercase":"interface","title_plural":"Interfaces"}],"name":"Hello","file":".","doc":"","location":{"filename":"default","line":54,"col":0,"byteIndex":967},"url":"././~/Hello.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Hello.world","file":".","doc":"","location":{"filename":"default","line":55,"col":2,"byteIndex":994},"url":"././~/Hello.world.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"}],"name":"c","file":".","doc":"","location":{"filename":"default","line":74,"col":13,"byteIndex":1245},"url":"././~/c.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"}],"name":"d","file":".","doc":"","location":{"filename":"default","line":79,"col":0,"byteIndex":1302},"url":"././~/d.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"},{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"},{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"}],"name":"qaz","file":".","doc":"","location":{"filename":"default","line":70,"col":0,"byteIndex":1124},"url":"././~/qaz.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Variable","char":"v","title":"Variable","title_lowercase":"variable","title_plural":"Variables"}],"name":"default","file":"foo","doc":"The default export item.\n\nThis item reproduces the issue reported in {@link https://github.com/jsr-io/jsr/issues/459}","location":{"filename":"foo","line":11,"col":6,"byteIndex":191},"url":"./foo/~/default.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"}],"name":"x","file":"foo","doc":"","location":{"filename":"foo","line":5,"col":0,"byteIndex":24},"url":"./foo/~/x.html","category":"","declarationKind":"export","deprecated":false}]};
window.DENO_DOC_SEARCH_INDEX = {"nodes":[{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"A","file":".","doc":"","location":{"filename":"default","line":63,"col":0,"byteIndex":1065},"url":"././~/A.html","category":"","declarationKind":"private","deprecated":false},{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"B","file":".","doc":"","location":{"filename":"default","line":66,"col":0,"byteIndex":1094},"url":"././~/B.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"Bar","file":".","doc":"> Some quote in bar docs\n> This quote part is ignored\n> when getting the title of this doc\n\nBar docs","location":{"filename":"default","line":39,"col":0,"byteIndex":739},"url":"././~/Bar.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"TypeAlias","char":"T","title":"Type Alias","title_lowercase":"type alias","title_plural":"Type Aliases"}],"name":"Baz","file":".","doc":"","location":{"filename":"default","line":59,"col":0,"byteIndex":1026},"url":"././~/Baz.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Baz.foo","file":".","doc":"","location":{"filename":"default","line":60,"col":2,"byteIndex":1048},"url":"././~/Baz.foo.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"Foo","file":".","doc":"some Foo docs {@linkcode Bar}","location":{"filename":"default","line":25,"col":0,"byteIndex":504},"url":"././~/Foo.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Method","char":"m","title":"Method","title_lowercase":"method","title_plural":"Methods"}],"name":"Foo.prototype.test","file":".","doc":"","location":{"filename":"default","line":29,"col":2,"byteIndex":603},"url":"././~/Foo.prototype.test.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Foo.bar","file":".","doc":"","location":{"filename":"default","line":26,"col":2,"byteIndex":525},"url":"././~/Foo.bar.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Foo.prototype.foo","file":".","doc":"","location":{"filename":"default","line":27,"col":2,"byteIndex":549},"url":"././~/Foo.prototype.foo.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Foo.prototype.\"&gt;&lt;img src=x onerror=alert(1)&gt;","file":".","doc":"","location":{"filename":"default","line":28,"col":2,"byteIndex":563},"url":"././~/Foo.prototype.\"><img src=x onerror=alert(1)>.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Class","char":"c","title":"Class","title_lowercase":"class","title_plural":"Classes"}],"name":"Foobar","file":".","doc":"```ts\n// This code block is ignored when getting the title of this doc\nconst foobar = new Foobar();\n```\n\nFoobar docs\n","location":{"filename":"default","line":52,"col":0,"byteIndex":946},"url":"././~/Foobar.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Interface","char":"I","title":"Interface","title_lowercase":"interface","title_plural":"Interfaces"}],"name":"Hello","file":".","doc":"","location":{"filename":"default","line":55,"col":0,"byteIndex":979},"url":"././~/Hello.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Property","char":"p","title":"Property","title_lowercase":"property","title_plural":"Properties"}],"name":"Hello.world","file":".","doc":"","location":{"filename":"default","line":56,"col":2,"byteIndex":1006},"url":"././~/Hello.world.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"}],"name":"c","file":".","doc":"","location":{"filename":"default","line":75,"col":13,"byteIndex":1257},"url":"././~/c.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"}],"name":"d","file":".","doc":"","location":{"filename":"default","line":80,"col":0,"byteIndex":1314},"url":"././~/d.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"},{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"},{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"}],"name":"qaz","file":".","doc":"","location":{"filename":"default","line":71,"col":0,"byteIndex":1136},"url":"././~/qaz.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Variable","char":"v","title":"Variable","title_lowercase":"variable","title_plural":"Variables"}],"name":"default","file":"foo","doc":"The default export item.\n\nThis item reproduces the issue reported in {@link https://github.com/jsr-io/jsr/issues/459}","location":{"filename":"foo","line":11,"col":6,"byteIndex":191},"url":"./foo/~/default.html","category":"","declarationKind":"export","deprecated":false},{"kind":[{"kind":"Function","char":"f","title":"Function","title_lowercase":"function","title_plural":"Functions"}],"name":"x","file":"foo","doc":"","location":{"filename":"foo","line":5,"col":0,"byteIndex":24},"url":"./foo/~/x.html","category":"","declarationKind":"export","deprecated":false}]};
})()
Loading

0 comments on commit 3aee62c

Please sign in to comment.