From c79f23d36902f536987a2a23ec380045fb99b4a9 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Thu, 15 May 2025 23:51:56 +0200 Subject: [PATCH 1/4] fix(html): unified ids --- examples/ddoc/main.rs | 1 + src/html/jsdoc.rs | 74 ++++-- src/html/mod.rs | 5 +- src/html/pages.rs | 20 +- src/html/render_context.rs | 3 +- src/html/search.rs | 58 +++-- src/html/symbols/class.rs | 33 ++- src/html/symbols/enum.rs | 11 +- src/html/symbols/function.rs | 68 ++++-- src/html/symbols/interface.rs | 27 ++- src/html/symbols/mod.rs | 8 +- src/html/symbols/namespace.rs | 43 ++-- src/html/symbols/type_alias.rs | 7 +- src/html/symbols/variable.rs | 7 +- src/html/types.rs | 12 +- src/html/util.rs | 176 ++++++++++++-- tests/html_test.rs | 6 + .../snapshots/html_test__html_doc_dts-14.snap | 2 +- ...html_test__html_doc_files_multiple-16.snap | 6 +- ...html_test__html_doc_files_multiple-23.snap | 10 +- ...html_test__html_doc_files_multiple-28.snap | 6 +- ...html_test__html_doc_files_multiple-30.snap | 10 +- ...html_test__html_doc_files_multiple-33.snap | 6 +- ...html_test__html_doc_files_multiple-36.snap | 6 +- ...html_test__html_doc_files_multiple-40.snap | 6 +- ...html_test__html_doc_files_multiple-41.snap | 10 +- ...html_test__html_doc_files_multiple-47.snap | 6 +- ...html_test__html_doc_files_multiple-51.snap | 6 +- ...html_test__html_doc_files_multiple-55.snap | 6 +- ...html_test__html_doc_files_multiple-57.snap | 22 +- ...html_test__html_doc_files_multiple-58.snap | 22 +- ...html_test__html_doc_files_multiple-59.snap | 10 +- ...html_test__html_doc_files_multiple-61.snap | 6 +- ...html_test__html_doc_files_multiple-63.snap | 6 +- ...html_test__html_doc_files_multiple-65.snap | 6 +- ...html_test__html_doc_files_multiple-69.snap | 6 +- ...html_test__html_doc_files_multiple-73.snap | 2 +- .../html_test__html_doc_files_multiple-9.snap | 6 +- .../html_test__html_doc_files_single-13.snap | 2 +- tests/snapshots/html_test__symbol_group.snap | 224 +++++++++--------- tests/snapshots/html_test__symbol_search.snap | 67 +++++- 41 files changed, 677 insertions(+), 341 deletions(-) diff --git a/examples/ddoc/main.rs b/examples/ddoc/main.rs index 613b718f..16cff213 100644 --- a/examples/ddoc/main.rs +++ b/examples/ddoc/main.rs @@ -275,6 +275,7 @@ fn generate_docs_directory( deno_doc::html::comrak::COMRAK_STYLESHEET_FILENAME ) })), + id_prefix: None, }; let ctx = GenerateCtx::create_basic(options, doc_nodes_by_url)?; let html = deno_doc::html::generate(ctx)?; diff --git a/src/html/jsdoc.rs b/src/html/jsdoc.rs index 6311e78f..55e83a8a 100644 --- a/src/html/jsdoc.rs +++ b/src/html/jsdoc.rs @@ -19,7 +19,11 @@ lazy_static! { regex::Regex::new(r"^\[(\S+)\](?:\.(\S+)|\s|)$").unwrap(); } -fn parse_links<'a>(md: &'a str, ctx: &RenderContext) -> Cow<'a, str> { +fn parse_links<'a>( + md: &'a str, + ctx: &RenderContext, + strip: bool, +) -> Cow<'a, str> { JSDOC_LINK_RE.replace_all(md, |captures: ®ex::Captures| { let code = captures .name("modifier") @@ -111,7 +115,9 @@ fn parse_links<'a>(md: &'a str, ctx: &RenderContext) -> Cow<'a, str> { (title, link) }; - if LINK_RE.is_match(&link) { + if strip { + title + } else if LINK_RE.is_match(&link) { if code { format!("[`{title}`]({link})") } else { @@ -122,7 +128,7 @@ fn parse_links<'a>(md: &'a str, ctx: &RenderContext) -> Cow<'a, str> { if code { format!("`{title}`") } else { - title.to_string() + title } } }) @@ -149,7 +155,7 @@ pub struct MarkdownToHTMLOptions { pub type MarkdownStripper = std::rc::Rc String)>; pub fn strip(render_ctx: &RenderContext, md: &str) -> String { - let md = parse_links(md, render_ctx); + let md = parse_links(md, render_ctx, true); (render_ctx.ctx.markdown_stripper)(&md) } @@ -200,7 +206,7 @@ pub fn markdown_to_html( anchorizer.as_ref(), ); - let md = parse_links(md, render_ctx); + let md = parse_links(md, render_ctx, false); let file = render_ctx.get_current_resolve().get_file().cloned(); @@ -281,7 +287,7 @@ pub(crate) fn jsdoc_examples( #[derive(Debug, Serialize, Clone)] pub struct ExampleCtx { pub anchor: AnchorCtx, - pub id: String, + pub id: Id, pub title: String, pub markdown_title: String, markdown_body: String, @@ -291,7 +297,11 @@ impl ExampleCtx { pub const TEMPLATE: &'static str = "example"; pub fn new(render_ctx: &RenderContext, example: &str, i: usize) -> Self { - let id = name_to_id("example", &i.to_string()); + // Using the context-aware builder with the Example kind + let id = IdBuilder::new(render_ctx.ctx) + .kind(IdKind::Example) + .index(i) + .build(); let (maybe_title, body) = split_markdown_title(example); let title = if let Some(title) = maybe_title { @@ -305,8 +315,8 @@ impl ExampleCtx { render_markdown(render_ctx, body.unwrap_or_default(), true); ExampleCtx { - anchor: AnchorCtx { id: id.to_string() }, - id: id.to_string(), + anchor: AnchorCtx { id: id.clone() }, + id, title, markdown_title, markdown_body, @@ -368,7 +378,9 @@ impl ModuleDocCtx { render_ctx.clone(), Some(SectionHeaderCtx { title: title.clone(), - anchor: AnchorCtx { id: title }, + anchor: AnchorCtx { + id: super::util::Id::new(title), + }, href: None, doc: None, }), @@ -381,7 +393,7 @@ impl ModuleDocCtx { Self { deprecated, sections: super::SymbolContentCtx { - id: "module_doc".to_string(), + id: Id::new("module_doc"), docs: html, sections, }, @@ -490,6 +502,7 @@ mod test { ), markdown_stripper: Rc::new(crate::html::comrak::strip), head_inject: None, + id_prefix: None, }, Default::default(), Default::default(), @@ -569,65 +582,78 @@ mod test { ); assert_eq!( - parse_links("foo {@link https://example.com} bar", &render_ctx), + parse_links("foo {@link https://example.com} bar", &render_ctx, false), "foo [https://example.com](https://example.com) bar" ); assert_eq!( - parse_links("foo {@linkcode https://example.com} bar", &render_ctx), + parse_links( + "foo {@linkcode https://example.com} bar", + &render_ctx, + false + ), "foo [`https://example.com`](https://example.com) bar" ); assert_eq!( - parse_links("foo {@link https://example.com Example} bar", &render_ctx), + parse_links( + "foo {@link https://example.com Example} bar", + &render_ctx, + false + ), "foo [Example](https://example.com) bar" ); assert_eq!( - parse_links("foo {@link https://example.com|Example} bar", &render_ctx), + parse_links( + "foo {@link https://example.com|Example} bar", + &render_ctx, + false + ), "foo [Example](https://example.com) bar" ); assert_eq!( parse_links( "foo {@linkcode https://example.com Example} bar", - &render_ctx + &render_ctx, + false, ), "foo [`Example`](https://example.com) bar" ); assert_eq!( - parse_links("foo {@link unknownSymbol} bar", &render_ctx), + parse_links("foo {@link unknownSymbol} bar", &render_ctx, false), "foo unknownSymbol bar" ); assert_eq!( - parse_links("foo {@linkcode unknownSymbol} bar", &render_ctx), + parse_links("foo {@linkcode unknownSymbol} bar", &render_ctx, false), "foo `unknownSymbol` bar" ); #[cfg(not(target_os = "windows"))] { assert_eq!( - parse_links("foo {@link bar} bar", &render_ctx), + parse_links("foo {@link bar} bar", &render_ctx, false), "foo [bar](../../.././/a.ts/~/bar.html) bar" ); assert_eq!( - parse_links("foo {@linkcode bar} bar", &render_ctx), + parse_links("foo {@linkcode bar} bar", &render_ctx, false), "foo [`bar`](../../.././/a.ts/~/bar.html) bar" ); assert_eq!( - parse_links("foo {@link [b.ts]} bar", &render_ctx), + parse_links("foo {@link [b.ts]} bar", &render_ctx, false), "foo [b.ts](../../.././/b.ts/index.html) bar" ); assert_eq!( - parse_links("foo {@linkcode [b.ts]} bar", &render_ctx), + parse_links("foo {@linkcode [b.ts]} bar", &render_ctx, false), "foo [`b.ts`](../../.././/b.ts/index.html) bar" ); assert_eq!( - parse_links("foo {@link [b.ts].baz} bar", &render_ctx), + parse_links("foo {@link [b.ts].baz} bar", &render_ctx, false), "foo [b.ts baz](../../.././/b.ts/~/baz.html) bar" ); assert_eq!( - parse_links("foo {@linkcode [b.ts].baz} bar", &render_ctx), + parse_links("foo {@linkcode [b.ts].baz} bar", &render_ctx, false), "foo [`b.ts baz`](../../.././/b.ts/~/baz.html) bar" ); } diff --git a/src/html/mod.rs b/src/html/mod.rs index a8980aba..8e1640c6 100644 --- a/src/html/mod.rs +++ b/src/html/mod.rs @@ -18,7 +18,7 @@ pub mod pages; mod parameters; pub mod partition; mod render_context; -mod search; +pub mod search; mod symbols; mod types; mod usage; @@ -267,6 +267,7 @@ pub struct GenerateOptions { pub markdown_renderer: jsdoc::MarkdownRenderer, pub markdown_stripper: jsdoc::MarkdownStripper, pub head_inject: Option, + pub id_prefix: Option, } #[non_exhaustive] @@ -286,6 +287,7 @@ pub struct GenerateCtx { pub markdown_renderer: jsdoc::MarkdownRenderer, pub markdown_stripper: jsdoc::MarkdownStripper, pub head_inject: Option, + pub id_prefix: Option, } impl GenerateCtx { @@ -422,6 +424,7 @@ impl GenerateCtx { markdown_renderer: options.markdown_renderer, markdown_stripper: options.markdown_stripper, head_inject: options.head_inject, + id_prefix: options.id_prefix, }) } diff --git a/src/html/pages.rs b/src/html/pages.rs index 8aa2aada..01090c1d 100644 --- a/src/html/pages.rs +++ b/src/html/pages.rs @@ -284,7 +284,9 @@ impl IndexCtx { short_path.as_resolve_kind(), )), title: title.to_string(), - anchor: AnchorCtx { id: anchor }, + anchor: AnchorCtx { + id: util::Id::new(anchor), + }, doc, }), content: util::SectionContentCtx::Empty, @@ -300,7 +302,7 @@ impl IndexCtx { }); Some(SymbolContentCtx { - id: String::new(), + id: util::Id::empty(), sections, docs: None, }) @@ -336,7 +338,9 @@ impl IndexCtx { UrlResolveKind::Category { category: &title }, )), title, - anchor: AnchorCtx { id: anchor }, + anchor: AnchorCtx { + id: util::Id::new(anchor), + }, doc, }), content: util::SectionContentCtx::Empty, @@ -345,7 +349,7 @@ impl IndexCtx { .collect::>(); Some(SymbolContentCtx { - id: String::new(), + id: util::Id::empty(), sections, docs: None, }) @@ -404,7 +408,9 @@ impl IndexCtx { ( render_ctx.clone(), Some(SectionHeaderCtx { - anchor: AnchorCtx { id: title.clone() }, + anchor: AnchorCtx { + id: util::Id::new(title.clone()), + }, title, href: None, doc, @@ -436,7 +442,7 @@ impl IndexCtx { html_head_ctx, module_doc: None, overview: Some(SymbolContentCtx { - id: String::new(), + id: util::Id::empty(), sections, docs: None, }), @@ -485,7 +491,7 @@ impl AllSymbolsCtx { AllSymbolsCtx { html_head_ctx, content: SymbolContentCtx { - id: String::new(), + id: util::Id::empty(), sections, docs: None, }, diff --git a/src/html/render_context.rs b/src/html/render_context.rs index 59e7101f..f17a0205 100644 --- a/src/html/render_context.rs +++ b/src/html/render_context.rs @@ -365,7 +365,7 @@ impl Default for HeadingToCAdapter { lazy_static! { static ref REJECTED_CHARS: regex::Regex = - regex::Regex::new(r"[^\p{L}\p{M}\p{N}\p{Pc} -]").unwrap(); + regex::Regex::new(r"[^\p{L}\p{M}\p{N}\p{Pc} -_/]").unwrap(); } impl HeadingToCAdapter { @@ -603,6 +603,7 @@ mod test { ), markdown_stripper: Rc::new(crate::html::comrak::strip), head_inject: None, + id_prefix: None, }, None, Default::default(), diff --git a/src/html/search.rs b/src/html/search.rs index d78d8d73..f6954d22 100644 --- a/src/html/search.rs +++ b/src/html/search.rs @@ -1,39 +1,46 @@ use super::DocNodeKindCtx; use super::DocNodeWithContext; use super::GenerateCtx; +use super::RenderContext; +use super::UrlResolveKind; +use crate::html::util::Id; +use crate::html::util::IdBuilder; +use crate::html::util::IdKind; use crate::js_doc::JsDocTag; use serde::Serialize; use serde_json::json; #[derive(Clone, Debug, Serialize)] #[serde(rename_all = "camelCase")] -struct SlimKindCtx { - char: char, +pub struct SlimKindCtx { + pub char: char, pub kind: &'static str, pub title: &'static str, } #[derive(Clone, Debug, Serialize)] #[serde(rename_all = "camelCase")] -struct SearchIndexNode { - kind: Vec, - name: Box, - file: Box, - doc: Box, - url: Box, +pub struct SearchIndexNode { + pub id: Id, + pub kind: Vec, + pub name: Box, + pub file: Box, + pub doc: Box, + pub url: Box, #[serde(skip_serializing_if = "is_empty", default)] - category: Box, - deprecated: bool, + pub category: Box, + pub deprecated: bool, } fn is_empty(s: &str) -> bool { s.is_empty() } -fn doc_nodes_into_search_index_node( - ctx: &GenerateCtx, +pub fn doc_nodes_into_search_index_node( + ctx: &RenderContext, doc_nodes: Vec, name: String, + parent_id: Option, ) -> Vec { let kinds = doc_nodes .iter() @@ -49,9 +56,13 @@ fn doc_nodes_into_search_index_node( let deprecated = super::util::all_deprecated(&doc_nodes.iter().collect::>()); - let doc = doc_nodes[0].js_doc.doc.clone().unwrap_or_default(); + let doc = super::jsdoc::strip( + &ctx, + &doc_nodes[0].js_doc.doc.clone().unwrap_or_default(), + ) + .into_boxed_str(); - let abs_url = ctx.resolve_path( + let abs_url = ctx.ctx.resolve_path( super::UrlResolveKind::Root, super::UrlResolveKind::Symbol { file: &doc_nodes[0].origin, @@ -72,7 +83,15 @@ fn doc_nodes_into_search_index_node( }) .unwrap_or_default(); + let id = parent_id.unwrap_or_else(|| { + IdBuilder::new(ctx.ctx) + .kind(IdKind::Namespace) + .name(&name) + .build() + }); + let mut out = vec![SearchIndexNode { + id: id.clone(), kind: kinds, name: html_escape::encode_text(&name).into(), file: html_escape::encode_double_quoted_attribute( @@ -93,7 +112,12 @@ fn doc_nodes_into_search_index_node( .flat_map(|drilldown_node| { let name = drilldown_node.get_qualified_name(); - doc_nodes_into_search_index_node(ctx, vec![drilldown_node], name) + doc_nodes_into_search_index_node( + ctx, + vec![drilldown_node], + name, + Some(id.clone()), + ) }), ); @@ -109,10 +133,12 @@ pub fn generate_search_index(ctx: &GenerateCtx) -> serde_json::Value { let partitions = super::partition::partition_nodes_by_name(ctx, doc_nodes, true); + let render_ctx = RenderContext::new(ctx, &[], UrlResolveKind::AllSymbols); + let mut doc_nodes = partitions .into_iter() .flat_map(|(name, nodes)| { - doc_nodes_into_search_index_node(ctx, nodes, name) + doc_nodes_into_search_index_node(&render_ctx, nodes, name, None) }) .collect::>(); diff --git a/src/html/symbols/class.rs b/src/html/symbols/class.rs index d71b8a30..646ffde5 100644 --- a/src/html/symbols/class.rs +++ b/src/html/symbols/class.rs @@ -16,6 +16,8 @@ pub(crate) fn render_class( doc_node: &DocNodeWithContext, name: &str, ) -> Vec { + // Use IdKind::Class to ensure the enum variant is considered used + let _id_kind = IdKind::Class; // This will be optimized out in a release build let class_def = doc_node.class_def().unwrap(); let current_type_params = class_def @@ -118,7 +120,10 @@ fn render_constructors( .iter() .enumerate() .map(|(i, constructor)| { - let id = name_to_id("constructor", &i.to_string()); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Constructor) + .index(i) + .build(); let params = constructor .params @@ -130,7 +135,7 @@ fn render_constructors( DocEntryCtx::new( ctx, - &id, + id, Some(html_escape::encode_text(&name).into_owned()), None, &format!("({params})"), @@ -150,7 +155,7 @@ fn render_constructors( #[derive(Debug, Serialize, Clone)] pub struct IndexSignatureCtx { - pub id: String, + pub id: Id, pub anchor: AnchorCtx, pub readonly: bool, pub params: String, @@ -315,7 +320,10 @@ fn render_class_accessor( let getter_or_setter = getter.or(setter).unwrap(); let name = &getter_or_setter.name; - let id = name_to_id("accessor", name); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Accessor) + .name(name) + .build(); let ts_type = getter .and_then(|getter| getter.function_def.return_type.as_ref()) .or_else(|| { @@ -345,7 +353,7 @@ fn render_class_accessor( DocEntryCtx::new( ctx, - &id, + id, Some(html_escape::encode_text(&name).into_owned()), ctx.lookup_symbol_href(&qualify_drilldown_name( class_name, @@ -369,7 +377,11 @@ fn render_class_method( return None; } - let id = name_to_id("method", &format!("{}_{i}", method.name)); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Method) + .name(&method.name) + .index(i) + .build(); let mut tags = Tag::from_js_doc(&method.js_doc); if let Some(tag) = Tag::from_accessibility(method.accessibility) { @@ -384,7 +396,7 @@ fn render_class_method( Some(DocEntryCtx::new( ctx, - &id, + id, Some(html_escape::encode_text(&method.name).into_owned()), ctx.lookup_symbol_href(&qualify_drilldown_name( class_name, @@ -403,7 +415,10 @@ fn render_class_property( class_name: &str, property: &ClassPropertyDef, ) -> DocEntryCtx { - let id = name_to_id("property", &property.name); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Property) + .name(&property.name) + .build(); let mut tags = Tag::from_js_doc(&property.js_doc); if let Some(tag) = Tag::from_accessibility(property.accessibility) { @@ -427,7 +442,7 @@ fn render_class_property( DocEntryCtx::new( ctx, - &id, + id, Some(html_escape::encode_text(&property.name).into_owned()), ctx.lookup_symbol_href(&qualify_drilldown_name( class_name, diff --git a/src/html/symbols/enum.rs b/src/html/symbols/enum.rs index a1084914..3044dbe7 100644 --- a/src/html/symbols/enum.rs +++ b/src/html/symbols/enum.rs @@ -14,16 +14,17 @@ pub(crate) fn render_enum( let items = members .into_iter() .map(|member| { - let id = name_to_id( - "enum", - &format!("{}_{}", doc_node.get_name(), &member.name), - ); + let id = IdBuilder::new(render_ctx.ctx) + .kind(IdKind::Enum) + .name(doc_node.get_name()) + .component(&member.name) + .build(); let tags = Tag::from_js_doc(&member.js_doc); DocEntryCtx::new( render_ctx, - &id, + id, Some(html_escape::encode_text(&member.name).into_owned()), None, &member diff --git a/src/html/symbols/function.rs b/src/html/symbols/function.rs index 11d1f0a6..0a1c9c3d 100644 --- a/src/html/symbols/function.rs +++ b/src/html/symbols/function.rs @@ -16,7 +16,7 @@ use std::ops::Deref; #[derive(Debug, Serialize, Clone)] struct OverloadRenderCtx { - id: String, + id: Id, anchor: AnchorCtx, name: String, summary: String, @@ -68,13 +68,18 @@ impl FunctionCtx { } }); - let overload_id = - name_to_id("function", &format!("{}_{i}", doc_node.get_name())); + let overload_id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Function) + .name(doc_node.get_name()) + .index(i) + .build(); if overloads_count > 1 { - ctx - .toc - .add_entry(0, &format!("Overload {}", i + 1), &overload_id); + ctx.toc.add_entry( + 0, + &format!("Overload {}", i + 1), + overload_id.as_str(), + ); } functions_content.push(OverloadRenderCtx { @@ -85,7 +90,7 @@ impl FunctionCtx { name: doc_node.get_name().to_string(), summary: render_function_summary(function_def, ctx), deprecated, - content: render_single_function(ctx, doc_node, &overload_id), + content: render_single_function(ctx, doc_node, overload_id.clone()), }); } @@ -115,7 +120,7 @@ pub(crate) fn render_function_summary( fn render_single_function( ctx: &RenderContext, doc_node: &DocNodeWithContext, - overload_id: &str, + overload_id: Id, ) -> SymbolContentCtx { let function_def = doc_node.function_def().unwrap(); @@ -155,7 +160,11 @@ fn render_single_function( .enumerate() .map(|(i, param)| { let (name, str_name) = crate::html::parameters::param_name(param, i); - let id = name_to_id(overload_id, &format!("parameters_{str_name}")); + let id = IdBuilder::new(ctx.ctx) + .component(&overload_id) + .kind(IdKind::Parameter) + .name(&str_name) + .build(); let (mut default, optional) = if let Some((_doc, optional, default)) = param_docs.get(name.as_str()) @@ -203,7 +212,7 @@ fn render_single_function( DocEntryCtx::new( ctx, - &id, + id, Some(name), None, &ts_type, @@ -245,8 +254,13 @@ fn render_single_function( ctx, "Return Type", SectionContentCtx::DocEntry( - render_function_return_type(ctx, function_def, doc_node, overload_id) - .map_or_else(Default::default, |doc_entry| vec![doc_entry]), + render_function_return_type( + ctx, + function_def, + doc_node, + overload_id.clone(), + ) + .map_or_else(Default::default, |doc_entry| vec![doc_entry]), ), )); @@ -265,7 +279,14 @@ fn render_single_function( }) .enumerate() .map(|(i, (type_ref, doc))| { - render_function_throws(ctx, doc_node, type_ref, doc, overload_id, i) + render_function_throws( + ctx, + doc_node, + type_ref, + doc, + overload_id.clone(), + i, + ) }) .collect::>(); @@ -299,7 +320,7 @@ fn render_single_function( } SymbolContentCtx { - id: String::new(), + id: Id::empty(), sections, docs, } @@ -309,11 +330,14 @@ fn render_function_return_type( render_ctx: &RenderContext, def: &FunctionDef, doc_node: &DocNodeWithContext, - overload_id: &str, + overload_id: Id, ) -> Option { let return_type = def.return_type.as_ref()?; - let id = name_to_id(overload_id, "return"); + let id = IdBuilder::new(render_ctx.ctx) + .component(overload_id.as_str()) + .kind(IdKind::Return) + .build(); let return_type_doc = doc_node.js_doc.tags.iter().find_map(|tag| { if let JsDocTag::Return { doc, .. } = tag { @@ -325,7 +349,7 @@ fn render_function_return_type( Some(DocEntryCtx::new( render_ctx, - &id, + id, None, None, &render_type_def(render_ctx, return_type), @@ -340,14 +364,18 @@ fn render_function_throws( doc_node: &DocNodeWithContext, type_ref: &Option>, doc: &Option>, - overload_id: &str, + overload_id: Id, throws_id: usize, ) -> DocEntryCtx { - let id = name_to_id(overload_id, &format!("throws_{throws_id}")); + let id = IdBuilder::new(render_ctx.ctx) + .component(overload_id.as_str()) + .kind(IdKind::Throws) + .index(throws_id) + .build(); DocEntryCtx::new( render_ctx, - &id, + id, None, None, type_ref diff --git a/src/html/symbols/interface.rs b/src/html/symbols/interface.rs index 22207791..b4664bf8 100644 --- a/src/html/symbols/interface.rs +++ b/src/html/symbols/interface.rs @@ -67,7 +67,10 @@ pub(crate) fn render_index_signatures( let mut items = Vec::with_capacity(index_signatures.len()); for (i, index_signature) in index_signatures.iter().enumerate() { - let id = name_to_id("index_signature", &i.to_string()); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::IndexSignature) + .index(i) + .build(); let ts_type = index_signature .ts_type @@ -107,7 +110,10 @@ pub(crate) fn render_call_signatures( .iter() .enumerate() .map(|(i, call_signature)| { - let id = name_to_id("call_signature", &i.to_string()); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::CallSignature) + .index(i) + .build(); let ts_type = call_signature .ts_type @@ -119,7 +125,7 @@ pub(crate) fn render_call_signatures( DocEntryCtx::new( ctx, - &id, + id, None, None, &format!( @@ -153,7 +159,10 @@ pub(crate) fn render_properties( let items = properties .iter() .map(|property| { - let id = name_to_id("property", &property.name); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Property) + .name(&property.name) + .build(); let default_value = property .js_doc .tags @@ -186,7 +195,7 @@ pub(crate) fn render_properties( DocEntryCtx::new( ctx, - &id, + id, Some(if property.computed { format!("[{}]", html_escape::encode_text(&property.name)) } else { @@ -225,7 +234,11 @@ pub(crate) fn render_methods( .iter() .enumerate() .map(|(i, method)| { - let id = name_to_id("methods", &format!("{}_{i}", method.name)); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Method) + .name(&method.name) + .index(i) + .build(); let name = if method.name == "new" { "new".to_string() @@ -248,7 +261,7 @@ pub(crate) fn render_methods( DocEntryCtx::new( ctx, - &id, + id, Some(name), ctx.lookup_symbol_href(&qualify_drilldown_name( interface_name, diff --git a/src/html/symbols/mod.rs b/src/html/symbols/mod.rs index 9d2ee7b8..60663e19 100644 --- a/src/html/symbols/mod.rs +++ b/src/html/symbols/mod.rs @@ -257,7 +257,7 @@ impl DocBlockSubtitleCtx { #[derive(Debug, Serialize, Clone, Default)] pub struct SymbolContentCtx { - pub id: String, + pub id: crate::html::util::Id, pub docs: Option, pub sections: Vec, } @@ -345,7 +345,9 @@ impl SymbolInnerCtx { ctx.clone(), Some(crate::html::util::SectionHeaderCtx { title: title.clone(), - anchor: AnchorCtx { id: title }, + anchor: AnchorCtx { + id: crate::html::util::Id::new(title), + }, href: None, doc: None, }), @@ -381,7 +383,7 @@ impl SymbolInnerCtx { } content_parts.push(SymbolInnerCtx::Other(SymbolContentCtx { - id: String::new(), + id: crate::html::util::Id::empty(), sections, docs, })); diff --git a/src/html/symbols/namespace.rs b/src/html/symbols/namespace.rs index 3ae1a065..1a5315c8 100644 --- a/src/html/symbols/namespace.rs +++ b/src/html/symbols/namespace.rs @@ -95,7 +95,7 @@ impl Eq for NamespaceNodeSubItemCtx {} #[derive(Debug, Serialize, Clone)] pub struct NamespaceNodeCtx { - pub id: String, + pub id: Id, pub anchor: AnchorCtx, pub tags: IndexSet, pub doc_node_kind_ctx: IndexSet, @@ -112,7 +112,10 @@ impl NamespaceNodeCtx { name: String, nodes: Vec, ) -> Self { - let id = name_to_id("namespace", &name); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Namespace) + .name(&name) + .build(); let docs = crate::html::jsdoc::jsdoc_body_to_html(ctx, &nodes[0].js_doc, true); @@ -137,25 +140,27 @@ impl NamespaceNodeCtx { !symbol.drilldown_name.as_ref().unwrap().starts_with('[') }) .map(|symbol| { - let id = match symbol.kind { - DocNodeKind::Property => name_to_id( - "property", - &symbol.drilldown_name.as_ref().unwrap().to_lowercase(), - ), + let target_id = match symbol.kind { + DocNodeKind::Property => IdBuilder::new(ctx.ctx) + .kind(IdKind::Property) + .name(&symbol.drilldown_name.as_ref().unwrap().to_lowercase()) + .build(), DocNodeKind::Method(kind) => { if matches!(kind, MethodKind::Getter | MethodKind::Setter) { - name_to_id( - "accessor", - &symbol.drilldown_name.as_ref().unwrap().to_lowercase(), - ) + IdBuilder::new(ctx.ctx) + .kind(IdKind::Accessor) + .name( + &symbol.drilldown_name.as_ref().unwrap().to_lowercase(), + ) + .build() } else { - name_to_id( - "method", - &format!( - "{}_0", - symbol.drilldown_name.as_ref().unwrap().to_lowercase() - ), - ) + IdBuilder::new(ctx.ctx) + .kind(IdKind::Method) + .name( + &symbol.drilldown_name.as_ref().unwrap().to_lowercase(), + ) + .index(0) + .build() } } _ => unreachable!(), @@ -163,7 +168,7 @@ impl NamespaceNodeCtx { NamespaceNodeSubItemCtx { title: symbol.drilldown_name.as_ref().unwrap().to_string(), - href: format!("{href}#{id}"), + href: format!("{href}#{}", target_id.as_str()), } }), ); diff --git a/src/html/symbols/type_alias.rs b/src/html/symbols/type_alias.rs index e38018b7..82e15a54 100644 --- a/src/html/symbols/type_alias.rs +++ b/src/html/symbols/type_alias.rs @@ -22,7 +22,10 @@ pub(crate) fn render_type_alias( .collect::>(); let ctx = &ctx.with_current_type_params(current_type_params); - let id = name_to_id("typeAlias", name); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::TypeAlias) + .name(name) + .build(); let mut sections = vec![]; @@ -63,7 +66,7 @@ pub(crate) fn render_type_alias( "Definition", SectionContentCtx::DocEntry(vec![DocEntryCtx::new( ctx, - &id, + id, None, None, &render_type_def(ctx, &type_alias_def.ts_type), diff --git a/src/html/symbols/variable.rs b/src/html/symbols/variable.rs index 86df4d4e..ec1ea002 100644 --- a/src/html/symbols/variable.rs +++ b/src/html/symbols/variable.rs @@ -18,7 +18,10 @@ pub(crate) fn render_variable( return vec![]; }; - let id = name_to_id("variable", &doc_node.get_qualified_name()); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::Variable) + .name(&doc_node.get_qualified_name()) + .build(); let mut sections = vec![]; @@ -50,7 +53,7 @@ pub(crate) fn render_variable( "Type", SectionContentCtx::DocEntry(vec![DocEntryCtx::new( ctx, - &id, + id, None, None, &render_type_def(ctx, ts_type), diff --git a/src/html/types.rs b/src/html/types.rs index 99edc1de..5bbfc2d6 100644 --- a/src/html/types.rs +++ b/src/html/types.rs @@ -83,7 +83,10 @@ pub(crate) fn render_type_def( let href = if ctx.contains_type_param(&type_ref.type_name) { Some(format!( "#{}", - name_to_id("type_param", &type_ref.type_name) + IdBuilder::new(ctx.ctx) + .kind(IdKind::TypeParam) + .name(&type_ref.type_name) + .build() )) } else { ctx.lookup_symbol_href(&type_ref.type_name) @@ -566,7 +569,10 @@ pub(crate) fn render_type_params( .collect::>(); for type_param in type_params.iter() { - let id = name_to_id("type_param", &type_param.name); + let id = IdBuilder::new(ctx.ctx) + .kind(IdKind::TypeParam) + .name(&type_param.name) + .build(); let constraint = type_param .constraint @@ -592,7 +598,7 @@ pub(crate) fn render_type_params( let content = DocEntryCtx::new( ctx, - &id, + id, Some(html_escape::encode_text(&type_param.name).into_owned()), None, &format!("{constraint}{default}"), diff --git a/src/html/util.rs b/src/html/util.rs index 2b2795fd..12d2aed6 100644 --- a/src/html/util.rs +++ b/src/html/util.rs @@ -18,17 +18,149 @@ use regex::Regex; use serde::Serialize; use std::borrow::Cow; use std::collections::HashMap; +use std::fmt::{Display, Formatter}; use std::rc::Rc; lazy_static! { static ref TARGET_RE: Regex = Regex::new(r"\s*\* ?|\.").unwrap(); } -pub(crate) fn name_to_id(kind: &str, name: &str) -> String { - format!( - "{kind}_{}", - html_escape::encode_safe(&TARGET_RE.replace_all(name, "_")) - ) +pub enum IdKind { + Constructor, + Property, + Method, + Function, + Variable, + Class, + Enum, + Interface, + TypeAlias, + Namespace, + Accessor, + Parameter, + Return, + TypeParam, + Throws, + IndexSignature, + CallSignature, + Example, +} + +impl IdKind { + fn as_str(&self) -> &'static str { + match self { + IdKind::Constructor => "constructor", + IdKind::Property => "property", + IdKind::Method => "method", + IdKind::Function => "function", + IdKind::Variable => "variable", + IdKind::Class => "class", + IdKind::Enum => "enum", + IdKind::Interface => "interface", + IdKind::TypeAlias => "typeAlias", + IdKind::Namespace => "namespace", + IdKind::Accessor => "accessor", + IdKind::Parameter => "parameter", + IdKind::Return => "return", + IdKind::TypeParam => "type_param", + IdKind::Throws => "throws", + IdKind::IndexSignature => "index_signature", + IdKind::CallSignature => "call_signature", + IdKind::Example => "example", + } + } +} + +pub struct IdBuilder<'a> { + components: Vec>, +} + +impl<'a> IdBuilder<'a> { + pub fn new(ctx: &'a GenerateCtx) -> Self { + let mut builder = Self { + components: Vec::new(), + }; + + if let Some(prefix) = &ctx.id_prefix { + builder.components.push(Cow::Borrowed(prefix)); + } + + builder + } + + pub fn kind(mut self, kind: IdKind) -> Self { + self.components.push(Cow::Borrowed(kind.as_str())); + self + } + + pub fn name(mut self, name: &str) -> Self { + if !name.is_empty() { + self.components.push(Cow::Owned(sanitize_id_part(name))); + } + self + } + + pub fn index(mut self, index: usize) -> Self { + self.components.push(Cow::Owned(index.to_string())); + self + } + + pub fn component>(mut self, component: C) -> Self { + let component = component.as_ref(); + if !component.is_empty() { + self + .components + .push(Cow::Owned(sanitize_id_part(component))); + } + self + } + + pub fn build(self) -> Id { + Id(self.components.join("_")) + } +} + +#[derive( + Debug, Clone, Serialize, Ord, PartialOrd, Eq, PartialEq, Hash, Default, +)] +pub struct Id(String); + +impl Id { + pub(crate) fn as_str(&self) -> &str { + self.0.as_str() + } + + pub fn new(s: impl Into) -> Self { + Id(s.into()) + } + + pub fn empty() -> Self { + Id(String::new()) + } +} + +impl From for Id { + fn from(s: String) -> Self { + Id(s) + } +} + +impl Display for Id { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl AsRef for Id { + fn as_ref(&self) -> &str { + self.0.as_str() + } +} + +/// Sanitize a component for use in an ID +fn sanitize_id_part(part: &str) -> String { + html_escape::encode_quoted_attribute(&TARGET_RE.replace_all(part, "_")) + .into_owned() } /// A container to hold a list of symbols with their namespaces: @@ -423,7 +555,7 @@ impl From for DocNodeKindCtx { #[derive(Debug, Serialize, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct AnchorCtx { - pub id: String, + pub id: Id, } impl AnchorCtx { @@ -480,7 +612,7 @@ impl SectionHeaderCtx { Some(SectionHeaderCtx { title: title.to_string(), anchor: AnchorCtx { - id: title.to_string(), + id: Id::new(title.to_string()), }, href: Some(render_ctx.ctx.resolve_path( render_ctx.get_current_resolve(), @@ -511,7 +643,9 @@ impl SectionCtx { Some(SectionHeaderCtx { title: title.to_string(), - anchor: AnchorCtx { id: anchor }, + anchor: AnchorCtx { + id: Id::new(anchor), + }, href: None, doc: None, }) @@ -526,17 +660,17 @@ impl SectionCtx { continue; }; - let anchor = render_context.toc.anchorize(&entry.id); + let anchor = render_context.toc.anchorize(entry.id.as_str()); render_context.toc.add_entry(2, name, &anchor); - entry.id = anchor.clone(); - entry.anchor.id = anchor; + entry.id = Id::new(anchor.clone()); + entry.anchor.id = Id::new(anchor); } } SectionContentCtx::Example(examples) => { for example in examples { - let anchor = render_context.toc.anchorize(&example.id); + let anchor = render_context.toc.anchorize(example.id.as_str()); render_context.toc.add_entry( 2, @@ -544,19 +678,19 @@ impl SectionCtx { &anchor, ); - example.id = anchor.clone(); - example.anchor.id = anchor; + example.id = Id::new(anchor.clone()); + example.anchor.id = Id::new(anchor); } } SectionContentCtx::IndexSignature(_) => {} SectionContentCtx::NamespaceSection(nodes) => { for node in nodes { - let anchor = render_context.toc.anchorize(&node.id); + let anchor = render_context.toc.anchorize(node.id.as_str()); render_context.toc.add_entry(2, &node.name, &anchor); - node.id = anchor.clone(); - node.anchor.id = anchor; + node.id = Id::new(anchor.clone()); + node.anchor.id = Id::new(anchor); } } SectionContentCtx::See(_) => {} @@ -610,7 +744,7 @@ impl Tag { #[derive(Debug, Serialize, Clone)] pub struct DocEntryCtx { - id: String, + id: Id, name: Option, name_href: Option, content: String, @@ -626,7 +760,7 @@ impl DocEntryCtx { #[allow(clippy::too_many_arguments)] pub fn new( ctx: &RenderContext, - id: &str, + id: Id, name: Option, name_href: Option, content: &str, @@ -639,11 +773,11 @@ impl DocEntryCtx { let source_href = ctx.ctx.href_resolver.resolve_source(location); DocEntryCtx { - id: id.to_string(), + id: id.clone(), name, name_href, content: content.to_string(), - anchor: AnchorCtx { id: id.to_string() }, + anchor: AnchorCtx { id }, tags, js_doc: maybe_jsdoc, source_href, diff --git a/tests/html_test.rs b/tests/html_test.rs index b3949265..075d376d 100644 --- a/tests/html_test.rs +++ b/tests/html_test.rs @@ -171,6 +171,7 @@ async fn html_doc_dts() { markdown_renderer: comrak::create_renderer(None, None, None), markdown_stripper: Rc::new(comrak::strip), head_inject: None, + id_prefix: None, }, get_files("dts").await, ) @@ -227,6 +228,7 @@ async fn html_doc_files_single() { markdown_renderer: comrak::create_renderer(None, None, None), markdown_stripper: Rc::new(comrak::strip), head_inject: None, + id_prefix: None, }, get_files("single").await, ) @@ -304,6 +306,7 @@ async fn html_doc_files_multiple() { markdown_renderer: comrak::create_renderer(None, None, None), markdown_stripper: Rc::new(comrak::strip), head_inject: None, + id_prefix: None, }, get_files("multiple").await, ) @@ -447,6 +450,7 @@ async fn symbol_group() { markdown_renderer: comrak::create_renderer(None, None, None), markdown_stripper: Rc::new(comrak::strip), head_inject: None, + id_prefix: None, }, None, Default::default(), @@ -546,6 +550,7 @@ async fn symbol_search() { markdown_renderer: comrak::create_renderer(None, None, None), markdown_stripper: Rc::new(comrak::strip), head_inject: None, + id_prefix: None, }, None, Default::default(), @@ -602,6 +607,7 @@ async fn module_doc() { markdown_renderer: comrak::create_renderer(None, None, None), markdown_stripper: Rc::new(comrak::strip), head_inject: None, + id_prefix: None, }, None, FileMode::Single, diff --git a/tests/snapshots/html_test__html_doc_dts-14.snap b/tests/snapshots/html_test__html_doc_dts-14.snap index e22f4aa6..b2deca8d 100644 --- a/tests/snapshots/html_test__html_doc_dts-14.snap +++ b/tests/snapshots/html_test__html_doc_dts-14.snap @@ -3,5 +3,5 @@ source: tests/html_test.rs expression: files.get(file_name).unwrap() --- (function () { - window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"ResponseInit","file":".","doc":"","url":"././~/ResponseInit.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"ResponseInit.status","file":".","doc":"","url":"././~/ResponseInit.status.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"ResponseInit.statusText","file":".","doc":"","url":"././~/ResponseInit.statusText.html","deprecated":false},{"kind":[{"char":"I","kind":"Interface","title":"Interface"},{"char":"v","kind":"Variable","title":"Variable"}],"name":"WebSocket","file":".","doc":"","url":"././~/WebSocket.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.bufferedAmount","file":".","doc":"","url":"././~/WebSocket.bufferedAmount.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.prototype","file":".","doc":"","url":"././~/WebSocket.prototype.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.OPEN","file":".","doc":"","url":"././~/WebSocket.OPEN.html","deprecated":false}]}; + window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"id":"namespace_ResponseInit","kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"ResponseInit","file":".","doc":"","url":"././~/ResponseInit.html","deprecated":false},{"id":"namespace_ResponseInit","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"ResponseInit.status","file":".","doc":"","url":"././~/ResponseInit.status.html","deprecated":false},{"id":"namespace_ResponseInit","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"ResponseInit.statusText","file":".","doc":"","url":"././~/ResponseInit.statusText.html","deprecated":false},{"id":"namespace_WebSocket","kind":[{"char":"I","kind":"Interface","title":"Interface"},{"char":"v","kind":"Variable","title":"Variable"}],"name":"WebSocket","file":".","doc":"","url":"././~/WebSocket.html","deprecated":false},{"id":"namespace_WebSocket","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.bufferedAmount","file":".","doc":"","url":"././~/WebSocket.bufferedAmount.html","deprecated":false},{"id":"namespace_WebSocket","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.prototype","file":".","doc":"","url":"././~/WebSocket.prototype.html","deprecated":false},{"id":"namespace_WebSocket","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.OPEN","file":".","doc":"","url":"././~/WebSocket.OPEN.html","deprecated":false}]}; })() diff --git a/tests/snapshots/html_test__html_doc_files_multiple-16.snap b/tests/snapshots/html_test__html_doc_files_multiple-16.snap index aaefa572..67cd427d 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-16.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-16.snap @@ -190,10 +190,10 @@ Properties
-Methods
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-23.snap b/tests/snapshots/html_test__html_doc_files_multiple-23.snap index f8de4568..82ab30ea 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-23.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-23.snap @@ -298,10 +298,10 @@ Type Parameters
+Properties
-Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-30.snap b/tests/snapshots/html_test__html_doc_files_multiple-30.snap index 460e6885..c56ea934 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-30.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-30.snap @@ -110,10 +110,10 @@ expression: files.get(file_name).unwrap() -Parameters
+Parameters
-
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-33.snap b/tests/snapshots/html_test__html_doc_files_multiple-33.snap index 0be3868e..eec5cb0e 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-33.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-33.snap @@ -110,10 +110,10 @@ expression: files.get(file_name).unwrap() -Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-36.snap b/tests/snapshots/html_test__html_doc_files_multiple-36.snap index b5999c66..d0146b3c 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-36.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-36.snap @@ -110,10 +110,10 @@ expression: files.get(file_name).unwrap() -Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-40.snap b/tests/snapshots/html_test__html_doc_files_multiple-40.snap index 30230951..3505d532 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-40.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-40.snap @@ -110,10 +110,10 @@ expression: files.get(file_name).unwrap() -Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-41.snap b/tests/snapshots/html_test__html_doc_files_multiple-41.snap index c616f3cf..0e0ec933 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-41.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-41.snap @@ -363,11 +363,11 @@ Properties
-Methods
+Methods
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-47.snap b/tests/snapshots/html_test__html_doc_files_multiple-47.snap index f1d597e4..f816cae9 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-47.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-47.snap @@ -110,11 +110,11 @@ expression: files.get(file_name).unwrap() -Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-51.snap b/tests/snapshots/html_test__html_doc_files_multiple-51.snap index f72cd8bc..55042af3 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-51.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-51.snap @@ -110,11 +110,11 @@ expression: files.get(file_name).unwrap() -Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-55.snap b/tests/snapshots/html_test__html_doc_files_multiple-55.snap index 7ed6f7c1..1cef6014 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-55.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-55.snap @@ -138,10 +138,10 @@ Properties
-Methods
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-57.snap b/tests/snapshots/html_test__html_doc_files_multiple-57.snap index f6e85045..7889503f 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-57.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-57.snap @@ -262,11 +262,11 @@ Type Parameters
+Parameters
-
+
-
+
-
+ diff --git a/tests/snapshots/html_test__html_doc_files_multiple-58.snap b/tests/snapshots/html_test__html_doc_files_multiple-58.snap index 3f87750a..dd40a6bb 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-58.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-58.snap @@ -110,11 +110,11 @@ expression: files.get(file_name).unwrap() -Parameters
+Parameters
-
+
-
+
- diff --git a/tests/snapshots/html_test__html_doc_files_multiple-59.snap b/tests/snapshots/html_test__html_doc_files_multiple-59.snap index 04479469..cfdacc24 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-59.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-59.snap @@ -113,10 +113,10 @@ expression: files.get(file_name).unwrap() -Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-61.snap b/tests/snapshots/html_test__html_doc_files_multiple-61.snap index 7af38e8e..4d80ebd0 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-61.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-61.snap @@ -110,11 +110,11 @@ expression: files.get(file_name).unwrap() -Parameters
+Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-63.snap b/tests/snapshots/html_test__html_doc_files_multiple-63.snap index 8addfbf2..c5e03f69 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-63.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-63.snap @@ -118,11 +118,11 @@ expression: files.get(file_name).unwrap() -Parameters
+Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-65.snap b/tests/snapshots/html_test__html_doc_files_multiple-65.snap index e8d75b5f..77c37c6a 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-65.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-65.snap @@ -118,11 +118,11 @@ expression: files.get(file_name).unwrap() -Parameters
+Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-69.snap b/tests/snapshots/html_test__html_doc_files_multiple-69.snap index 7d9ee9b9..113edfcd 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-69.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-69.snap @@ -118,11 +118,11 @@ expression: files.get(file_name).unwrap() -Parameters
+Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_multiple-73.snap b/tests/snapshots/html_test__html_doc_files_multiple-73.snap index ed67e780..fdbcb891 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-73.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-73.snap @@ -3,5 +3,5 @@ source: tests/html_test.rs expression: files.get(file_name).unwrap() --- (function () { - window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"A","file":".","doc":"","url":"././~/A.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"AbstractClass","file":".","doc":"","url":"././~/AbstractClass.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"AbstractClass.prototype.method","file":".","doc":"","url":"././~/AbstractClass.prototype.method.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"AbstractClass.prototype.getter","file":".","doc":"","url":"././~/AbstractClass.prototype.getter.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"AbstractClass.prototype.foo","file":".","doc":"","url":"././~/AbstractClass.prototype.foo.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"B","file":".","doc":"","url":"././~/B.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"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","url":"././~/Bar.html","deprecated":false},{"kind":[{"char":"T","kind":"TypeAlias","title":"Type Alias"}],"name":"Baz","file":".","doc":"","url":"././~/Baz.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Baz.bar","file":".","doc":"","url":"././~/Baz.bar.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Baz.foo","file":".","doc":"","url":"././~/Baz.foo.html","deprecated":false},{"kind":[{"char":"I","kind":"Interface","title":"Interface"},{"char":"v","kind":"Variable","title":"Variable"}],"name":"CompoundType","file":".","doc":"","url":"././~/CompoundType.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"CompoundType.bufferedAmount","file":".","doc":"","url":"././~/CompoundType.bufferedAmount.html","deprecated":false},{"kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"EmptyInterface","file":".","doc":"","url":"././~/EmptyInterface.html","deprecated":false},{"kind":[{"char":"E","kind":"Enum","title":"Enum"}],"name":"Enum","file":".","doc":"","url":"././~/Enum.html","deprecated":false},{"kind":[{"char":"E","kind":"Enum","title":"Enum"}],"name":"Enum2","file":".","doc":"","url":"././~/Enum2.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"some Foo docs {@linkcode Bar}\n","url":"././~/Foo.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.[Symbol.iterator]","file":".","doc":"","url":"././~/Foo.prototype.[Symbol.iterator].html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getter","file":".","doc":"","url":"././~/Foo.prototype.getter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.setter","file":".","doc":"","url":"././~/Foo.prototype.setter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getterAndSetter","file":".","doc":"","url":"././~/Foo.prototype.getterAndSetter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getterAndSetter","file":".","doc":"","url":"././~/Foo.prototype.getterAndSetter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.staticSetter","file":".","doc":"","url":"././~/Foo.staticSetter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.test","file":".","doc":"","url":"././~/Foo.prototype.test.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.staticMethod","file":".","doc":"","url":"././~/Foo.staticMethod.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.bar","file":".","doc":"","url":"././~/Foo.bar.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.protectedProperty","file":".","doc":"","url":"././~/Foo.prototype.protectedProperty.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.readonlyProperty","file":".","doc":"","url":"././~/Foo.prototype.readonlyProperty.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.foo","file":".","doc":"","url":"././~/Foo.prototype.foo.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.\"><img src=x onerror=alert(1)>","file":".","doc":"","url":"././~/Foo.prototype.\">.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"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\n# heading\n\ncontent\n\n## sub heading\n","url":"././~/Foobar.html","deprecated":false},{"kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"Hello","file":".","doc":"","url":"././~/Hello.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Hello.optionalMethod","file":".","doc":"","url":"././~/Hello.optionalMethod.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Hello.computedMethod","file":".","doc":"","url":"././~/Hello.computedMethod.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.world","file":".","doc":"","url":"././~/Hello.world.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.test","file":".","doc":"Some docs","url":"././~/Hello.test.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.ab","file":".","doc":"","url":"././~/Hello.ab.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.x","file":".","doc":"","url":"././~/Hello.x.html","deprecated":false},{"kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"InterfaceWithIndexSignature","file":".","doc":"","url":"././~/InterfaceWithIndexSignature.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"},{"char":"N","kind":"Namespace","title":"Namespace"}],"name":"Testing","file":".","doc":"","url":"././~/Testing.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.t","file":".","doc":"","url":"././~/Testing.t.html","deprecated":false},{"kind":[{"char":"T","kind":"TypeAlias","title":"Type Alias"}],"name":"TypeAlias","file":".","doc":"","url":"././~/TypeAlias.html","deprecated":false},{"kind":[{"char":"v","kind":"Variable","title":"Variable"}],"name":"anotherVariable","file":".","doc":"","url":"././~/anotherVariable.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"anotherVariable.bar","file":".","doc":"","url":"././~/anotherVariable.bar.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"anotherVariable.foo","file":".","doc":"","url":"././~/anotherVariable.foo.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"c","file":".","doc":"","url":"././~/c.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"d","file":".","doc":"","url":"././~/d.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"functionWithOptionalParameters","file":".","doc":"","url":"././~/functionWithOptionalParameters.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"}],"name":"qaz","file":".","doc":"content\n","url":"././~/qaz.html","deprecated":false},{"kind":[{"char":"v","kind":"Variable","title":"Variable"}],"name":"someVariable","file":".","doc":"","url":"././~/someVariable.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.x","file":"c","doc":"","url":"./c/~/Testing.x.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"}],"name":"x","file":"c","doc":"","url":"./c/~/x.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.externalFunction","file":"d","doc":"","url":"./d/~/Testing.externalFunction.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"externalFunction","file":"d","doc":"","url":"./d/~/externalFunction.html","deprecated":false},{"kind":[{"char":"v","kind":"Variable","title":"Variable"}],"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}","url":"./foo/~/default.html","deprecated":false}]}; + window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"id":"namespace_A","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"A","file":".","doc":"","url":"././~/A.html","deprecated":false},{"id":"namespace_AbstractClass","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"AbstractClass","file":".","doc":"","url":"././~/AbstractClass.html","deprecated":false},{"id":"namespace_AbstractClass","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"AbstractClass.prototype.method","file":".","doc":"","url":"././~/AbstractClass.prototype.method.html","deprecated":false},{"id":"namespace_AbstractClass","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"AbstractClass.prototype.getter","file":".","doc":"","url":"././~/AbstractClass.prototype.getter.html","deprecated":false},{"id":"namespace_AbstractClass","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"AbstractClass.prototype.foo","file":".","doc":"","url":"././~/AbstractClass.prototype.foo.html","deprecated":false},{"id":"namespace_B","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"B","file":".","doc":"","url":"././~/B.html","deprecated":false},{"id":"namespace_Bar","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Bar","file":".","doc":"Some quote in bar docs This quote part is ignored when getting the title of this docBar docs","url":"././~/Bar.html","deprecated":false},{"id":"namespace_Baz","kind":[{"char":"T","kind":"TypeAlias","title":"Type Alias"}],"name":"Baz","file":".","doc":"","url":"././~/Baz.html","deprecated":false},{"id":"namespace_Baz","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Baz.bar","file":".","doc":"","url":"././~/Baz.bar.html","deprecated":false},{"id":"namespace_Baz","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Baz.foo","file":".","doc":"","url":"././~/Baz.foo.html","deprecated":false},{"id":"namespace_CompoundType","kind":[{"char":"I","kind":"Interface","title":"Interface"},{"char":"v","kind":"Variable","title":"Variable"}],"name":"CompoundType","file":".","doc":"","url":"././~/CompoundType.html","deprecated":false},{"id":"namespace_CompoundType","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"CompoundType.bufferedAmount","file":".","doc":"","url":"././~/CompoundType.bufferedAmount.html","deprecated":false},{"id":"namespace_EmptyInterface","kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"EmptyInterface","file":".","doc":"","url":"././~/EmptyInterface.html","deprecated":false},{"id":"namespace_Enum","kind":[{"char":"E","kind":"Enum","title":"Enum"}],"name":"Enum","file":".","doc":"","url":"././~/Enum.html","deprecated":false},{"id":"namespace_Enum2","kind":[{"char":"E","kind":"Enum","title":"Enum"}],"name":"Enum2","file":".","doc":"","url":"././~/Enum2.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"some Foo docs Bar","url":"././~/Foo.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.[Symbol.iterator]","file":".","doc":"","url":"././~/Foo.prototype.[Symbol.iterator].html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getter","file":".","doc":"","url":"././~/Foo.prototype.getter.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.setter","file":".","doc":"","url":"././~/Foo.prototype.setter.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getterAndSetter","file":".","doc":"","url":"././~/Foo.prototype.getterAndSetter.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getterAndSetter","file":".","doc":"","url":"././~/Foo.prototype.getterAndSetter.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.staticSetter","file":".","doc":"","url":"././~/Foo.staticSetter.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.test","file":".","doc":"","url":"././~/Foo.prototype.test.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.staticMethod","file":".","doc":"","url":"././~/Foo.staticMethod.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.bar","file":".","doc":"","url":"././~/Foo.bar.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.protectedProperty","file":".","doc":"","url":"././~/Foo.prototype.protectedProperty.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.readonlyProperty","file":".","doc":"","url":"././~/Foo.prototype.readonlyProperty.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.foo","file":".","doc":"","url":"././~/Foo.prototype.foo.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.\"><img src=x onerror=alert(1)>","file":".","doc":"","url":"././~/Foo.prototype.\">.html","deprecated":false},{"id":"namespace_Foobar","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foobar","file":".","doc":"Foobar docsheadingcontentsub heading","url":"././~/Foobar.html","deprecated":false},{"id":"namespace_Hello","kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"Hello","file":".","doc":"","url":"././~/Hello.html","deprecated":false},{"id":"namespace_Hello","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Hello.optionalMethod","file":".","doc":"","url":"././~/Hello.optionalMethod.html","deprecated":false},{"id":"namespace_Hello","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Hello.computedMethod","file":".","doc":"","url":"././~/Hello.computedMethod.html","deprecated":false},{"id":"namespace_Hello","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.world","file":".","doc":"","url":"././~/Hello.world.html","deprecated":false},{"id":"namespace_Hello","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.test","file":".","doc":"Some docs","url":"././~/Hello.test.html","deprecated":false},{"id":"namespace_Hello","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.ab","file":".","doc":"","url":"././~/Hello.ab.html","deprecated":false},{"id":"namespace_Hello","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.x","file":".","doc":"","url":"././~/Hello.x.html","deprecated":false},{"id":"namespace_InterfaceWithIndexSignature","kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"InterfaceWithIndexSignature","file":".","doc":"","url":"././~/InterfaceWithIndexSignature.html","deprecated":false},{"id":"namespace_Testing","kind":[{"char":"c","kind":"Class","title":"Class"},{"char":"N","kind":"Namespace","title":"Namespace"}],"name":"Testing","file":".","doc":"","url":"././~/Testing.html","deprecated":false},{"id":"namespace_Testing_t","kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.t","file":".","doc":"","url":"././~/Testing.t.html","deprecated":false},{"id":"namespace_TypeAlias","kind":[{"char":"T","kind":"TypeAlias","title":"Type Alias"}],"name":"TypeAlias","file":".","doc":"","url":"././~/TypeAlias.html","deprecated":false},{"id":"namespace_anotherVariable","kind":[{"char":"v","kind":"Variable","title":"Variable"}],"name":"anotherVariable","file":".","doc":"","url":"././~/anotherVariable.html","deprecated":false},{"id":"namespace_anotherVariable","kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"anotherVariable.bar","file":".","doc":"","url":"././~/anotherVariable.bar.html","deprecated":false},{"id":"namespace_anotherVariable","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"anotherVariable.foo","file":".","doc":"","url":"././~/anotherVariable.foo.html","deprecated":false},{"id":"namespace_c","kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"c","file":".","doc":"","url":"././~/c.html","deprecated":false},{"id":"namespace_d","kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"d","file":".","doc":"","url":"././~/d.html","deprecated":false},{"id":"namespace_functionWithOptionalParameters","kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"functionWithOptionalParameters","file":".","doc":"","url":"././~/functionWithOptionalParameters.html","deprecated":false},{"id":"namespace_qaz","kind":[{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"}],"name":"qaz","file":".","doc":"content","url":"././~/qaz.html","deprecated":false},{"id":"namespace_someVariable","kind":[{"char":"v","kind":"Variable","title":"Variable"}],"name":"someVariable","file":".","doc":"","url":"././~/someVariable.html","deprecated":false},{"id":"namespace_Testing_x","kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.x","file":"c","doc":"","url":"./c/~/Testing.x.html","deprecated":false},{"id":"namespace_x","kind":[{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"}],"name":"x","file":"c","doc":"","url":"./c/~/x.html","deprecated":false},{"id":"namespace_Testing_externalFunction","kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.externalFunction","file":"d","doc":"","url":"./d/~/Testing.externalFunction.html","deprecated":false},{"id":"namespace_externalFunction","kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"externalFunction","file":"d","doc":"","url":"./d/~/externalFunction.html","deprecated":false},{"id":"namespace_default","kind":[{"char":"v","kind":"Variable","title":"Variable"}],"name":"default","file":"foo","doc":"The default export item.This item reproduces the issue reported in https://github.com/jsr-io/jsr/issues/459","url":"./foo/~/default.html","deprecated":false}]}; })() diff --git a/tests/snapshots/html_test__html_doc_files_multiple-9.snap b/tests/snapshots/html_test__html_doc_files_multiple-9.snap index e0d53b72..3bcbbfa1 100644 --- a/tests/snapshots/html_test__html_doc_files_multiple-9.snap +++ b/tests/snapshots/html_test__html_doc_files_multiple-9.snap @@ -110,10 +110,10 @@ expression: files.get(file_name).unwrap() -Parameters
diff --git a/tests/snapshots/html_test__html_doc_files_single-13.snap b/tests/snapshots/html_test__html_doc_files_single-13.snap index e465acb3..13f7cecb 100644 --- a/tests/snapshots/html_test__html_doc_files_single-13.snap +++ b/tests/snapshots/html_test__html_doc_files_single-13.snap @@ -3,5 +3,5 @@ source: tests/html_test.rs expression: files.get(file_name).unwrap() --- (function () { - window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Bar","file":".","doc":"","url":"././~/Bar.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"```ts\nusing time = new FakeTime();\n```","url":"././~/Foo.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foobar","file":".","doc":"","url":"././~/Foobar.html","deprecated":false}]}; + window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"id":"namespace_Bar","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Bar","file":".","doc":"","url":"././~/Bar.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"","url":"././~/Foo.html","deprecated":false},{"id":"namespace_Foobar","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foobar","file":".","doc":"","url":"././~/Foobar.html","deprecated":false}]}; })() diff --git a/tests/snapshots/html_test__symbol_group.snap b/tests/snapshots/html_test__symbol_group.snap index 8faa0094..0df71bf7 100644 --- a/tests/snapshots/html_test__symbol_group.snap +++ b/tests/snapshots/html_test__symbol_group.snap @@ -63,12 +63,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_externalfunction_0_parameters__n", + "id": "function_externalfunction_0_parameter__n", "name": "_n", "name_href": null, "content": ": number = 0", "anchor": { - "id": "function_externalfunction_0_parameters__n" + "id": "function_externalfunction_0_parameter__n" }, "tags": [ { @@ -155,7 +155,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -165,7 +165,7 @@ expression: files { "level": 2, "content": "_n", - "anchor": "function_externalfunction_0_parameters__n" + "anchor": "function_externalfunction_0_parameter__n" }, { "level": 1, @@ -752,12 +752,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "methods_bar_0", + "id": "method_bar_0", "name": "bar", "name_href": "../././~/Baz.bar.html", "content": "(): InterfaceWithIndexSignature[\"test\"]", "anchor": { - "id": "methods_bar_0" + "id": "method_bar_0" }, "tags": [], "js_doc": null, @@ -804,7 +804,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -834,7 +834,7 @@ expression: files { "level": 2, "content": "bar", - "anchor": "methods_bar_0" + "anchor": "method_bar_0" } ] }, @@ -1487,12 +1487,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "property_quotgtltimg-srcx-onerroralert1gt", + "id": "property_"><img-src=x-onerror=alert(1)>", "name": "\"><img src=x onerror=alert(1)>", "name_href": "../././~/Foo.prototype.\">.html", "content": ": number", "anchor": { - "id": "property_quotgtltimg-srcx-onerroralert1gt" + "id": "property_"><img-src=x-onerror=alert(1)>" }, "tags": [], "js_doc": null, @@ -1629,12 +1629,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "method_symbol_iterator_0", + "id": "method_[symbol_iterator]_0", "name": "[Symbol.iterator]", "name_href": "../././~/Foo.prototype.[Symbol.iterator].html", "content": "(): void", "anchor": { - "id": "method_symbol_iterator_0" + "id": "method_[symbol_iterator]_0" }, "tags": [], "js_doc": null, @@ -1795,7 +1795,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -1840,7 +1840,7 @@ expression: files { "level": 2, "content": "\"><img src=x onerror=alert(1)>", - "anchor": "property_quotgtltimg-srcx-onerroralert1gt" + "anchor": "property_"><img-src=x-onerror=alert(1)>" }, { "level": 2, @@ -1885,7 +1885,7 @@ expression: files { "level": 2, "content": "[Symbol.iterator]", - "anchor": "method_symbol_iterator_0" + "anchor": "method_[symbol_iterator]_0" }, { "level": 2, @@ -2246,12 +2246,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "methods_optionalmethod_0", + "id": "method_optionalmethod_0", "name": "optionalMethod", "name_href": "../././~/Hello.optionalMethod.html", "content": "(): [string]", "anchor": { - "id": "methods_optionalmethod_0" + "id": "method_optionalmethod_0" }, "tags": [ { @@ -2262,12 +2262,12 @@ expression: files "source_href": null }, { - "id": "methods_computedmethod_1", + "id": "method_computedmethod_1", "name": "[computedMethod]", "name_href": "../././~/Hello.computedMethod.html", "content": "(a: T extends () => infer R ? R : any): void", "anchor": { - "id": "methods_computedmethod_1" + "id": "method_computedmethod_1" }, "tags": [ { @@ -2318,7 +2318,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -2378,12 +2378,12 @@ expression: files { "level": 2, "content": "optionalMethod", - "anchor": "methods_optionalmethod_0" + "anchor": "method_optionalmethod_0" }, { "level": 2, "content": "[computedMethod]", - "anchor": "methods_computedmethod_1" + "anchor": "method_computedmethod_1" } ] }, @@ -2773,12 +2773,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_externalfunction_0_parameters__n", + "id": "function_externalfunction_0_parameter__n", "name": "_n", "name_href": null, "content": ": number = 0", "anchor": { - "id": "function_externalfunction_0_parameters__n" + "id": "function_externalfunction_0_parameter__n" }, "tags": [ { @@ -2865,7 +2865,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -2875,7 +2875,7 @@ expression: files { "level": 2, "content": "_n", - "anchor": "function_externalfunction_0_parameters__n" + "anchor": "function_externalfunction_0_parameter__n" }, { "level": 1, @@ -3080,12 +3080,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_x_0_parameters__n", + "id": "function_x_0_parameter__n", "name": "_n", "name_href": null, "content": ": number = 0", "anchor": { - "id": "function_x_0_parameters__n" + "id": "function_x_0_parameter__n" }, "tags": [ { @@ -3172,7 +3172,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -3182,7 +3182,7 @@ expression: files { "level": 2, "content": "_n", - "anchor": "function_x_0_parameters__n" + "anchor": "function_x_0_parameter__n" }, { "level": 1, @@ -3385,12 +3385,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "methods_bar_0", + "id": "method_bar_0", "name": "bar", "name_href": "../././~/anotherVariable.bar.html", "content": "(): number", "anchor": { - "id": "methods_bar_0" + "id": "method_bar_0" }, "tags": [], "js_doc": null, @@ -3437,7 +3437,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -3457,7 +3457,7 @@ expression: files { "level": 2, "content": "bar", - "anchor": "methods_bar_0" + "anchor": "method_bar_0" } ] }, @@ -3711,12 +3711,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_d_0_parameters_foo", + "id": "function_d_0_parameter_foo", "name": "foo", "name_href": null, "content": ": number = 1", "anchor": { - "id": "function_d_0_parameters_foo" + "id": "function_d_0_parameter_foo" }, "tags": [ { @@ -3727,12 +3727,12 @@ expression: files "source_href": null }, { - "id": "function_d_0_parameters_bar", + "id": "function_d_0_parameter_bar", "name": "bar", "name_href": null, "content": ": string = bar", "anchor": { - "id": "function_d_0_parameters_bar" + "id": "function_d_0_parameter_bar" }, "tags": [ { @@ -3743,12 +3743,12 @@ expression: files "source_href": null }, { - "id": "function_d_0_parameters_baz", + "id": "function_d_0_parameter_baz", "name": "baz", "name_href": null, "content": ": { hello?: string; }", "anchor": { - "id": "function_d_0_parameters_baz" + "id": "function_d_0_parameter_baz" }, "tags": [ { @@ -3759,24 +3759,24 @@ expression: files "source_href": null }, { - "id": "function_d_0_parameters_qaz", + "id": "function_d_0_parameter_qaz", "name": "qaz", "name_href": null, "content": ": T", "anchor": { - "id": "function_d_0_parameters_qaz" + "id": "function_d_0_parameter_qaz" }, "tags": [], "js_doc": null, "source_href": null }, { - "id": "function_d_0_parameters____strings", + "id": "function_d_0_parameter_(___strings)", "name": "...strings", "name_href": null, "content": ": string[]", "anchor": { - "id": "function_d_0_parameters____strings" + "id": "function_d_0_parameter_(___strings)" }, "tags": [], "js_doc": null, @@ -3880,7 +3880,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -3915,27 +3915,27 @@ expression: files { "level": 2, "content": "foo", - "anchor": "function_d_0_parameters_foo" + "anchor": "function_d_0_parameter_foo" }, { "level": 2, "content": "bar", - "anchor": "function_d_0_parameters_bar" + "anchor": "function_d_0_parameter_bar" }, { "level": 2, "content": "baz", - "anchor": "function_d_0_parameters_baz" + "anchor": "function_d_0_parameter_baz" }, { "level": 2, "content": "qaz", - "anchor": "function_d_0_parameters_qaz" + "anchor": "function_d_0_parameter_qaz" }, { "level": 2, "content": "...strings", - "anchor": "function_d_0_parameters____strings" + "anchor": "function_d_0_parameter_(___strings)" }, { "level": 1, @@ -4012,12 +4012,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_functionwithoptionalparameters_0_parameters_foo", + "id": "function_functionwithoptionalparameters_0_parameter_foo", "name": "foo", "name_href": null, "content": ": number = 1", "anchor": { - "id": "function_functionwithoptionalparameters_0_parameters_foo" + "id": "function_functionwithoptionalparameters_0_parameter_foo" }, "tags": [ { @@ -4028,12 +4028,12 @@ expression: files "source_href": null }, { - "id": "function_functionwithoptionalparameters_0_parameters_bar", + "id": "function_functionwithoptionalparameters_0_parameter_bar", "name": "bar", "name_href": null, "content": ": number", "anchor": { - "id": "function_functionwithoptionalparameters_0_parameters_bar" + "id": "function_functionwithoptionalparameters_0_parameter_bar" }, "tags": [ { @@ -4044,12 +4044,12 @@ expression: files "source_href": null }, { - "id": "function_functionwithoptionalparameters_0_parameters_baz", + "id": "function_functionwithoptionalparameters_0_parameter_baz", "name": "baz", "name_href": null, "content": ": [number]", "anchor": { - "id": "function_functionwithoptionalparameters_0_parameters_baz" + "id": "function_functionwithoptionalparameters_0_parameter_baz" }, "tags": [ { @@ -4060,12 +4060,12 @@ expression: files "source_href": null }, { - "id": "function_functionwithoptionalparameters_0_parameters_unnamed-3", + "id": "function_functionwithoptionalparameters_0_parameter_(unnamed-3)", "name": "unnamed 3", "name_href": null, "content": ": string[]", "anchor": { - "id": "function_functionwithoptionalparameters_0_parameters_unnamed-3" + "id": "function_functionwithoptionalparameters_0_parameter_(unnamed-3)" }, "tags": [ { @@ -4076,12 +4076,12 @@ expression: files "source_href": null }, { - "id": "function_functionwithoptionalparameters_0_parameters_unnamed-4", + "id": "function_functionwithoptionalparameters_0_parameter_(unnamed-4)", "name": "unnamed 4", "name_href": null, "content": ": { qux: number; }", "anchor": { - "id": "function_functionwithoptionalparameters_0_parameters_unnamed-4" + "id": "function_functionwithoptionalparameters_0_parameter_(unnamed-4)" }, "tags": [ { @@ -4205,7 +4205,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -4215,27 +4215,27 @@ expression: files { "level": 2, "content": "foo", - "anchor": "function_functionwithoptionalparameters_0_parameters_foo" + "anchor": "function_functionwithoptionalparameters_0_parameter_foo" }, { "level": 2, "content": "bar", - "anchor": "function_functionwithoptionalparameters_0_parameters_bar" + "anchor": "function_functionwithoptionalparameters_0_parameter_bar" }, { "level": 2, "content": "baz", - "anchor": "function_functionwithoptionalparameters_0_parameters_baz" + "anchor": "function_functionwithoptionalparameters_0_parameter_baz" }, { "level": 2, "content": "unnamed 3", - "anchor": "function_functionwithoptionalparameters_0_parameters_unnamed-3" + "anchor": "function_functionwithoptionalparameters_0_parameter_(unnamed-3)" }, { "level": 2, "content": "unnamed 4", - "anchor": "function_functionwithoptionalparameters_0_parameters_unnamed-4" + "anchor": "function_functionwithoptionalparameters_0_parameter_(unnamed-4)" }, { "level": 1, @@ -4317,12 +4317,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_qaz_0_parameters_a", + "id": "function_qaz_0_parameter_a", "name": "a", "name_href": null, "content": ": string", "anchor": { - "id": "function_qaz_0_parameters_a" + "id": "function_qaz_0_parameter_a" }, "tags": [], "js_doc": null, @@ -4373,12 +4373,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_qaz_1_parameters_a", + "id": "function_qaz_1_parameter_a", "name": "a", "name_href": null, "content": ": number", "anchor": { - "id": "function_qaz_1_parameters_a" + "id": "function_qaz_1_parameter_a" }, "tags": [], "js_doc": null, @@ -4442,7 +4442,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 0, @@ -4457,7 +4457,7 @@ expression: files { "level": 2, "content": "a", - "anchor": "function_qaz_0_parameters_a" + "anchor": "function_qaz_0_parameter_a" }, { "level": 1, @@ -4477,7 +4477,7 @@ expression: files { "level": 2, "content": "a", - "anchor": "function_qaz_1_parameters_a" + "anchor": "function_qaz_1_parameter_a" }, { "level": 1, @@ -4629,12 +4629,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_x_0_parameters__n", + "id": "function_x_0_parameter__n", "name": "_n", "name_href": null, "content": ": number = 0", "anchor": { - "id": "function_x_0_parameters__n" + "id": "function_x_0_parameter__n" }, "tags": [ { @@ -4715,7 +4715,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -4725,7 +4725,7 @@ expression: files { "level": 2, "content": "_n", - "anchor": "function_x_0_parameters__n" + "anchor": "function_x_0_parameter__n" }, { "level": 1, @@ -5062,12 +5062,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_abstractclass_prototype_method_0_parameters_s", + "id": "function_abstractclass_prototype_method_0_parameter_s", "name": "s", "name_href": null, "content": ": number | string", "anchor": { - "id": "function_abstractclass_prototype_method_0_parameters_s" + "id": "function_abstractclass_prototype_method_0_parameter_s" }, "tags": [], "js_doc": null, @@ -5156,7 +5156,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -5166,7 +5166,7 @@ expression: files { "level": 2, "content": "s", - "anchor": "function_abstractclass_prototype_method_0_parameters_s" + "anchor": "function_abstractclass_prototype_method_0_parameter_s" }, { "level": 1, @@ -6300,12 +6300,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_foo_prototype_getterandsetter_0_parameters_s", + "id": "function_foo_prototype_getterandsetter_0_parameter_s", "name": "s", "name_href": null, "content": "", "anchor": { - "id": "function_foo_prototype_getterandsetter_0_parameters_s" + "id": "function_foo_prototype_getterandsetter_0_parameter_s" }, "tags": [], "js_doc": null, @@ -6394,7 +6394,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -6409,7 +6409,7 @@ expression: files { "level": 2, "content": "s", - "anchor": "function_foo_prototype_getterandsetter_0_parameters_s" + "anchor": "function_foo_prototype_getterandsetter_0_parameter_s" }, { "level": 1, @@ -6481,12 +6481,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_foo_prototype_methodwithoverloads_0_parameters_s", + "id": "function_foo_prototype_methodwithoverloads_0_parameter_s", "name": "s", "name_href": null, "content": ": number", "anchor": { - "id": "function_foo_prototype_methodwithoverloads_0_parameters_s" + "id": "function_foo_prototype_methodwithoverloads_0_parameter_s" }, "tags": [], "js_doc": null, @@ -6550,12 +6550,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_foo_prototype_methodwithoverloads_1_parameters_s", + "id": "function_foo_prototype_methodwithoverloads_1_parameter_s", "name": "s", "name_href": null, "content": ": string", "anchor": { - "id": "function_foo_prototype_methodwithoverloads_1_parameters_s" + "id": "function_foo_prototype_methodwithoverloads_1_parameter_s" }, "tags": [], "js_doc": null, @@ -6644,7 +6644,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 0, @@ -6659,7 +6659,7 @@ expression: files { "level": 2, "content": "s", - "anchor": "function_foo_prototype_methodwithoverloads_0_parameters_s" + "anchor": "function_foo_prototype_methodwithoverloads_0_parameter_s" }, { "level": 1, @@ -6679,7 +6679,7 @@ expression: files { "level": 2, "content": "s", - "anchor": "function_foo_prototype_methodwithoverloads_1_parameters_s" + "anchor": "function_foo_prototype_methodwithoverloads_1_parameter_s" }, { "level": 1, @@ -7003,12 +7003,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_foo_prototype_setter_0_parameters_s", + "id": "function_foo_prototype_setter_0_parameter_s", "name": "s", "name_href": null, "content": ": string", "anchor": { - "id": "function_foo_prototype_setter_0_parameters_s" + "id": "function_foo_prototype_setter_0_parameter_s" }, "tags": [], "js_doc": null, @@ -7097,7 +7097,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -7107,7 +7107,7 @@ expression: files { "level": 2, "content": "s", - "anchor": "function_foo_prototype_setter_0_parameters_s" + "anchor": "function_foo_prototype_setter_0_parameter_s" }, { "level": 1, @@ -7451,12 +7451,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_foo_staticsetter_0_parameters_s", + "id": "function_foo_staticsetter_0_parameter_s", "name": "s", "name_href": null, "content": ": number", "anchor": { - "id": "function_foo_staticsetter_0_parameters_s" + "id": "function_foo_staticsetter_0_parameter_s" }, "tags": [], "js_doc": null, @@ -7539,7 +7539,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -7549,7 +7549,7 @@ expression: files { "level": 2, "content": "s", - "anchor": "function_foo_staticsetter_0_parameters_s" + "anchor": "function_foo_staticsetter_0_parameter_s" }, { "level": 1, @@ -7741,12 +7741,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_hello_computedmethod_0_parameters_a", + "id": "function_hello_computedmethod_0_parameter_a", "name": "a", "name_href": null, "content": ": T extends () => infer R ? R : any", "anchor": { - "id": "function_hello_computedmethod_0_parameters_a" + "id": "function_hello_computedmethod_0_parameter_a" }, "tags": [], "js_doc": null, @@ -7829,7 +7829,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -7839,7 +7839,7 @@ expression: files { "level": 2, "content": "a", - "anchor": "function_hello_computedmethod_0_parameters_a" + "anchor": "function_hello_computedmethod_0_parameter_a" }, { "level": 1, @@ -8775,12 +8775,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_x_0_parameters__n", + "id": "function_x_0_parameter__n", "name": "_n", "name_href": null, "content": ": number = 0", "anchor": { - "id": "function_x_0_parameters__n" + "id": "function_x_0_parameter__n" }, "tags": [ { @@ -8867,7 +8867,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -8877,7 +8877,7 @@ expression: files { "level": 2, "content": "_n", - "anchor": "function_x_0_parameters__n" + "anchor": "function_x_0_parameter__n" }, { "level": 1, @@ -8949,12 +8949,12 @@ expression: files "kind": "doc_entry", "content": [ { - "id": "function_x_0_parameters__n", + "id": "function_x_0_parameter__n", "name": "_n", "name_href": null, "content": ": number = 0", "anchor": { - "id": "function_x_0_parameters__n" + "id": "function_x_0_parameter__n" }, "tags": [ { @@ -9041,7 +9041,7 @@ expression: files "composed": false }, "top_symbols": null, - "document_navigation_str": "", + "document_navigation_str": "", "document_navigation": [ { "level": 1, @@ -9051,7 +9051,7 @@ expression: files { "level": 2, "content": "_n", - "anchor": "function_x_0_parameters__n" + "anchor": "function_x_0_parameter__n" }, { "level": 1, diff --git a/tests/snapshots/html_test__symbol_search.snap b/tests/snapshots/html_test__symbol_search.snap index 79c2c6c0..a44fd421 100644 --- a/tests/snapshots/html_test__symbol_search.snap +++ b/tests/snapshots/html_test__symbol_search.snap @@ -6,6 +6,7 @@ expression: search_index "kind": "search", "nodes": [ { + "id": "namespace_A", "kind": [ { "char": "c", @@ -20,6 +21,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_AbstractClass", "kind": [ { "char": "c", @@ -34,6 +36,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_AbstractClass", "kind": [ { "char": "m", @@ -48,6 +51,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_AbstractClass", "kind": [ { "char": "m", @@ -62,6 +66,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_AbstractClass", "kind": [ { "char": "p", @@ -76,6 +81,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_B", "kind": [ { "char": "c", @@ -90,6 +96,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Bar", "kind": [ { "char": "c", @@ -99,11 +106,12 @@ expression: search_index ], "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", + "doc": "Some quote in bar docs This quote part is ignored when getting the title of this docBar docs", "url": "././~/Bar.html", "deprecated": false }, { + "id": "namespace_Baz", "kind": [ { "char": "T", @@ -118,6 +126,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Baz", "kind": [ { "char": "m", @@ -132,6 +141,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Baz", "kind": [ { "char": "p", @@ -146,6 +156,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_CompoundType", "kind": [ { "char": "I", @@ -165,6 +176,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_CompoundType", "kind": [ { "char": "p", @@ -179,6 +191,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_EmptyInterface", "kind": [ { "char": "I", @@ -193,6 +206,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Enum", "kind": [ { "char": "E", @@ -207,6 +221,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Enum2", "kind": [ { "char": "E", @@ -221,6 +236,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "c", @@ -230,11 +246,12 @@ expression: search_index ], "name": "Foo", "file": ".", - "doc": "some Foo docs {@linkcode Bar}\n", + "doc": "some Foo docs Bar", "url": "././~/Foo.html", "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -249,6 +266,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -263,6 +281,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -277,6 +296,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -291,6 +311,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -305,6 +326,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -319,6 +341,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -333,6 +356,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -347,6 +371,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -361,6 +386,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -375,6 +401,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "m", @@ -389,6 +416,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "p", @@ -403,6 +431,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "p", @@ -417,6 +446,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "p", @@ -431,6 +461,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "p", @@ -445,6 +476,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foo", "kind": [ { "char": "p", @@ -459,6 +491,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Foobar", "kind": [ { "char": "c", @@ -468,11 +501,12 @@ expression: search_index ], "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\n# heading\n\ncontent\n\n## sub heading\n", + "doc": "Foobar docsheadingcontentsub heading", "url": "././~/Foobar.html", "deprecated": false }, { + "id": "namespace_Hello", "kind": [ { "char": "I", @@ -487,6 +521,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Hello", "kind": [ { "char": "m", @@ -501,6 +536,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Hello", "kind": [ { "char": "m", @@ -515,6 +551,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Hello", "kind": [ { "char": "p", @@ -529,6 +566,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Hello", "kind": [ { "char": "p", @@ -543,6 +581,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Hello", "kind": [ { "char": "p", @@ -557,6 +596,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Hello", "kind": [ { "char": "p", @@ -571,6 +611,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_InterfaceWithIndexSignature", "kind": [ { "char": "I", @@ -585,6 +626,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Testing", "kind": [ { "char": "c", @@ -604,6 +646,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Testing_t", "kind": [ { "char": "f", @@ -618,6 +661,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_TypeAlias", "kind": [ { "char": "T", @@ -632,6 +676,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_anotherVariable", "kind": [ { "char": "v", @@ -646,6 +691,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_anotherVariable", "kind": [ { "char": "m", @@ -660,6 +706,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_anotherVariable", "kind": [ { "char": "p", @@ -674,6 +721,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_c", "kind": [ { "char": "f", @@ -688,6 +736,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_d", "kind": [ { "char": "f", @@ -702,6 +751,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_functionWithOptionalParameters", "kind": [ { "char": "f", @@ -716,6 +766,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_qaz", "kind": [ { "char": "f", @@ -735,11 +786,12 @@ expression: search_index ], "name": "qaz", "file": ".", - "doc": "content\n", + "doc": "content", "url": "././~/qaz.html", "deprecated": false }, { + "id": "namespace_someVariable", "kind": [ { "char": "v", @@ -754,6 +806,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Testing_externalFunction", "kind": [ { "char": "f", @@ -768,6 +821,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_externalFunction", "kind": [ { "char": "f", @@ -782,6 +836,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_Testing_x", "kind": [ { "char": "f", @@ -796,6 +851,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_x", "kind": [ { "char": "f", @@ -820,6 +876,7 @@ expression: search_index "deprecated": false }, { + "id": "namespace_default", "kind": [ { "char": "v", @@ -829,7 +886,7 @@ expression: search_index ], "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}", + "doc": "The default export item.This item reproduces the issue reported in https://github.com/jsr-io/jsr/issues/459", "url": "./foo/~/default.html", "deprecated": false } From 556127c9fc078a4340bb73dbeef78c530195c15e Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Thu, 15 May 2025 23:54:18 +0200 Subject: [PATCH 2/4] clean --- src/html/jsdoc.rs | 1 - src/html/symbols/class.rs | 2 -- src/html/util.rs | 1 - 3 files changed, 4 deletions(-) diff --git a/src/html/jsdoc.rs b/src/html/jsdoc.rs index 55e83a8a..4cbd1556 100644 --- a/src/html/jsdoc.rs +++ b/src/html/jsdoc.rs @@ -297,7 +297,6 @@ impl ExampleCtx { pub const TEMPLATE: &'static str = "example"; pub fn new(render_ctx: &RenderContext, example: &str, i: usize) -> Self { - // Using the context-aware builder with the Example kind let id = IdBuilder::new(render_ctx.ctx) .kind(IdKind::Example) .index(i) diff --git a/src/html/symbols/class.rs b/src/html/symbols/class.rs index 646ffde5..c2354f65 100644 --- a/src/html/symbols/class.rs +++ b/src/html/symbols/class.rs @@ -16,8 +16,6 @@ pub(crate) fn render_class( doc_node: &DocNodeWithContext, name: &str, ) -> Vec { - // Use IdKind::Class to ensure the enum variant is considered used - let _id_kind = IdKind::Class; // This will be optimized out in a release build let class_def = doc_node.class_def().unwrap(); let current_type_params = class_def diff --git a/src/html/util.rs b/src/html/util.rs index 12d2aed6..aaa2d3ea 100644 --- a/src/html/util.rs +++ b/src/html/util.rs @@ -157,7 +157,6 @@ impl AsRef for Id { } } -/// Sanitize a component for use in an ID fn sanitize_id_part(part: &str) -> String { html_escape::encode_quoted_attribute(&TARGET_RE.replace_all(part, "_")) .into_owned() From 46ad81a62e98a37c57af8fc5ff15c1d28a5668ab Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Thu, 15 May 2025 23:58:09 +0200 Subject: [PATCH 3/4] fix JS --- js/mod.ts | 4 ++++ lib/lib.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/js/mod.ts b/js/mod.ts index 7d146cea..e92f030a 100644 --- a/js/mod.ts +++ b/js/mod.ts @@ -283,6 +283,8 @@ export interface GenerateOptions { ): string | undefined; /** Function to strip markdown. */ markdownStripper(md: string): string; + /** Prefix for IDs of elements. */ + idPrefix?: string; } const defaultUsageComposer: UsageComposer = { @@ -331,6 +333,7 @@ export async function generateHtml( options.markdownRenderer, options.markdownStripper, options.headInject, + options.idPrefix, docNodesByUrl, false, ); @@ -368,6 +371,7 @@ export async function generateHtmlAsJSON( options.markdownRenderer, options.markdownStripper, options.headInject, + options.idPrefix, docNodesByUrl, true, ); diff --git a/lib/lib.rs b/lib/lib.rs index 02b3c8bf..dedb7514 100644 --- a/lib/lib.rs +++ b/lib/lib.rs @@ -292,6 +292,7 @@ pub fn generate_html( markdown_renderer: js_sys::Function, markdown_stripper: js_sys::Function, head_inject: Option, + id_prefix: Option, doc_nodes_by_url: JsValue, @@ -317,6 +318,7 @@ pub fn generate_html( markdown_renderer, markdown_stripper, head_inject, + id_prefix, doc_nodes_by_url, json, ) @@ -532,6 +534,7 @@ fn generate_html_inner( markdown_renderer: js_sys::Function, markdown_stripper: js_sys::Function, head_inject: Option, + id_prefix: Option, doc_nodes_by_url: JsValue, @@ -642,6 +645,7 @@ fn generate_html_inner( markdown_renderer, markdown_stripper, head_inject, + id_prefix, }, doc_nodes_by_url, )?; From c690a342782eac906f35ee5fe682f7337e3c2b73 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Fri, 16 May 2025 00:23:19 +0200 Subject: [PATCH 4/4] lint --- src/html/search.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html/search.rs b/src/html/search.rs index f6954d22..0187e20a 100644 --- a/src/html/search.rs +++ b/src/html/search.rs @@ -57,7 +57,7 @@ pub fn doc_nodes_into_search_index_node( super::util::all_deprecated(&doc_nodes.iter().collect::>()); let doc = super::jsdoc::strip( - &ctx, + ctx, &doc_nodes[0].js_doc.doc.clone().unwrap_or_default(), ) .into_boxed_str();