diff --git a/Cargo.lock b/Cargo.lock index 1471dfb0..92c6d92d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -554,6 +554,7 @@ dependencies = [ "import_map", "indexmap 2.1.0", "insta", + "itoa", "lazy_static", "pretty_assertions", "regex", diff --git a/Cargo.toml b/Cargo.toml index 488ee8db..c910e8cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,7 @@ tree-sitter-md = { version = "0.1.7", optional = true } tree-sitter-rust = { version = "0.20.4", optional = true } tree-sitter-html = { version = "0.20.0", optional = true } tree-sitter-bash = { version = "0.20.5", optional = true } +itoa = "1.0.10" [dev-dependencies] anyhow = { version = "1.0.58" } diff --git a/examples/ddoc/main.rs b/examples/ddoc/main.rs index a63d179c..415d803e 100644 --- a/examples/ddoc/main.rs +++ b/examples/ddoc/main.rs @@ -150,9 +150,9 @@ async fn run() -> anyhow::Result<()> { doc_nodes.extend(nodes); } - doc_nodes.retain(|doc_node| doc_node.kind != DocNodeKind::Import); + doc_nodes.retain(|doc_node| doc_node.kind() != DocNodeKind::Import); if let Some(filter) = maybe_filter { - doc_nodes = find_nodes_by_name_recursively(doc_nodes, filter.to_string()); + doc_nodes = find_nodes_by_name_recursively(doc_nodes, filter); } let result = DocPrinter::new(&doc_nodes, true, false); @@ -201,7 +201,7 @@ impl HrefResolver for EmptyResolver { } fn resolve_source(&self, location: &deno_doc::Location) -> Option { - Some(location.filename.clone()) + Some(location.filename.to_string()) } } diff --git a/src/class.rs b/src/class.rs index 824a688b..aac19775 100644 --- a/src/class.rs +++ b/src/class.rs @@ -113,14 +113,14 @@ pub struct ClassPropertyDef { pub ts_type: Option, pub readonly: bool, pub accessibility: Option, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub decorators: Vec, + #[serde(skip_serializing_if = "<[_]>::is_empty", default)] + pub decorators: Box<[DecoratorDef]>, pub optional: bool, pub is_abstract: bool, pub is_static: bool, #[serde(skip_serializing_if = "is_false", default)] pub is_override: bool, - pub name: String, + pub name: Box, pub location: Location, } @@ -172,7 +172,7 @@ pub struct ClassMethodDef { pub is_static: bool, #[serde(skip_serializing_if = "is_false", default)] pub is_override: bool, - pub name: String, + pub name: Box, pub kind: deno_ast::swc::ast::MethodKind, pub function_def: FunctionDef, pub location: Location, @@ -220,24 +220,24 @@ impl Display for ClassMethodDef { pub struct ClassDef { #[serde(skip_serializing_if = "Option::is_none", default)] /// set when the class is a default export and has a name in its declaration - pub def_name: Option, + pub def_name: Option>, pub is_abstract: bool, - pub constructors: Vec, - pub properties: Vec, - pub index_signatures: Vec, - pub methods: Vec, - pub extends: Option, - pub implements: Vec, - pub type_params: Vec, - pub super_type_params: Vec, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub decorators: Vec, + pub constructors: Box<[ClassConstructorDef]>, + pub properties: Box<[ClassPropertyDef]>, + pub index_signatures: Box<[IndexSignatureDef]>, + pub methods: Box<[ClassMethodDef]>, + pub extends: Option>, + pub implements: Box<[TsTypeDef]>, + pub type_params: Box<[TsTypeParamDef]>, + pub super_type_params: Box<[TsTypeDef]>, + #[serde(skip_serializing_if = "<[_]>::is_empty", default)] + pub decorators: Box<[DecoratorDef]>, } pub fn class_to_class_def( parsed_source: &ParsedSource, class: &deno_ast::swc::ast::Class, - def_name: Option, + def_name: Option>, ) -> (ClassDef, JsDoc) { use deno_ast::swc::ast::Expr; @@ -262,10 +262,10 @@ pub fn class_to_class_def( } } - let extends: Option = match &class.super_class { + let extends: Option> = match &class.super_class { Some(boxed) => { let expr: &Expr = boxed; - walk_class_extends(expr) + walk_class_extends(expr).map(|s| s.into_boxed_str()) } None => None, }; @@ -274,7 +274,7 @@ pub fn class_to_class_def( .implements .iter() .map(|expr| TsTypeDef::ts_expr_with_type_args(parsed_source, expr)) - .collect::>(); + .collect::>(); for member in &class.body { use deno_ast::swc::ast::ClassMember::*; @@ -351,7 +351,7 @@ pub fn class_to_class_def( is_abstract: class_method.is_abstract, is_static: class_method.is_static, is_override: class_method.is_override, - name: method_name, + name: method_name.into_boxed_str(), kind: class_method.kind, function_def: fn_def, location: get_location(parsed_source, class_method.start()), @@ -388,7 +388,7 @@ pub fn class_to_class_def( is_static: class_prop.is_static, is_override: class_prop.is_override, accessibility: class_prop.accessibility, - name: prop_name, + name: prop_name.into_boxed_str(), decorators, location: get_location(parsed_source, class_prop.start()), }; @@ -453,10 +453,10 @@ pub fn class_to_class_def( is_abstract: class.is_abstract, extends, implements, - constructors, - properties, - index_signatures, - methods, + constructors: constructors.into_boxed_slice(), + properties: properties.into_boxed_slice(), + index_signatures: index_signatures.into_boxed_slice(), + methods: methods.into_boxed_slice(), type_params, super_type_params, decorators, diff --git a/src/decorators.rs b/src/decorators.rs index f597e4ea..e59fc490 100644 --- a/src/decorators.rs +++ b/src/decorators.rs @@ -83,7 +83,7 @@ impl DecoratorDef { pub fn decorators_to_defs( parsed_source: &ParsedSource, decorators: &[Decorator], -) -> Vec { +) -> Box<[DecoratorDef]> { decorators .iter() .map(|d| DecoratorDef::from_ast_decorator(parsed_source, d)) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index f4d64033..27aac064 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -243,7 +243,10 @@ impl<'a> DiagnosticsCollector<'a> { }) // should never happen, but just in case .unwrap_or_else(|| Location { - filename: referenced_module.specifier().to_string(), + filename: referenced_module + .specifier() + .to_string() + .into_boxed_str(), line: 1, col: 0, byte_index: 0, @@ -364,8 +367,9 @@ impl<'a, 'b> DiagnosticDocNodeVisitor<'a, 'b> { } if let Some(last_node) = last_node { - if doc_node.name == last_node.name && last_node.function_def.is_some() { - if let Some(current_fn) = &doc_node.function_def { + if doc_node.name == last_node.name && last_node.function_def().is_some() + { + if let Some(current_fn) = &doc_node.function_def() { if current_fn.has_body { continue; // it's an overload. Ignore it } @@ -399,29 +403,29 @@ impl<'a, 'b> DiagnosticDocNodeVisitor<'a, 'b> { return; // skip, we don't do these diagnostics above private nodes } - if is_js_docable_kind(&doc_node.kind) { + if is_js_docable_kind(&doc_node.kind()) { self .diagnostics .check_missing_js_doc(&doc_node.js_doc, &doc_node.location); } - if let Some(def) = &doc_node.class_def { + if let Some(def) = &doc_node.class_def() { self.visit_class_def(def); } - if let Some(def) = &doc_node.function_def { + if let Some(def) = &doc_node.function_def() { self.visit_function_def(doc_node, def); } - if let Some(def) = &doc_node.interface_def { + if let Some(def) = &doc_node.interface_def() { self.visit_interface_def(def); } - if let Some(def) = &doc_node.namespace_def { + if let Some(def) = &doc_node.namespace_def() { self.visit_namespace_def(def); } - if let Some(def) = &doc_node.variable_def { + if let Some(def) = &doc_node.variable_def() { self.visit_variable_def(doc_node, def); } } @@ -439,7 +443,7 @@ impl<'a, 'b> DiagnosticDocNodeVisitor<'a, 'b> { } // properties - for prop in &def.properties { + for prop in def.properties.iter() { if prop.accessibility == Some(Accessibility::Private) { continue; // don't do diagnostics for private types } @@ -454,7 +458,7 @@ impl<'a, 'b> DiagnosticDocNodeVisitor<'a, 'b> { } // index signatures - for sig in &def.index_signatures { + for sig in def.index_signatures.iter() { self .diagnostics .check_missing_js_doc(&sig.js_doc, &sig.location); @@ -467,9 +471,9 @@ impl<'a, 'b> DiagnosticDocNodeVisitor<'a, 'b> { // methods let mut last_name: Option<&str> = None; - for method in &def.methods { + for method in def.methods.iter() { if let Some(last_name) = last_name { - if method.name == last_name && method.function_def.has_body { + if &*method.name == last_name && method.function_def.has_body { continue; // skip, it's the implementation signature } } diff --git a/src/function.rs b/src/function.rs index 60378d56..008b1b86 100644 --- a/src/function.rs +++ b/src/function.rs @@ -26,9 +26,9 @@ pub struct FunctionDef { pub has_body: bool, pub is_async: bool, pub is_generator: bool, - pub type_params: Vec, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub decorators: Vec, + pub type_params: Box<[TsTypeParamDef]>, + #[serde(skip_serializing_if = "<[_]>::is_empty", default)] + pub decorators: Box<[DecoratorDef]>, } pub fn function_to_function_def( @@ -58,7 +58,7 @@ pub fn function_to_function_def( repr: "Promise".to_string(), kind: Some(crate::ts_type::TsTypeDefKind::TypeRef), type_ref: Some(crate::ts_type::TsTypeRefDef { - type_params: Some(vec![TsTypeDef::keyword("void")]), + type_params: Some(Box::new([TsTypeDef::keyword("void")])), type_name: "Promise".to_string(), }), ..Default::default() diff --git a/src/html/comrak_adapters.rs b/src/html/comrak_adapters.rs index 5a46d37b..0e113a93 100644 --- a/src/html/comrak_adapters.rs +++ b/src/html/comrak_adapters.rs @@ -115,7 +115,7 @@ impl SyntaxHighlighterAdapter for HighlightAdapter { let mut highlighter = syntect::easy::HighlightLines::new(syntax, theme); match self.highlight_html( - syntect::util::LinesWithEndings::from(&code), + syntect::util::LinesWithEndings::from(code), |lines, line| { let regions = highlighter.highlight_line(line, &self.syntax_set)?; syntect::html::append_highlighted_html_for_styled_line( @@ -131,7 +131,7 @@ impl SyntaxHighlighterAdapter for HighlightAdapter { Err(_) => output.write_all(code.as_bytes())?, } - self.write_button(output, &code) + self.write_button(output, code) } #[cfg(all(feature = "tree-sitter", not(feature = "syntect")))] @@ -232,11 +232,40 @@ pub struct ToCEntry { pub anchor: String, } +#[derive(Default)] +pub struct Anchorizer { + map: HashMap, + itoa_buffer: itoa::Buffer, +} + +impl Anchorizer { + /// Returns a String that has been converted into an anchor using the GFM algorithm. + /// This replaces comrak's implementation to improve the performance. + /// @see https://docs.rs/comrak/latest/comrak/struct.Anchorizer.html#method.anchorize + pub fn anchorize(&mut self, s: &str) -> String { + let mut s = REJECTED_CHARS + .replace_all(&s.to_lowercase(), "") + .replace(' ', "-"); + + if let Some(count) = self.map.get_mut(&s) { + let a = self.itoa_buffer.format(*count); + s.push('-'); + s.push_str(a); + + *count += 1; + } else { + self.map.insert(s.clone(), 1); + } + + s + } +} + #[derive(Clone)] pub struct HeadingToCAdapter { toc: Arc>>, - anchorizer: Arc>, offset: Arc>, + anchorizer: Arc>, } impl Default for HeadingToCAdapter { @@ -249,18 +278,18 @@ 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(); +} + impl HeadingToCAdapter { - pub fn anchorize(&self, content: String) -> String { + pub fn anchorize(&self, content: &str) -> String { let mut anchorizer = self.anchorizer.lock().unwrap(); - anchorizer.anchorize(content.clone()) + anchorizer.anchorize(content) } - pub fn add_entry( - &self, - level: u8, - content: String, - anchor: String, - ) -> String { + pub fn add_entry(&self, level: u8, content: &str, anchor: &str) { let mut toc = self.toc.lock().unwrap(); let mut offset = self.offset.lock().unwrap(); @@ -269,12 +298,10 @@ impl HeadingToCAdapter { if toc.last().map_or(true, |toc| toc.content != content) { toc.push(ToCEntry { level, - content, - anchor: anchor.clone(), + content: content.to_owned(), + anchor: anchor.to_owned(), }); } - - anchor } pub fn render(self) -> Option { @@ -322,7 +349,7 @@ impl HeadingAdapter for HeadingToCAdapter { let mut anchorizer = self.anchorizer.lock().unwrap(); let offset = self.offset.lock().unwrap(); - let anchor = anchorizer.anchorize(heading.content.clone()); + let anchor = anchorizer.anchorize(&heading.content); writeln!(output, r#""#, heading.level)?; let mut toc = self.toc.lock().unwrap(); diff --git a/src/html/jsdoc.rs b/src/html/jsdoc.rs index ca753d23..49536028 100644 --- a/src/html/jsdoc.rs +++ b/src/html/jsdoc.rs @@ -26,6 +26,74 @@ lazy_static! { regex::Regex::new(r"(^\.{0,2}\/)|(^[A-Za-z]+:\S)").unwrap(); static ref MODULE_LINK_RE: regex::Regex = regex::Regex::new(r"^\[(\S+)\](?:\.(\S+)|\s|)$").unwrap(); + + #[cfg(feature = "ammonia")] + static ref AMMONIA: ammonia::Builder<'static> = { + let mut ammonia_builder = ammonia::Builder::default(); + + ammonia_builder + .add_tags(["video", "button", "svg", "path", "rect"]) + .add_generic_attributes(["id", "align"]) + .add_tag_attributes("button", ["data-copy"]) + .add_tag_attributes( + "svg", + [ + "width", + "height", + "viewBox", + "fill", + "xmlns", + "stroke", + "stroke-width", + "stroke-linecap", + "stroke-linejoin", + ], + ) + .add_tag_attributes( + "path", + [ + "d", + "fill", + "fill-rule", + "clip-rule", + "stroke", + "stroke-width", + "stroke-linecap", + "stroke-linejoin", + ], + ) + .add_tag_attributes("rect", ["x", "y", "width", "height", "fill"]) + .add_tag_attributes("video", ["src", "controls"]) + .add_allowed_classes("pre", ["highlight"]) + .add_allowed_classes("button", ["context_button"]) + .add_allowed_classes( + "div", + [ + "alert", + "alert-note", + "alert-tip", + "alert-important", + "alert-warning", + "alert-caution", + ], + ) + .link_rel(Some("nofollow")) + .url_relative( + ammonia::UrlRelative::Custom(Box::new(AmmoniaRelativeUrlEvaluator()))); + + #[cfg(feature = "syntect")] + ammonia_builder.add_tag_attributes("span", ["style"]); + + #[cfg(feature = "tree-sitter")] + ammonia_builder.add_allowed_classes("span", super::tree_sitter::CLASSES); + + ammonia_builder + }; +} + +thread_local! { + static CURRENT_FILE: RefCell>> = RefCell::new(None); + static URL_REWRITER: RefCell>> = RefCell::new(None); } fn parse_links<'a>(md: &'a str, ctx: &RenderContext) -> Cow<'a, str> { @@ -147,15 +215,23 @@ fn split_markdown_title( } #[cfg(feature = "ammonia")] -struct AmmoniaRelativeUrlEvaluator { - current_file: Option, - url_rewriter: URLRewriter, -} +struct AmmoniaRelativeUrlEvaluator(); #[cfg(feature = "ammonia")] impl ammonia::UrlRelativeEvaluate for AmmoniaRelativeUrlEvaluator { fn evaluate<'a>(&self, url: &'a str) -> Option> { - Some((self.url_rewriter)(self.current_file.as_ref(), url).into()) + URL_REWRITER.with(|url_rewriter| { + if let Some(url_rewriter) = url_rewriter.borrow().as_ref().unwrap() { + CURRENT_FILE.with(|current_file| { + Some( + url_rewriter(current_file.borrow().as_ref().unwrap().as_ref(), url) + .into(), + ) + }) + } else { + Some(Cow::Borrowed(url)) + } + }) } } @@ -374,10 +450,13 @@ pub fn markdown_to_html( } let mut plugins = comrak::Plugins::default(); - plugins.render.codefence_syntax_highlighter = - Some(&render_ctx.ctx.highlight_adapter); - if !render_options.no_toc { - plugins.render.heading_adapter = Some(&render_ctx.toc); + + if !render_options.summary { + plugins.render.codefence_syntax_highlighter = + Some(&render_ctx.ctx.highlight_adapter); + if !render_options.no_toc { + plugins.render.heading_adapter = Some(&render_ctx.toc); + } } let md = parse_links(md, render_ctx); @@ -400,7 +479,7 @@ pub fn markdown_to_html( "markdown" }; - let mut html = { + let html = { let arena = Arena::new(); let root = comrak::parse_document(&arena, md, &options); @@ -411,75 +490,24 @@ pub fn markdown_to_html( #[cfg(feature = "ammonia")] { - let mut ammonia_builder = ammonia::Builder::default(); - - ammonia_builder - .add_tags(["video", "button", "svg", "path", "rect"]) - .add_generic_attributes(["id", "align"]) - .add_tag_attributes("button", ["data-copy"]) - .add_tag_attributes( - "svg", - [ - "width", - "height", - "viewBox", - "fill", - "xmlns", - "stroke", - "stroke-width", - "stroke-linecap", - "stroke-linejoin", - ], - ) - .add_tag_attributes( - "path", - [ - "d", - "fill", - "fill-rule", - "clip-rule", - "stroke", - "stroke-width", - "stroke-linecap", - "stroke-linejoin", - ], - ) - .add_tag_attributes("rect", ["x", "y", "width", "height", "fill"]) - .add_tag_attributes("video", ["src", "controls"]) - .add_allowed_classes("pre", ["highlight"]) - .add_allowed_classes("button", ["context_button"]) - .add_allowed_classes( - "div", - [ - "alert", - "alert-note", - "alert-tip", - "alert-important", - "alert-warning", - "alert-caution", - ], - ) - .link_rel(Some("nofollow")) - .url_relative(render_ctx.ctx.url_rewriter.as_ref().map_or( - ammonia::UrlRelative::PassThrough, - |url_rewriter| { - ammonia::UrlRelative::Custom(Box::new(AmmoniaRelativeUrlEvaluator { - current_file: render_ctx.get_current_resolve().get_file().cloned(), - url_rewriter: url_rewriter.clone(), - })) - }, - )); + CURRENT_FILE + .set(Some(render_ctx.get_current_resolve().get_file().cloned())); + URL_REWRITER.set(Some(render_ctx.ctx.url_rewriter.clone())); - #[cfg(feature = "syntect")] - ammonia_builder.add_tag_attributes("span", ["style"]); + let html = Some(format!( + r#"
{}
"#, + AMMONIA.clean(&html) + )); - #[cfg(feature = "tree-sitter")] - ammonia_builder.add_allowed_classes("span", super::tree_sitter::CLASSES); + CURRENT_FILE.set(None); + URL_REWRITER.set(None); - html = ammonia_builder.clean(&html).to_string(); + html + } + #[cfg(not(feature = "ammonia"))] + { + Some(format!(r#"
{html}
"#)) } - - Some(format!(r#"
{html}
"#)) } pub(crate) fn render_markdown_summary( @@ -618,7 +646,7 @@ impl ModuleDocCtx { let (deprecated, html) = if let Some(node) = module_doc_nodes .iter() - .find(|n| n.kind == DocNodeKind::ModuleDoc) + .find(|n| n.kind() == DocNodeKind::ModuleDoc) { let deprecated = node.js_doc.tags.iter().find_map(|tag| { if let JsDocTag::Deprecated { doc } = tag { @@ -649,20 +677,17 @@ impl ModuleDocCtx { sections.extend(super::namespace::render_namespace( render_ctx, - partitions_by_kind - .into_iter() - .map(|(title, nodes)| { - ( - SectionHeaderCtx { - title: title.clone(), - anchor: AnchorCtx { id: title }, - href: None, - doc: None, - }, - nodes, - ) - }) - .collect(), + partitions_by_kind.into_iter().map(|(title, nodes)| { + ( + SectionHeaderCtx { + title: title.clone(), + anchor: AnchorCtx { id: title }, + href: None, + doc: None, + }, + nodes, + ) + }), )); } @@ -751,7 +776,7 @@ mod test { ModuleSpecifier::parse("file:///a.ts").unwrap(), vec![ DocNode::interface( - "foo".to_string(), + "foo".into(), false, Location::default(), DeclarationKind::Export, @@ -764,11 +789,11 @@ mod test { properties: vec![], call_signatures: vec![], index_signatures: vec![], - type_params: vec![], + type_params: Box::new([]), }, ), DocNode::interface( - "bar".to_string(), + "bar".into(), false, Location::default(), DeclarationKind::Export, @@ -781,7 +806,7 @@ mod test { properties: vec![], call_signatures: vec![], index_signatures: vec![], - type_params: vec![], + type_params: Box::new([]), }, ), ], @@ -789,7 +814,7 @@ mod test { ( ModuleSpecifier::parse("file:///b.ts").unwrap(), vec![DocNode::interface( - "baz".to_string(), + "baz".into(), false, Location::default(), DeclarationKind::Export, @@ -802,7 +827,7 @@ mod test { properties: vec![], call_signatures: vec![], index_signatures: vec![], - type_params: vec![], + type_params: Box::new([]), }, )], ), diff --git a/src/html/mod.rs b/src/html/mod.rs index 47da3e49..27359250 100644 --- a/src/html/mod.rs +++ b/src/html/mod.rs @@ -6,8 +6,8 @@ use std::cmp::Ordering; use std::collections::HashMap; use std::path::PathBuf; use std::rc::Rc; -use std::sync::Arc; +use crate::node::DocNodeDef; use crate::DocNode; pub mod comrak_adapters; @@ -22,7 +22,7 @@ mod symbols; mod tree_sitter; mod types; mod usage; -mod util; +pub mod util; use crate::html::pages::SymbolPage; use crate::js_doc::JsDocTag; @@ -67,6 +67,164 @@ const FUSE_FILENAME: &str = "fuse.js"; const SEARCH_JS: &str = include_str!("./templates/pages/search.js"); const SEARCH_FILENAME: &str = "search.js"; +fn setup_hbs() -> Result, anyhow::Error> { + let mut reg = Handlebars::new(); + reg.register_escape_fn(|str| html_escape::encode_safe(str).into_owned()); + reg.set_strict_mode(true); + + #[cfg(debug_assertions)] + reg.set_dev_mode(true); + + handlebars_helper!(concat: |a: str, b: str| format!("{a}{b}")); + reg.register_helper("concat", Box::new(concat)); + + handlebars_helper!(print: |a: Json| println!("{a:#?}")); + reg.register_helper("print", Box::new(print)); + + reg.register_template_string( + ToCCtx::TEMPLATE, + include_str!("./templates/toc.hbs"), + )?; + reg.register_template_string( + util::DocEntryCtx::TEMPLATE, + include_str!("./templates/doc_entry.hbs"), + )?; + reg.register_template_string( + util::SectionCtx::TEMPLATE, + include_str!("./templates/section.hbs"), + )?; + reg.register_template_string( + "doc_node_kind_icon", + include_str!("./templates/doc_node_kind_icon.hbs"), + )?; + reg.register_template_string( + "namespace_section", + include_str!("./templates/namespace_section.hbs"), + )?; + reg.register_template_string( + symbols::DocBlockSubtitleCtx::TEMPLATE_CLASS, + include_str!("./templates/doc_block_subtitle_class.hbs"), + )?; + reg.register_template_string( + symbols::DocBlockSubtitleCtx::TEMPLATE_INTERFACE, + include_str!("./templates/doc_block_subtitle_interface.hbs"), + )?; + reg.register_template_string( + util::AnchorCtx::TEMPLATE, + include_str!("./templates/anchor.hbs"), + )?; + reg.register_template_string( + SymbolGroupCtx::TEMPLATE, + include_str!("./templates/symbol_group.hbs"), + )?; + reg.register_template_string( + SymbolContentCtx::TEMPLATE, + include_str!("./templates/symbol_content.hbs"), + )?; + reg.register_template_string( + jsdoc::ExampleCtx::TEMPLATE, + include_str!("./templates/example.hbs"), + )?; + reg.register_template_string( + symbols::function::FunctionCtx::TEMPLATE, + include_str!("./templates/function.hbs"), + )?; + reg.register_template_string( + jsdoc::ModuleDocCtx::TEMPLATE, + include_str!("./templates/module_doc.hbs"), + )?; + reg.register_template_string( + util::BreadcrumbsCtx::TEMPLATE, + include_str!("./templates/breadcrumbs.hbs"), + )?; + reg.register_template_string( + usage::UsagesCtx::TEMPLATE, + include_str!("./templates/usages.hbs"), + )?; + reg.register_template_string( + "usages_large", + include_str!("./templates/usages_large.hbs"), + )?; + reg.register_template_string( + util::Tag::TEMPLATE, + include_str!("./templates/tag.hbs"), + )?; + reg.register_template_string( + "source_button", + include_str!("./templates/source_button.hbs"), + )?; + reg.register_template_string( + "deprecated", + include_str!("./templates/deprecated.hbs"), + )?; + reg.register_template_string( + "index_signature", + include_str!("./templates/index_signature.hbs"), + )?; + reg.register_template_string( + pages::CategoriesPanelCtx::TEMPLATE, + include_str!("./templates/category_panel.hbs"), + )?; + + // pages + reg.register_template_string( + pages::HtmlHeadCtx::TEMPLATE, + include_str!("./templates/pages/html_head.hbs"), + )?; + reg.register_template_string( + pages::AllSymbolsCtx::TEMPLATE, + include_str!("./templates/pages/all_symbols.hbs"), + )?; + reg.register_template_string( + pages::SymbolPageCtx::TEMPLATE, + include_str!("./templates/pages/symbol.hbs"), + )?; + reg.register_template_string( + pages::IndexCtx::TEMPLATE, + include_str!("./templates/pages/index.hbs"), + )?; + reg.register_template_string( + "pages/top_nav", + include_str!("./templates/pages/top_nav.hbs"), + )?; + reg.register_template_string( + "pages/search_results", + include_str!("./templates/pages/search_results.hbs"), + )?; + reg.register_template_string( + "pages/redirect", + include_str!("./templates/pages/redirect.hbs"), + )?; + + // icons + reg.register_template_string( + "icons/arrow", + include_str!("./templates/icons/arrow.svg"), + )?; + reg.register_template_string( + "icons/copy", + include_str!("./templates/icons/copy.svg"), + )?; + reg.register_template_string( + "icons/link", + include_str!("./templates/icons/link.svg"), + )?; + reg.register_template_string( + "icons/source", + include_str!("./templates/icons/source.svg"), + )?; + reg.register_template_string( + "icons/menu", + include_str!("./templates/icons/menu.svg"), + )?; + + Ok(reg) +} + +lazy_static! { + pub static ref HANDLEBARS: Handlebars<'static> = setup_hbs().unwrap(); +} + pub type UsageComposer = Rc< dyn Fn( &RenderContext, @@ -100,11 +258,10 @@ pub struct GenerateOptions { } #[non_exhaustive] -pub struct GenerateCtx<'ctx> { +pub struct GenerateCtx { pub package_name: Option, pub common_ancestor: Option, pub doc_nodes: IndexMap, Vec>, - pub hbs: Handlebars<'ctx>, pub highlight_adapter: comrak_adapters::HighlightAdapter, #[cfg(feature = "ammonia")] pub url_rewriter: Option, @@ -119,7 +276,7 @@ pub struct GenerateCtx<'ctx> { pub default_symbol_map: Option>, } -impl<'ctx> GenerateCtx<'ctx> { +impl GenerateCtx { pub fn new( options: GenerateOptions, common_ancestor: Option, @@ -145,31 +302,29 @@ impl<'ctx> GenerateCtx<'ctx> { let nodes = nodes .into_iter() .map(|mut node| { - if node.name == "default" { + if &*node.name == "default" { if let Some(default_rename) = options.default_symbol_map.as_ref().and_then( |default_symbol_map| default_symbol_map.get(&short_path.path), ) { - node.name = default_rename.clone(); + node.name = default_rename.as_str().into(); } } let node = if node - .variable_def + .variable_def() .as_ref() .and_then(|def| def.ts_type.as_ref()) .and_then(|ts_type| ts_type.kind.as_ref()) .is_some_and(|kind| { kind == &crate::ts_type::TsTypeDefKind::FnOrConstructor }) { - let fn_or_constructor = node - .variable_def - .unwrap() - .ts_type - .unwrap() - .fn_or_constructor - .unwrap(); + let DocNodeDef::Variable { variable_def } = node.def else { + unreachable!() + }; + let fn_or_constructor = + variable_def.ts_type.unwrap().fn_or_constructor.unwrap(); let mut new_node = DocNode::function( node.name, @@ -185,7 +340,7 @@ impl<'ctx> GenerateCtx<'ctx> { is_async: false, is_generator: false, type_params: fn_or_constructor.type_params, - decorators: vec![], + decorators: Box::new([]), }, ); new_node.is_default = node.is_default; @@ -196,10 +351,10 @@ impl<'ctx> GenerateCtx<'ctx> { DocNodeWithContext { origin: short_path.clone(), - ns_qualifiers: Rc::new(vec![]), + ns_qualifiers: Rc::new([]), drilldown_parent_kind: None, - kind_with_drilldown: DocNodeKindWithDrilldown::Other(node.kind), - inner: Arc::new(node), + kind_with_drilldown: DocNodeKindWithDrilldown::Other(node.kind()), + inner: Rc::new(node), parent: None, } }) @@ -213,7 +368,6 @@ impl<'ctx> GenerateCtx<'ctx> { package_name: options.package_name, common_ancestor, doc_nodes, - hbs: setup_hbs()?, highlight_adapter: setup_highlighter(false), #[cfg(feature = "ammonia")] url_rewriter: None, @@ -234,7 +388,7 @@ impl<'ctx> GenerateCtx<'ctx> { template: &str, data: &T, ) -> String { - self.hbs.render(template, data).unwrap() + HANDLEBARS.render(template, data).unwrap() } pub fn resolve_path( @@ -372,20 +526,20 @@ pub enum DocNodeKindWithDrilldown { #[derive(Clone, Debug)] pub struct DocNodeWithContext { pub origin: Rc, - pub ns_qualifiers: Rc>, + pub ns_qualifiers: Rc<[String]>, pub drilldown_parent_kind: Option, pub kind_with_drilldown: DocNodeKindWithDrilldown, - pub inner: Arc, + pub inner: Rc, pub parent: Option>, } impl DocNodeWithContext { - pub fn create_child(&self, doc_node: Arc) -> Self { + pub fn create_child(&self, doc_node: Rc) -> Self { DocNodeWithContext { origin: self.origin.clone(), ns_qualifiers: self.ns_qualifiers.clone(), drilldown_parent_kind: None, - kind_with_drilldown: DocNodeKindWithDrilldown::Other(doc_node.kind), + kind_with_drilldown: DocNodeKindWithDrilldown::Other(doc_node.kind()), inner: doc_node, parent: Some(Box::new(self.clone())), } @@ -393,8 +547,8 @@ impl DocNodeWithContext { pub fn create_namespace_child( &self, - doc_node: Arc, - qualifiers: Rc>, + doc_node: Rc, + qualifiers: Rc<[String]>, ) -> Self { let mut child = self.create_child(doc_node); child.ns_qualifiers = qualifiers; @@ -407,11 +561,12 @@ impl DocNodeWithContext { is_static: bool, ) -> Self { method_doc_node.name = - qualify_drilldown_name(self.get_name(), &method_doc_node.name, is_static); + qualify_drilldown_name(self.get_name(), &method_doc_node.name, is_static) + .into_boxed_str(); method_doc_node.declaration_kind = self.declaration_kind; - let mut new_node = self.create_child(Arc::new(method_doc_node)); - new_node.drilldown_parent_kind = Some(self.kind); + let mut new_node = self.create_child(Rc::new(method_doc_node)); + new_node.drilldown_parent_kind = Some(self.kind()); new_node.kind_with_drilldown = DocNodeKindWithDrilldown::Method; new_node } @@ -425,11 +580,12 @@ impl DocNodeWithContext { self.get_name(), &property_doc_node.name, is_static, - ); + ) + .into_boxed_str(); property_doc_node.declaration_kind = self.declaration_kind; - let mut new_node = self.create_child(Arc::new(property_doc_node)); - new_node.drilldown_parent_kind = Some(self.kind); + let mut new_node = self.create_child(Rc::new(property_doc_node)); + new_node.drilldown_parent_kind = Some(self.kind()); new_node.kind_with_drilldown = DocNodeKindWithDrilldown::Property; new_node } @@ -443,7 +599,7 @@ impl DocNodeWithContext { } pub fn sub_qualifier(&self) -> Vec { - let mut ns_qualifiers = (*self.ns_qualifiers).clone(); + let mut ns_qualifiers = Vec::from(&*self.ns_qualifiers); ns_qualifiers.push(self.get_name().to_string()); ns_qualifiers } @@ -473,160 +629,6 @@ impl core::ops::Deref for DocNodeWithContext { } } -pub fn setup_hbs<'t>() -> Result, anyhow::Error> { - let mut reg = Handlebars::new(); - reg.register_escape_fn(|str| html_escape::encode_safe(str).into_owned()); - reg.set_strict_mode(true); - - #[cfg(debug_assertions)] - reg.set_dev_mode(true); - - handlebars_helper!(concat: |a: str, b: str| format!("{a}{b}")); - reg.register_helper("concat", Box::new(concat)); - - handlebars_helper!(print: |a: Json| println!("{a:#?}")); - reg.register_helper("print", Box::new(print)); - - reg.register_template_string( - ToCCtx::TEMPLATE, - include_str!("./templates/toc.hbs"), - )?; - reg.register_template_string( - util::DocEntryCtx::TEMPLATE, - include_str!("./templates/doc_entry.hbs"), - )?; - reg.register_template_string( - util::SectionCtx::TEMPLATE, - include_str!("./templates/section.hbs"), - )?; - reg.register_template_string( - "doc_node_kind_icon", - include_str!("./templates/doc_node_kind_icon.hbs"), - )?; - reg.register_template_string( - "namespace_section", - include_str!("./templates/namespace_section.hbs"), - )?; - reg.register_template_string( - symbols::DocBlockSubtitleCtx::TEMPLATE_CLASS, - include_str!("./templates/doc_block_subtitle_class.hbs"), - )?; - reg.register_template_string( - symbols::DocBlockSubtitleCtx::TEMPLATE_INTERFACE, - include_str!("./templates/doc_block_subtitle_interface.hbs"), - )?; - reg.register_template_string( - util::AnchorCtx::TEMPLATE, - include_str!("./templates/anchor.hbs"), - )?; - reg.register_template_string( - SymbolGroupCtx::TEMPLATE, - include_str!("./templates/symbol_group.hbs"), - )?; - reg.register_template_string( - SymbolContentCtx::TEMPLATE, - include_str!("./templates/symbol_content.hbs"), - )?; - reg.register_template_string( - jsdoc::ExampleCtx::TEMPLATE, - include_str!("./templates/example.hbs"), - )?; - reg.register_template_string( - symbols::function::FunctionCtx::TEMPLATE, - include_str!("./templates/function.hbs"), - )?; - reg.register_template_string( - jsdoc::ModuleDocCtx::TEMPLATE, - include_str!("./templates/module_doc.hbs"), - )?; - reg.register_template_string( - util::BreadcrumbsCtx::TEMPLATE, - include_str!("./templates/breadcrumbs.hbs"), - )?; - reg.register_template_string( - usage::UsagesCtx::TEMPLATE, - include_str!("./templates/usages.hbs"), - )?; - reg.register_template_string( - "usages_large", - include_str!("./templates/usages_large.hbs"), - )?; - reg.register_template_string( - util::Tag::TEMPLATE, - include_str!("./templates/tag.hbs"), - )?; - reg.register_template_string( - "source_button", - include_str!("./templates/source_button.hbs"), - )?; - reg.register_template_string( - "deprecated", - include_str!("./templates/deprecated.hbs"), - )?; - reg.register_template_string( - "index_signature", - include_str!("./templates/index_signature.hbs"), - )?; - - // pages - reg.register_template_string( - pages::HtmlHeadCtx::TEMPLATE, - include_str!("./templates/pages/html_head.hbs"), - )?; - reg.register_template_string( - pages::CategoriesPanelCtx::TEMPLATE, - include_str!("./templates/pages/category_panel.hbs"), - )?; - reg.register_template_string( - pages::AllSymbolsCtx::TEMPLATE, - include_str!("./templates/pages/all_symbols.hbs"), - )?; - reg.register_template_string( - pages::SymbolPageCtx::TEMPLATE, - include_str!("./templates/pages/symbol.hbs"), - )?; - reg.register_template_string( - pages::IndexCtx::TEMPLATE, - include_str!("./templates/pages/index.hbs"), - )?; - reg.register_template_string( - "pages/top_nav", - include_str!("./templates/pages/top_nav.hbs"), - )?; - reg.register_template_string( - "pages/search_results", - include_str!("./templates/pages/search_results.hbs"), - )?; - reg.register_template_string( - "pages/redirect", - include_str!("./templates/pages/redirect.hbs"), - )?; - - // icons - reg.register_template_string( - "icons/arrow", - include_str!("./templates/icons/arrow.svg"), - )?; - reg.register_template_string( - "icons/copy", - include_str!("./templates/icons/copy.svg"), - )?; - reg.register_template_string( - "icons/link", - include_str!("./templates/icons/link.svg"), - )?; - reg.register_template_string( - "icons/source", - include_str!("./templates/icons/source.svg"), - )?; - reg.register_template_string( - "icons/menu", - include_str!("./templates/icons/menu.svg"), - )?; - - Ok(reg) -} - pub fn setup_highlighter( show_line_numbers: bool, ) -> comrak_adapters::HighlightAdapter { diff --git a/src/html/pages.rs b/src/html/pages.rs index 844f7098..3be5f0aa 100644 --- a/src/html/pages.rs +++ b/src/html/pages.rs @@ -83,7 +83,7 @@ pub struct CategoriesPanelCtx { } impl CategoriesPanelCtx { - pub const TEMPLATE: &'static str = "pages/category_panel"; + pub const TEMPLATE: &'static str = "category_panel"; pub fn new(ctx: &RenderContext) -> Option { match ctx.ctx.file_mode { @@ -230,7 +230,7 @@ impl IndexCtx { .map(|(short_path, nodes)| { let doc = nodes .iter() - .find(|node| node.kind == DocNodeKind::ModuleDoc) + .find(|node| node.kind() == DocNodeKind::ModuleDoc) .and_then(|node| { crate::html::jsdoc::jsdoc_body_to_html( &render_ctx, @@ -241,11 +241,8 @@ impl IndexCtx { let title = short_path.display_name(); - let anchor = render_ctx.toc.add_entry( - 1, - title.clone(), - render_ctx.toc.anchorize(title.clone()), - ); + let anchor = render_ctx.toc.anchorize(&title); + render_ctx.toc.add_entry(1, &title, &anchor); util::SectionCtx { header: SectionHeaderCtx { @@ -274,11 +271,8 @@ impl IndexCtx { let sections = partitions .into_keys() .map(|title| { - let anchor = render_ctx.toc.add_entry( - 1, - title.clone(), - render_ctx.toc.anchorize(title.clone()), - ); + let anchor = render_ctx.toc.anchorize(&title); + render_ctx.toc.add_entry(1, &title, &anchor); let doc = ctx .category_docs @@ -358,24 +352,21 @@ impl IndexCtx { let sections = super::namespace::render_namespace( &render_ctx, - partitions - .into_iter() - .map(|(title, nodes)| { - let doc = ctx.category_docs.as_ref().and_then(|category_docs| { - category_docs.get(&title).cloned().flatten() - }); - - ( - SectionHeaderCtx { - anchor: AnchorCtx { id: title.clone() }, - title, - href: None, - doc, - }, - nodes, - ) - }) - .collect(), + partitions.into_iter().map(|(title, nodes)| { + let doc = ctx.category_docs.as_ref().and_then(|category_docs| { + category_docs.get(&title).cloned().flatten() + }); + + ( + SectionHeaderCtx { + anchor: AnchorCtx { id: title.clone() }, + title, + href: None, + doc, + }, + nodes, + ) + }), ); let root = @@ -438,15 +429,12 @@ impl AllSymbolsCtx { let sections = super::namespace::render_namespace( &render_ctx, - partitions - .into_iter() - .map(|(path, nodes)| { - ( - SectionHeaderCtx::new_for_namespace(&render_ctx, &path), - nodes, - ) - }) - .collect(), + partitions.into_iter().map(|(path, nodes)| { + ( + SectionHeaderCtx::new_for_namespace(&render_ctx, &path), + nodes, + ) + }), ); let html_head_ctx = HtmlHeadCtx::new( @@ -496,12 +484,13 @@ pub fn generate_symbol_pages_for_module( let mut drilldown_partitions = IndexMap::new(); for doc_nodes in name_partitions.values() { - let has_class = - doc_nodes.iter().any(|node| node.kind == DocNodeKind::Class); + let has_class = doc_nodes + .iter() + .any(|node| node.kind() == DocNodeKind::Class); for doc_node in doc_nodes { - match doc_node.kind { + match doc_node.kind() { DocNodeKind::Class => { - let class = doc_node.class_def.as_ref().unwrap(); + let class = doc_node.class_def().unwrap(); let method_nodes = class .methods @@ -540,7 +529,7 @@ pub fn generate_symbol_pages_for_module( ); } DocNodeKind::Interface => { - let interface = doc_node.interface_def.as_ref().unwrap(); + let interface = doc_node.interface_def().unwrap(); let method_nodes = interface .methods .iter() @@ -579,7 +568,7 @@ pub fn generate_symbol_pages_for_module( .extend(partition::partition_nodes_by_name(&property_nodes, false)); } DocNodeKind::TypeAlias => { - let type_alias = doc_node.type_alias_def.as_ref().unwrap(); + let type_alias = doc_node.type_alias_def().unwrap(); if let Some(ts_type_literal) = type_alias.ts_type.type_literal.as_ref() @@ -624,7 +613,7 @@ pub fn generate_symbol_pages_for_module( } } DocNodeKind::Variable => { - let variable = doc_node.variable_def.as_ref().unwrap(); + let variable = doc_node.variable_def().unwrap(); if let Some(ts_type_literal) = variable .ts_type @@ -682,7 +671,7 @@ pub fn generate_symbol_pages_for_module( if doc_nodes .iter() - .any(|doc_node| doc_node.kind == DocNodeKind::Class) + .any(|doc_node| doc_node.kind() == DocNodeKind::Class) { let prototype_name = format!("{name}.prototype"); generated_pages.push(SymbolPage::Redirect { diff --git a/src/html/partition.rs b/src/html/partition.rs index f9562475..9595df25 100644 --- a/src/html/partition.rs +++ b/src/html/partition.rs @@ -25,13 +25,13 @@ where F: Fn(&mut IndexMap>, &DocNodeWithContext), { for node in doc_nodes { - if matches!(node.kind, DocNodeKind::ModuleDoc | DocNodeKind::Import) { + if matches!(node.kind(), DocNodeKind::ModuleDoc | DocNodeKind::Import) { continue; } - if flatten_namespaces && node.kind == DocNodeKind::Namespace { - let namespace_def = node.namespace_def.as_ref().unwrap(); - let ns_qualifiers = Rc::new(node.sub_qualifier()); + if flatten_namespaces && node.kind() == DocNodeKind::Namespace { + let namespace_def = node.namespace_def().unwrap(); + let ns_qualifiers: Rc<[String]> = node.sub_qualifier().into(); partitioner_inner( partitions, @@ -72,7 +72,7 @@ pub fn partition_nodes_by_name( }); for val in partitions.values_mut() { - val.sort_by_key(|n| n.kind); + val.sort_by_key(|n| n.kind()); } partitions.sort_keys(); @@ -138,7 +138,7 @@ pub fn partition_nodes_by_category( if !entry.iter().any(|n| { n.get_qualified_name() == node.get_qualified_name() - && n.kind == node.kind + && n.kind() == node.kind() }) { entry.push(node.clone()); } @@ -207,5 +207,5 @@ fn compare_node( .cmp(&node2.get_qualified_name().to_ascii_lowercase()) }) .then_with(|| node1.get_qualified_name().cmp(&node2.get_qualified_name())) - .then_with(|| node1.kind.cmp(&node2.kind)) + .then_with(|| node1.kind().cmp(&node2.kind())) } diff --git a/src/html/render_context.rs b/src/html/render_context.rs index 51717144..9a0a60c4 100644 --- a/src/html/render_context.rs +++ b/src/html/render_context.rs @@ -12,13 +12,13 @@ use std::rc::Rc; #[derive(Clone)] pub struct RenderContext<'ctx> { - pub ctx: &'ctx GenerateCtx<'ctx>, + pub ctx: &'ctx GenerateCtx, scoped_symbols: NamespacedSymbols, current_imports: Rc>, current_type_params: Rc>, current_resolve: UrlResolveKind<'ctx>, /// A vector of parts of the current namespace, eg. `vec!["Deno", "errors"]`. - namespace_parts: Rc>, + namespace_parts: Rc<[String]>, /// Only some when in `FileMode::SingleDts` and using categories category: Option<&'ctx str>, pub toc: crate::html::comrak_adapters::HeadingToCAdapter, @@ -26,7 +26,7 @@ pub struct RenderContext<'ctx> { impl<'ctx> RenderContext<'ctx> { pub fn new( - ctx: &'ctx GenerateCtx<'ctx>, + ctx: &'ctx GenerateCtx, doc_nodes: &[DocNodeWithContext], current_resolve: UrlResolveKind<'ctx>, ) -> Self { @@ -36,7 +36,7 @@ impl<'ctx> RenderContext<'ctx> { current_imports: Rc::new(get_current_imports(doc_nodes)), current_type_params: Default::default(), current_resolve, - namespace_parts: Rc::new(vec![]), + namespace_parts: Rc::new([]), category: None, toc: Default::default(), } @@ -52,7 +52,7 @@ impl<'ctx> RenderContext<'ctx> { } } - pub fn with_namespace(&self, namespace_parts: Rc>) -> Self { + pub fn with_namespace(&self, namespace_parts: Rc<[String]>) -> Self { Self { namespace_parts, ..self.clone() @@ -93,7 +93,8 @@ impl<'ctx> RenderContext<'ctx> { .collect::>(); if !self.namespace_parts.is_empty() { - let mut parts = (*self.namespace_parts).clone(); + // TODO: clean this up to not clone and to_vec + let mut parts = self.namespace_parts.to_vec(); while !parts.is_empty() { let mut current_parts = parts.clone(); current_parts.extend_from_slice(&target_symbol_parts); @@ -339,8 +340,8 @@ fn get_current_imports( let mut imports = HashMap::new(); for doc_node in doc_nodes { - if doc_node.kind == DocNodeKind::Import { - let import_def = doc_node.import_def.as_ref().unwrap(); + if doc_node.kind() == DocNodeKind::Import { + let import_def = doc_node.import_def().unwrap(); // TODO: handle import aliasing if import_def.imported.as_deref() == Some(doc_node.get_name()) { imports.insert(doc_node.get_name().to_string(), import_def.src.clone()); @@ -395,7 +396,7 @@ mod test { } fn resolve_source(&self, location: &Location) -> Option { - Some(location.filename.clone()) + Some(location.filename.clone().into_string()) } } @@ -404,28 +405,22 @@ mod test { let doc_nodes_by_url = indexmap::IndexMap::from([( ModuleSpecifier::parse("file:///mod.ts").unwrap(), vec![DocNode { - kind: DocNodeKind::Import, - name: "foo".to_string(), + name: "foo".into(), is_default: None, location: Location { - filename: "a".to_string(), + filename: "a".into(), line: 0, col: 0, byte_index: 0, }, declaration_kind: DeclarationKind::Private, js_doc: Default::default(), - function_def: None, - variable_def: None, - enum_def: None, - class_def: None, - type_alias_def: None, - namespace_def: None, - interface_def: None, - import_def: Some(ImportDef { - src: "b".to_string(), - imported: Some("foo".to_string()), - }), + def: crate::node::DocNodeDef::Import { + import_def: ImportDef { + src: "b".to_string(), + imported: Some("foo".to_string()), + }, + }, }], )]); diff --git a/src/html/search.rs b/src/html/search.rs index 5dded021..c58ee3f4 100644 --- a/src/html/search.rs +++ b/src/html/search.rs @@ -11,12 +11,12 @@ use serde_json::json; #[serde(rename_all = "camelCase")] struct SearchIndexNode { kind: Vec, - name: String, - file: String, - doc: String, + name: Box, + file: Box, + doc: Box, location: Location, - url: String, - category: String, + url: Box, + category: Box, declaration_kind: crate::node::DeclarationKind, deprecated: bool, } @@ -26,7 +26,7 @@ fn doc_nodes_into_search_index_node( doc_nodes: Vec, name: String, ) -> SearchIndexNode { - let kinds = doc_nodes.iter().map(|node| node.kind).collect(); + let kinds = doc_nodes.iter().map(|node| node.kind()).collect(); let deprecated = super::util::all_deprecated(&doc_nodes.iter().collect::>()); @@ -37,9 +37,9 @@ fn doc_nodes_into_search_index_node( .keys() .find(|short_path| short_path.specifier == location_url) { - html_escape::encode_text(&short_path.display_name()).into_owned() + html_escape::encode_text(&short_path.display_name()).into() } else { - String::new() + "".into() }; let doc = doc_nodes[0].js_doc.doc.clone().unwrap_or_default(); @@ -67,14 +67,14 @@ fn doc_nodes_into_search_index_node( SearchIndexNode { kind: kinds, - name: html_escape::encode_text(&name).to_string(), + name: html_escape::encode_text(&name).into(), file: html_escape::encode_double_quoted_attribute( &doc_nodes[0].origin.path, ) - .into_owned(), + .into(), doc, location, - url: abs_url, + url: abs_url.into_boxed_str(), category, declaration_kind: doc_nodes[0].declaration_kind, deprecated, diff --git a/src/html/symbols/class.rs b/src/html/symbols/class.rs index a46b3583..d2c455bc 100644 --- a/src/html/symbols/class.rs +++ b/src/html/symbols/class.rs @@ -18,7 +18,7 @@ pub(crate) fn render_class( doc_node: &DocNodeWithContext, name: &str, ) -> Vec { - let class_def = doc_node.class_def.as_ref().unwrap(); + let class_def = doc_node.class_def().unwrap(); let current_type_params = class_def .type_params @@ -258,20 +258,20 @@ fn property_or_method_cmp( struct ClassItems { properties: Vec, static_properties: Vec, - methods: BTreeMap>, - static_methods: BTreeMap>, + methods: BTreeMap, Vec>, + static_methods: BTreeMap, Vec>, } fn partition_properties_and_classes( - properties: Vec, - methods: Vec, + properties: Box<[ClassPropertyDef]>, + methods: Box<[ClassMethodDef]>, ) -> ClassItems { let mut out_properties = vec![]; let mut out_static_properties = vec![]; let mut out_methods = BTreeMap::new(); let mut out_static_methods = BTreeMap::new(); - for property in properties { + for property in properties.into_vec().into_iter() { if property.is_static { out_static_properties.push(PropertyOrMethod::Property(property)); } else { @@ -279,7 +279,7 @@ fn partition_properties_and_classes( } } - for method in methods { + for method in methods.into_vec().into_iter() { if matches!(method.kind, MethodKind::Getter | MethodKind::Setter) { if method.is_static { out_static_properties.push(PropertyOrMethod::Method(method)); @@ -493,7 +493,7 @@ fn render_class_properties( fn render_class_methods( ctx: &RenderContext, class_name: &str, - methods: BTreeMap>, + methods: BTreeMap, Vec>, ) -> Vec { methods .values() diff --git a/src/html/symbols/enum.rs b/src/html/symbols/enum.rs index 67595c05..a1084914 100644 --- a/src/html/symbols/enum.rs +++ b/src/html/symbols/enum.rs @@ -7,7 +7,7 @@ pub(crate) fn render_enum( render_ctx: &RenderContext, doc_node: &DocNodeWithContext, ) -> Vec { - let mut members = doc_node.enum_def.as_ref().unwrap().members.clone(); + let mut members = doc_node.enum_def().unwrap().members.clone(); members.sort_by(|a, b| a.name.cmp(&b.name)); diff --git a/src/html/symbols/function.rs b/src/html/symbols/function.rs index 0fd5f4f6..a0c8fc69 100644 --- a/src/html/symbols/function.rs +++ b/src/html/symbols/function.rs @@ -11,6 +11,7 @@ use crate::js_doc::JsDocTag; use crate::params::ParamPatternDef; use serde::Serialize; use std::collections::HashSet; +use std::ops::Deref; #[derive(Debug, Serialize, Clone)] struct OverloadRenderCtx { @@ -40,14 +41,14 @@ impl FunctionCtx { .iter() .enumerate() .filter(|(i, doc_node)| { - let function_def = doc_node.function_def.as_ref().unwrap(); + let function_def = doc_node.function_def().unwrap(); !(function_def.has_body && *i != 0) }) .count(); for (i, doc_node) in doc_nodes.into_iter().enumerate() { - let function_def = doc_node.function_def.as_ref().unwrap(); + let function_def = doc_node.function_def().unwrap(); if function_def.has_body && i != 0 { continue; @@ -70,11 +71,9 @@ impl FunctionCtx { name_to_id("function", &format!("{}_{i}", doc_node.get_name())); if overloads_count > 1 { - ctx.toc.add_entry( - 0, - format!("Overload {}", i + 1), - overload_id.clone(), - ); + ctx + .toc + .add_entry(0, &format!("Overload {}", i + 1), &overload_id); } functions_content.push(OverloadRenderCtx { @@ -117,7 +116,7 @@ fn render_single_function( doc_node: &DocNodeWithContext, overload_id: &str, ) -> SymbolContentCtx { - let function_def = doc_node.function_def.as_ref().unwrap(); + let function_def = doc_node.function_def().unwrap(); let current_type_params = function_def .type_params @@ -126,29 +125,28 @@ fn render_single_function( .collect::>(); let ctx = &ctx.with_current_type_params(current_type_params); - let param_docs = - doc_node - .js_doc - .tags - .iter() - .filter_map(|tag| { - if let JsDocTag::Param { - name, - doc, - optional, - default, - .. - } = tag - { - Some((name.as_str(), (doc, *optional, default))) - } else { - None - } - }) - .collect::, bool, &Option), - >>(); + let param_docs = doc_node + .js_doc + .tags + .iter() + .filter_map(|tag| { + if let JsDocTag::Param { + name, + doc, + optional, + default, + .. + } = tag + { + Some((name.deref(), (doc, *optional, default))) + } else { + None + } + }) + .collect::>, bool, &Option>), + >>(); let params = function_def .params @@ -168,7 +166,7 @@ fn render_single_function( let ts_type = if let ParamPatternDef::Assign { left, right } = ¶m.pattern { - default = default.or(Some(right.to_string())); + default = default.or(Some(right.deref().into())); left.ts_type.as_ref() } else { param.ts_type.as_ref() @@ -179,7 +177,7 @@ fn render_single_function( .unwrap_or_default(); if let Some(default) = &default { - if default != "[UNSUPPORTED]" { + if default.deref() != "[UNSUPPORTED]" { ts_type = format!(r#"{ts_type} = {default}"#); } } diff --git a/src/html/symbols/interface.rs b/src/html/symbols/interface.rs index a2540194..347c4360 100644 --- a/src/html/symbols/interface.rs +++ b/src/html/symbols/interface.rs @@ -11,7 +11,7 @@ pub(crate) fn render_interface( doc_node: &DocNodeWithContext, name: &str, ) -> Vec { - let interface_def = doc_node.interface_def.as_ref().unwrap(); + let interface_def = doc_node.interface_def().unwrap(); let current_type_params = interface_def .type_params diff --git a/src/html/symbols/mod.rs b/src/html/symbols/mod.rs index 74539d37..73d7b9fc 100644 --- a/src/html/symbols/mod.rs +++ b/src/html/symbols/mod.rs @@ -9,6 +9,7 @@ use crate::html::RenderContext; use crate::js_doc::JsDocTag; use crate::DocNodeKind; use indexmap::IndexMap; +use indexmap::IndexSet; use serde::Serialize; use std::collections::HashSet; @@ -24,7 +25,7 @@ pub mod variable; struct SymbolCtx { kind: super::util::DocNodeKindCtx, usage: Option, - tags: HashSet, + tags: IndexSet, subtitle: Option, content: Vec, deprecated: Option, @@ -49,7 +50,7 @@ impl SymbolGroupCtx { IndexMap::>::default(); for doc_node in doc_nodes { - if doc_node.kind == DocNodeKind::Import { + if doc_node.kind() == DocNodeKind::Import { continue; } @@ -67,7 +68,7 @@ impl SymbolGroupCtx { let all_deprecated = super::util::all_deprecated(&doc_nodes.iter().collect::>()); - let mut tags = HashSet::new(); + let mut tags = indexmap::IndexSet::new(); if doc_nodes.iter().any(|node| { node @@ -79,7 +80,7 @@ impl SymbolGroupCtx { tags.insert(Tag::Unstable); } - let permissions = doc_nodes + let mut permissions = doc_nodes .iter() .flat_map(|node| { node @@ -101,10 +102,11 @@ impl SymbolGroupCtx { }) .flatten() }) - .collect::>(); + .collect::>(); if !permissions.is_empty() { - tags.insert(Tag::Permissions(permissions)); + permissions.sort(); + tags.insert(Tag::Permissions(permissions.into_iter().collect())); } if doc_nodes[0].is_internal() { @@ -112,7 +114,7 @@ impl SymbolGroupCtx { } let deprecated = if all_deprecated - && !(doc_nodes[0].kind == DocNodeKind::Function + && !(doc_nodes[0].kind() == DocNodeKind::Function && doc_nodes.len() == 1) { doc_nodes[0].js_doc.tags.iter().find_map(|tag| { @@ -187,9 +189,9 @@ impl DocBlockSubtitleCtx { pub const TEMPLATE_INTERFACE: &'static str = "doc_block_subtitle_interface"; fn new(ctx: &RenderContext, doc_node: &DocNodeWithContext) -> Option { - match doc_node.kind { + match doc_node.kind() { DocNodeKind::Class => { - let class_def = doc_node.class_def.as_ref().unwrap(); + let class_def = doc_node.class_def().unwrap(); let current_type_params = class_def .type_params @@ -229,7 +231,7 @@ impl DocBlockSubtitleCtx { }) } DocNodeKind::Interface => { - let interface_def = doc_node.interface_def.as_ref().unwrap(); + let interface_def = doc_node.interface_def().unwrap(); if interface_def.extends.is_empty() { return None; @@ -287,7 +289,7 @@ impl SymbolInnerCtx { let docs = crate::html::jsdoc::jsdoc_body_to_html(ctx, &doc_node.js_doc, false); - if doc_node.kind != DocNodeKind::Function { + if doc_node.kind() != DocNodeKind::Function { if let Some(examples) = crate::html::jsdoc::jsdoc_examples(ctx, &doc_node.js_doc) { @@ -295,7 +297,7 @@ impl SymbolInnerCtx { } } - sections.extend(match doc_node.kind { + sections.extend(match doc_node.kind() { DocNodeKind::Function => { functions.push(doc_node); continue; @@ -312,8 +314,9 @@ impl SymbolInnerCtx { } DocNodeKind::Namespace => { - let namespace_def = doc_node.namespace_def.as_ref().unwrap(); - let ns_qualifiers = std::rc::Rc::new(doc_node.sub_qualifier()); + let namespace_def = doc_node.namespace_def().unwrap(); + let ns_qualifiers: std::rc::Rc<[String]> = + doc_node.sub_qualifier().into(); let namespace_nodes = namespace_def .elements .iter() @@ -328,20 +331,17 @@ impl SymbolInnerCtx { namespace::render_namespace( &ctx.with_namespace(ns_qualifiers), - partitions - .into_iter() - .map(|(title, nodes)| { - ( - crate::html::util::SectionHeaderCtx { - title: title.clone(), - anchor: AnchorCtx { id: title }, - href: None, - doc: None, - }, - nodes, - ) - }) - .collect(), + partitions.into_iter().map(|(title, nodes)| { + ( + crate::html::util::SectionHeaderCtx { + title: title.clone(), + anchor: AnchorCtx { id: title }, + href: None, + doc: None, + }, + nodes, + ) + }), ) } DocNodeKind::ModuleDoc | DocNodeKind::Import => unreachable!(), diff --git a/src/html/symbols/namespace.rs b/src/html/symbols/namespace.rs index a02080ad..8fa5be51 100644 --- a/src/html/symbols/namespace.rs +++ b/src/html/symbols/namespace.rs @@ -8,10 +8,9 @@ use std::collections::HashSet; pub fn render_namespace( ctx: &RenderContext, - partitions: IndexMap>, + partitions: impl Iterator)>, ) -> Vec { partitions - .into_iter() .map(|(header, doc_nodes)| { get_namespace_section_render_ctx(ctx, header, doc_nodes) }) diff --git a/src/html/symbols/type_alias.rs b/src/html/symbols/type_alias.rs index a25a00d8..c869c1d0 100644 --- a/src/html/symbols/type_alias.rs +++ b/src/html/symbols/type_alias.rs @@ -13,7 +13,7 @@ pub(crate) fn render_type_alias( doc_node: &DocNodeWithContext, name: &str, ) -> Vec { - let type_alias_def = doc_node.type_alias_def.as_ref().unwrap(); + let type_alias_def = doc_node.type_alias_def().unwrap(); let current_type_params = type_alias_def .type_params diff --git a/src/html/symbols/variable.rs b/src/html/symbols/variable.rs index 32406a1e..25adeee9 100644 --- a/src/html/symbols/variable.rs +++ b/src/html/symbols/variable.rs @@ -13,7 +13,7 @@ pub(crate) fn render_variable( doc_node: &DocNodeWithContext, name: &str, ) -> Vec { - let variable_def = doc_node.variable_def.as_ref().unwrap(); + let variable_def = doc_node.variable_def().unwrap(); let Some(ts_type) = &variable_def.ts_type else { return vec![]; diff --git a/src/html/templates/category_panel.hbs b/src/html/templates/category_panel.hbs new file mode 100644 index 00000000..a74e02d3 --- /dev/null +++ b/src/html/templates/category_panel.hbs @@ -0,0 +1,16 @@ +{{#if this}} +
+ +
+{{/if}} diff --git a/src/html/templates/pages/all_symbols.hbs b/src/html/templates/pages/all_symbols.hbs index f3d872a0..1a3d7b72 100644 --- a/src/html/templates/pages/all_symbols.hbs +++ b/src/html/templates/pages/all_symbols.hbs @@ -1,5 +1,5 @@ {{~> pages/html_head html_head_ctx ~}} -{{~> pages/category_panel categories_panel ~}} +{{~> category_panel categories_panel ~}}
{{~> pages/top_nav ~}} diff --git a/src/html/templates/pages/category_panel.hbs b/src/html/templates/pages/category_panel.hbs deleted file mode 100644 index c63173d7..00000000 --- a/src/html/templates/pages/category_panel.hbs +++ /dev/null @@ -1,22 +0,0 @@ -{{#if this}} -
-
- -
-
-{{/if}} diff --git a/src/html/templates/pages/index.hbs b/src/html/templates/pages/index.hbs index 86eddfe8..6ccfd9aa 100644 --- a/src/html/templates/pages/index.hbs +++ b/src/html/templates/pages/index.hbs @@ -1,5 +1,5 @@ {{~> pages/html_head html_head_ctx ~}} -{{~> pages/category_panel categories_panel ~}} +{{~> category_panel categories_panel ~}}
{{~> pages/top_nav ~}} diff --git a/src/html/templates/pages/page.css b/src/html/templates/pages/page.css index b09e4d1e..a6907014 100644 --- a/src/html/templates/pages/page.css +++ b/src/html/templates/pages/page.css @@ -2,34 +2,37 @@ @tailwind utilities; .ddoc { - @apply flex h-screen items-start gap-6 p-4 pt-2 lg:p-2 lg:pt-0 max-lg:pt-4; + /* keep in sync with #topnav further down */ + @apply flex h-screen items-start gap-6 p-4 lg:p-2; - /* doesn't have categories panel */ - &:not(:has(> div.toc)) { + &:not(:has(#categoryPanel)) { @apply lg:pt-4; } - /* Has categories panel, target non-categories panel content */ - &:has(> div.toc) > div:not(.toc) { - @apply lg:pt-4; - } - - /* Categories panel */ - & > .toc { - @apply max-lg:hidden md:flex md:flex-col -mt-0 pt-0 h-full max-h-screen; - @apply w-[290px] flex-shrink-0; + &:has(#categoryPanel) { + & > div:not(#categoryPanel) { + @apply lg:pt-4; + } - h3 { - @apply pt-3 !important; + #topnav { + @apply lg:-ml-6 lg:pl-6 !important; } } - /* Non-categories panel content */ - & > div:not(.toc) { + &:not(:has(#categoryPanel)), + &:has(#categoryPanel) > div:not(#categoryPanel) { + @apply pt-1; + } + + & > div:not(#categoryPanel) { @apply flex flex-col flex-grow; } } +#categoryPanel { + @apply max-lg:hidden lg:flex lg:flex-col -mt-0 pt-0 w-[250px] flex-shrink-0 top-0 sticky max-h-screen h-fit box-border; +} + #content { @apply mt-4; @@ -40,22 +43,22 @@ &:has(.toc) > main { @apply lg:col-span-3 lg:row-start-1; } +} - .toc { - @apply max-md:hidden xl:flex xl:flex-col; - } +#topnav { + @apply -ml-4 pl-4 lg:-ml-2 lg:pl-2; } #content, #topnav > div { @apply flex flex-row justify-between gap-6 gap-8 lg:gap-12; } -#content .toc, #searchbar { +.toc, #searchbar { @apply flex-shrink-0 min-w-[250px] max-w-[300px]; } .toc { - @apply max-lg:row-start-1 lg:col-[span_1_/_-1] lg:top-0 lg:sticky lg:max-h-screen lg:h-fit flex flex-col box-border gap-y-4 -mt-14 pt-14; + @apply max-sm:hidden sm:flex sm:flex-col max-lg:row-start-1 lg:col-[span_1_/_-1] top-0 sticky max-h-screen h-fit box-border gap-y-4 -mt-14 pt-14; > div { @apply max-h-full lg:overflow-y-auto; diff --git a/src/html/templates/pages/page.gen.css b/src/html/templates/pages/page.gen.css index 07b7e6f0..72c6de2b 100644 --- a/src/html/templates/pages/page.gen.css +++ b/src/html/templates/pages/page.gen.css @@ -1 +1 @@ -.sticky{position:sticky}.top-0{top:0}.z-50{z-index:50}.block{display:block}.\!flex{display:flex!important}.flex{display:flex}.h-14{height:3.5rem}.h-full{height:100%}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-4{gap:1rem}.overflow-hidden{overflow:hidden}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-lg{border-radius:.5rem}.border{border-width:1px}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.bg-transparent{background-color:#0000}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.italic{font-style:italic}.leading-none{line-height:1}.text-stone-400{--tw-text-opacity:1;color:rgb(168 162 158/var(--tw-text-opacity))}.blur{--tw-blur:blur(8px);filter:var(--tw-blur)var(--tw-brightness)var(--tw-contrast)var(--tw-grayscale)var(--tw-hue-rotate)var(--tw-invert)var(--tw-saturate)var(--tw-sepia)var(--tw-drop-shadow)}.ddoc{align-items:flex-start;gap:1.5rem;height:100vh;padding:.5rem 1rem 1rem;display:flex}@media not all and (min-width:1024px){.ddoc{padding-top:1rem}}@media (min-width:1024px){.ddoc{padding:0 .5rem .5rem}}@media (min-width:1024px){.ddoc:not(:has(>div.toc)),.ddoc:has(>div.toc)>div:not(.toc){padding-top:1rem}}.ddoc>.toc{height:100%;max-height:100vh;margin-top:0;padding-top:0}@media not all and (min-width:1024px){.ddoc>.toc{display:none}}@media (min-width:768px){.ddoc>.toc{flex-direction:column;display:flex}}.ddoc>.toc{flex-shrink:0;width:290px}.ddoc>.toc h3{padding-top:.75rem!important}.ddoc>div:not(.toc){flex-direction:column;flex-grow:1;display:flex}#content{margin-top:1rem}#content>main{flex-direction:column;flex-grow:1;grid-column:1/-1;gap:.75rem;min-width:0;padding-bottom:0;display:flex}@media (min-width:768px){#content>main{padding-bottom:2rem}}@media (min-width:1024px){#content>main{padding-bottom:3rem}#content:has(.toc)>main{grid-column:span 3/span 3;grid-row-start:1}}@media not all and (min-width:768px){#content .toc{display:none}}@media (min-width:1280px){#content .toc{flex-direction:column;display:flex}}#content,#topnav>div{flex-direction:row;justify-content:space-between;gap:2rem;display:flex}@media (min-width:1024px){#content,#topnav>div{gap:3rem}}#content .toc,#searchbar{flex-shrink:0;min-width:250px;max-width:300px}.toc{box-sizing:border-box;flex-direction:column;row-gap:1rem;margin-top:-3.5rem;padding-top:3.5rem;display:flex}@media not all and (min-width:1024px){.toc{grid-row-start:1}}@media (min-width:1024px){.toc{grid-column:span 1/-1;height:-moz-fit-content;height:fit-content;max-height:100vh;position:sticky;top:0}}.toc>div{max-height:100%}@media (min-width:1024px){.toc>div{overflow-y:auto}}.toc>div>:last-child{padding-bottom:1rem}#searchResults{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));display:none;position:absolute;inset:0}.hover\:bg-stone-100:hover{--tw-bg-opacity:1;background-color:rgb(245 245 244/var(--tw-bg-opacity))} \ No newline at end of file +.sticky{position:sticky}.top-0{top:0}.z-50{z-index:50}.block{display:block}.flex{display:flex}.h-14{height:3.5rem}.h-full{height:100%}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-4{gap:1rem}.overflow-hidden{overflow:hidden}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-lg{border-radius:.5rem}.border{border-width:1px}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.bg-transparent{background-color:#0000}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.italic{font-style:italic}.leading-none{line-height:1}.text-stone-400{--tw-text-opacity:1;color:rgb(168 162 158/var(--tw-text-opacity))}.blur{--tw-blur:blur(8px);filter:var(--tw-blur)var(--tw-brightness)var(--tw-contrast)var(--tw-grayscale)var(--tw-hue-rotate)var(--tw-invert)var(--tw-saturate)var(--tw-sepia)var(--tw-drop-shadow)}.ddoc{align-items:flex-start;gap:1.5rem;height:100vh;padding:1rem;display:flex}@media (min-width:1024px){.ddoc{padding:.5rem}}@media (min-width:1024px){.ddoc:not(:has(#categoryPanel)){padding-top:1rem}}@media (min-width:1024px){.ddoc:has(#categoryPanel)>div:not(#categoryPanel){padding-top:1rem}.ddoc:has(#categoryPanel) #topnav{margin-left:-1.5rem!important;padding-left:1.5rem!important}}.ddoc:not(:has(#categoryPanel)),.ddoc:has(#categoryPanel)>div:not(#categoryPanel){padding-top:.25rem}.ddoc>div:not(#categoryPanel){flex-direction:column;flex-grow:1;display:flex}#categoryPanel{box-sizing:border-box;flex-shrink:0;width:250px;height:-moz-fit-content;height:fit-content;max-height:100vh;margin-top:0;padding-top:0;position:sticky;top:0}@media not all and (min-width:1024px){#categoryPanel{display:none}}@media (min-width:1024px){#categoryPanel{flex-direction:column;display:flex}}#content{margin-top:1rem}#content>main{flex-direction:column;flex-grow:1;grid-column:1/-1;gap:.75rem;min-width:0;padding-bottom:0;display:flex}@media (min-width:768px){#content>main{padding-bottom:2rem}}@media (min-width:1024px){#content>main{padding-bottom:3rem}#content:has(.toc)>main{grid-column:span 3/span 3;grid-row-start:1}}#topnav{margin-left:-1rem;padding-left:1rem}@media (min-width:1024px){#topnav{margin-left:-.5rem;padding-left:.5rem}}#content,#topnav>div{flex-direction:row;justify-content:space-between;gap:2rem;display:flex}@media (min-width:1024px){#content,#topnav>div{gap:3rem}}.toc,#searchbar{flex-shrink:0;min-width:250px;max-width:300px}.toc{box-sizing:border-box;row-gap:1rem;height:-moz-fit-content;height:fit-content;max-height:100vh;margin-top:-3.5rem;padding-top:3.5rem;position:sticky;top:0}@media not all and (min-width:1024px){.toc{grid-row-start:1}}@media not all and (min-width:640px){.toc{display:none}}@media (min-width:640px){.toc{flex-direction:column;display:flex}}@media (min-width:1024px){.toc{grid-column:span 1/-1}}.toc>div{max-height:100%}@media (min-width:1024px){.toc>div{overflow-y:auto}}.toc>div>:last-child{padding-bottom:1rem}#searchResults{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));display:none;position:absolute;inset:0}.hover\:bg-stone-100:hover{--tw-bg-opacity:1;background-color:rgb(245 245 244/var(--tw-bg-opacity))} \ No newline at end of file diff --git a/src/html/templates/pages/symbol.hbs b/src/html/templates/pages/symbol.hbs index dac9b5b3..3151c001 100644 --- a/src/html/templates/pages/symbol.hbs +++ b/src/html/templates/pages/symbol.hbs @@ -1,5 +1,5 @@ {{~> pages/html_head html_head_ctx ~}} -{{~> pages/category_panel categories_panel ~}} +{{~> category_panel categories_panel ~}}
{{~> pages/top_nav ~}} diff --git a/src/html/templates/styles.css b/src/html/templates/styles.css index a66cd627..e36aafae 100644 --- a/src/html/templates/styles.css +++ b/src/html/templates/styles.css @@ -198,7 +198,7 @@ a { } .documentNavigation { - @apply max-lg:hidden text-sm space-y-3; + @apply max-sm:hidden text-sm space-y-3; > ul { @apply space-y-2 block overflow-y-auto flex-grow; @@ -296,6 +296,18 @@ a { } } +#categoryPanel { + @apply pt-3; + + ul { + @apply space-y-3; + } + + a { + @apply hover:underline block overflow-hidden whitespace-nowrap text-ellipsis py-1.5 px-3.5; + } +} + .contextLink { @apply text-contextLink/80 underline decoration-[1.5px] decoration-contextLink/50 underline-offset-[0.15em] hover:text-contextLink hover:decoration-contextLink; text-decoration-skip-ink: auto diff --git a/src/html/templates/styles.gen.css b/src/html/templates/styles.gen.css index a582af54..240f5725 100644 --- a/src/html/templates/styles.gen.css +++ b/src/html/templates/styles.gen.css @@ -1 +1 @@ -.ddoc .container{width:100%}@media (min-width:640px){.ddoc .container{max-width:640px}}@media (min-width:768px){.ddoc .container{max-width:768px}}@media (min-width:1024px){.ddoc .container{max-width:1024px}}@media (min-width:1280px){.ddoc .container{max-width:1280px}}@media (min-width:1536px){.ddoc .container{max-width:1536px}}.ddoc .static{position:static}.ddoc .relative{position:relative}.ddoc .\!mb-0{margin-bottom:0!important}.ddoc .\!mt-2{margin-top:.5rem!important}.ddoc .mb-1{margin-bottom:.25rem}.ddoc .ml-4{margin-left:1rem}.ddoc .ml-indent{margin-left:2ch}.ddoc .mr-2{margin-right:.5rem}.ddoc .mt-3{margin-top:.75rem}.ddoc .block{display:block}.ddoc .inline{display:inline}.ddoc .\!flex{display:flex!important}.ddoc .flex{display:flex}.ddoc .inline-flex{display:inline-flex}.ddoc .table{display:table}.ddoc .contents{display:contents}.ddoc .hidden{display:none}.ddoc .h-4{height:1rem}.ddoc .h-5{height:1.25rem}.ddoc .min-w-0{min-width:0}.ddoc .max-w-\[75ch\]{max-width:75ch}.ddoc .flex-1{flex:1}.ddoc .flex-none{flex:none}.ddoc .grow{flex-grow:1}.ddoc .rotate-90{--tw-rotate:90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y))rotate(var(--tw-rotate))skewX(var(--tw-skew-x))skewY(var(--tw-skew-y))scaleX(var(--tw-scale-x))scaleY(var(--tw-scale-y))}.ddoc .scroll-mt-16{scroll-margin-top:4rem}.ddoc .items-center{align-items:center}.ddoc .gap-0{gap:0}.ddoc .gap-0\.5{gap:.125rem}.ddoc .gap-1{gap:.25rem}.ddoc .gap-2{gap:.5rem}.ddoc .space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(.25rem*var(--tw-space-x-reverse));margin-left:calc(.25rem*calc(1 - var(--tw-space-x-reverse)))}.ddoc .space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(.5rem*var(--tw-space-x-reverse));margin-left:calc(.5rem*calc(1 - var(--tw-space-x-reverse)))}.ddoc .space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .space-y-7>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.75rem*var(--tw-space-y-reverse))}.ddoc .space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.ddoc .overflow-x-auto{overflow-x:auto}.ddoc .break-words{overflow-wrap:break-word}.ddoc .break-all{word-break:break-all}.ddoc .rounded{border-radius:.25rem}.ddoc .rounded-md{border-radius:.375rem}.ddoc .border{border-width:1px}.ddoc .border-b{border-bottom-width:1px}.ddoc .border-l-2{border-left-width:2px}.ddoc .border-Class\/50{border-color:#20b44b80}.ddoc .border-Enum\/50{border-color:#22abb080}.ddoc .border-Function\/50{border-color:#056cf080}.ddoc .border-Interface\/50{border-color:#d2a06480}.ddoc .border-Method\/50{border-color:#056cf080}.ddoc .border-Namespace\/50{border-color:#d2564680}.ddoc .border-Property\/50{border-color:#7e57c080}.ddoc .border-TypeAlias\/50{border-color:#a4478c80}.ddoc .border-Variable\/50{border-color:#7e57c080}.ddoc .border-abstract\/50{border-color:#0cafc680}.ddoc .border-deprecated\/50{border-color:#dc262680}.ddoc .border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.ddoc .border-new\/50{border-color:#7b61ff80}.ddoc .border-optional\/50{border-color:#0cafc680}.ddoc .border-other\/50{border-color:#57534e80}.ddoc .border-permissions\/50,.ddoc .border-private\/50{border-color:#0cafc680}.ddoc .border-protected\/50,.ddoc .border-readonly\/50{border-color:#7b61ff80}.ddoc .border-stone-300{--tw-border-opacity:1;border-color:rgb(214 211 209/var(--tw-border-opacity))}.ddoc .border-unstable\/50,.ddoc .border-writeonly\/50{border-color:#7b61ff80}.ddoc .bg-Class\/15{background-color:#20b44b26}.ddoc .bg-Class\/5{background-color:#20b44b0d}.ddoc .bg-Enum\/15{background-color:#22abb026}.ddoc .bg-Enum\/5{background-color:#22abb00d}.ddoc .bg-Function\/15{background-color:#056cf026}.ddoc .bg-Function\/5{background-color:#056cf00d}.ddoc .bg-Interface\/15{background-color:#d2a06426}.ddoc .bg-Interface\/5{background-color:#d2a0640d}.ddoc .bg-Method\/15{background-color:#056cf026}.ddoc .bg-Method\/5{background-color:#056cf00d}.ddoc .bg-Namespace\/15{background-color:#d2564626}.ddoc .bg-Namespace\/5{background-color:#d256460d}.ddoc .bg-Property\/15{background-color:#7e57c026}.ddoc .bg-Property\/5{background-color:#7e57c00d}.ddoc .bg-TypeAlias\/15{background-color:#a4478c26}.ddoc .bg-TypeAlias\/5{background-color:#a4478c0d}.ddoc .bg-Variable\/15{background-color:#7e57c026}.ddoc .bg-Variable\/5{background-color:#7e57c00d}.ddoc .bg-abstract\/15{background-color:#0cafc626}.ddoc .bg-abstract\/5{background-color:#0cafc60d}.ddoc .bg-deprecated\/15{background-color:#dc262626}.ddoc .bg-deprecated\/5{background-color:#dc26260d}.ddoc .bg-new\/15{background-color:#7b61ff26}.ddoc .bg-new\/5{background-color:#7b61ff0d}.ddoc .bg-optional\/15{background-color:#0cafc626}.ddoc .bg-optional\/5{background-color:#0cafc60d}.ddoc .bg-other\/15{background-color:#57534e26}.ddoc .bg-other\/5{background-color:#57534e0d}.ddoc .bg-permissions\/15{background-color:#0cafc626}.ddoc .bg-permissions\/5{background-color:#0cafc60d}.ddoc .bg-private\/15{background-color:#0cafc626}.ddoc .bg-private\/5{background-color:#0cafc60d}.ddoc .bg-protected\/15{background-color:#7b61ff26}.ddoc .bg-protected\/5{background-color:#7b61ff0d}.ddoc .bg-readonly\/15{background-color:#7b61ff26}.ddoc .bg-readonly\/5{background-color:#7b61ff0d}.ddoc .bg-stone-100{--tw-bg-opacity:1;background-color:rgb(245 245 244/var(--tw-bg-opacity))}.ddoc .bg-unstable\/15{background-color:#7b61ff26}.ddoc .bg-unstable\/5{background-color:#7b61ff0d}.ddoc .bg-writeonly\/15{background-color:#7b61ff26}.ddoc .bg-writeonly\/5{background-color:#7b61ff0d}.ddoc .px-2{padding-left:.5rem;padding-right:.5rem}.ddoc .px-3{padding-left:.75rem;padding-right:.75rem}.ddoc .px-4{padding-left:1rem;padding-right:1rem}.ddoc .py-1{padding-top:.25rem;padding-bottom:.25rem}.ddoc .py-2{padding-top:.5rem;padding-bottom:.5rem}.ddoc .pb-5{padding-bottom:1.25rem}.ddoc .pt-4{padding-top:1rem}.ddoc .text-2xl{font-size:1.5rem;line-height:2rem}.ddoc .text-base{font-size:1rem;line-height:1.5rem}.ddoc .text-sm{font-size:.875rem;line-height:1.25rem}.ddoc .font-bold{font-weight:700}.ddoc .font-medium{font-weight:500}.ddoc .font-normal{font-weight:400}.ddoc .italic{font-style:italic}.ddoc .leading-none{line-height:1}.ddoc .text-Class{--tw-text-opacity:1;color:rgb(32 180 75/var(--tw-text-opacity))}.ddoc .text-Enum{--tw-text-opacity:1;color:rgb(34 171 176/var(--tw-text-opacity))}.ddoc .text-Function{--tw-text-opacity:1;color:rgb(5 108 240/var(--tw-text-opacity))}.ddoc .text-Interface{--tw-text-opacity:1;color:rgb(210 160 100/var(--tw-text-opacity))}.ddoc .text-Method{--tw-text-opacity:1;color:rgb(5 108 240/var(--tw-text-opacity))}.ddoc .text-Namespace{--tw-text-opacity:1;color:rgb(210 86 70/var(--tw-text-opacity))}.ddoc .text-Property{--tw-text-opacity:1;color:rgb(126 87 192/var(--tw-text-opacity))}.ddoc .text-TypeAlias{--tw-text-opacity:1;color:rgb(164 71 140/var(--tw-text-opacity))}.ddoc .text-Variable{--tw-text-opacity:1;color:rgb(126 87 192/var(--tw-text-opacity))}.ddoc .text-\[\#0F172A\]{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity))}.ddoc .text-abstract{--tw-text-opacity:1;color:rgb(12 175 198/var(--tw-text-opacity))}.ddoc .text-deprecated{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.ddoc .text-new{--tw-text-opacity:1;color:rgb(123 97 255/var(--tw-text-opacity))}.ddoc .text-optional{--tw-text-opacity:1;color:rgb(12 175 198/var(--tw-text-opacity))}.ddoc .text-other{--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity))}.ddoc .text-permissions,.ddoc .text-private{--tw-text-opacity:1;color:rgb(12 175 198/var(--tw-text-opacity))}.ddoc .text-protected,.ddoc .text-readonly{--tw-text-opacity:1;color:rgb(123 97 255/var(--tw-text-opacity))}.ddoc .text-stone-500{--tw-text-opacity:1;color:rgb(120 113 108/var(--tw-text-opacity))}.ddoc .text-unstable,.ddoc .text-writeonly{--tw-text-opacity:1;color:rgb(123 97 255/var(--tw-text-opacity))}.ddoc .filter{filter:var(--tw-blur)var(--tw-brightness)var(--tw-contrast)var(--tw-grayscale)var(--tw-hue-rotate)var(--tw-invert)var(--tw-saturate)var(--tw-sepia)var(--tw-drop-shadow)}.ddoc summary::-webkit-details-marker{display:none}.ddoc a{word-wrap:break-word}.ddoc{--ddoc-selection-border-width:2px;--ddoc-selection-border-color-default:#d6d3d1;--ddoc-selection-selected-border-color:#2564eb;--ddoc-selection-selected-bg:#056cf00c;--ddoc-selection-padding:9px 15px}.ddoc .link{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity));transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter,backdrop-filter,-webkit-backdrop-filter;transition-duration:75ms;transition-timing-function:cubic-bezier(.4,0,.2,1)}.ddoc .link:hover{--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}.ddoc .anchor{float:left;--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity));margin-left:-24px;padding:.25rem;line-height:1;display:none;top:0;bottom:0}.ddoc .anchorable{scroll-margin-top:4rem;position:relative}.ddoc .anchorable:hover .anchor{display:block}.ddoc .deprecated>div:first-child{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity));align-items:center;gap:.25rem;padding-top:.25rem;padding-bottom:.25rem;display:flex}.ddoc .deprecated>div:first-child>span{font-weight:600;line-height:1.5rem}.ddoc .deprecated>div:nth-child(2){--tw-border-opacity:1;border-left-width:4px;border-color:rgb(252 165 165/var(--tw-border-opacity));margin-left:.25rem;padding-left:.5rem}.ddoc .symbolSubtitle>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.125rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem*var(--tw-space-y-reverse))}.ddoc .symbolSubtitle{font-size:.875rem;line-height:1rem}.ddoc .symbolSubtitle .type{--tw-text-opacity:1;color:rgb(168 162 158/var(--tw-text-opacity));font-style:italic}.ddoc .docEntry{margin-bottom:1rem}.ddoc .docEntry>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .docEntry .docEntryHeader{justify-content:space-between;align-items:flex-start;display:flex}@media (min-width:768px){.ddoc .docEntry .docEntryHeader{font-size:1rem;line-height:1.5rem}}.ddoc .docEntry .docEntryHeader>div{overflow-wrap:break-word}.ddoc .section{margin-bottom:.5rem;scroll-margin-top:4rem}.ddoc .section>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .section>div:first-child>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.ddoc .section>div:first-child>h2{padding-top:.25rem;padding-bottom:.25rem;font-size:1.25rem;font-weight:600;line-height:1.5rem}.ddoc .section>div:first-child>.markdown_summary{max-width:75ch;font-size:1rem;line-height:1.5rem}.ddoc .namespaceSection{-moz-column-gap:2.5rem;grid-template-columns:repeat(1,minmax(0,1fr));gap:1.5rem 2.5rem;display:grid}@media (min-width:768px){.ddoc .namespaceSection{-moz-column-gap:2rem;grid-template-columns:repeat(2,minmax(0,1fr));gap:2rem}}@media (min-width:1024px){.ddoc .namespaceSection{grid-template-columns:repeat(3,minmax(0,1fr))}}.ddoc .namespaceSection .namespaceItem{-moz-column-gap:.625rem;column-gap:.625rem;display:flex}@media (min-width:768px){.ddoc .namespaceSection .namespaceItem{min-height:4rem}}@media (min-width:1024px){.ddoc .namespaceSection .namespaceItem{padding-right:1rem}}.ddoc .namespaceSection .namespaceItem .docNodeKindIcon{flex-direction:column;justify-content:flex-start;width:auto}.ddoc .namespaceSection .namespaceItem .docNodeKindIcon>*+*{margin-top:-.125rem;margin-left:0}.ddoc .namespaceSection .namespaceItem[aria-label=deprecated]{opacity:.6}.ddoc .namespaceSection .namespaceItem[aria-label=deprecated] .namespaceItemContent>a{--tw-text-opacity:1;color:rgb(120 113 108/var(--tw-text-opacity));text-decoration-line:line-through;text-decoration-color:#78716cb3;text-decoration-thickness:2px}.ddoc .namespaceSection .namespaceItem .namespaceItemContent>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.ddoc .namespaceSection .namespaceItem .namespaceItemContent>a{word-break:break-all;font-weight:500;line-height:1.25;display:block}.ddoc .namespaceSection .namespaceItem .namespaceItemContent>div{--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity));font-size:.875rem;line-height:1.25rem}.ddoc .symbolGroup>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(3rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(3rem*var(--tw-space-y-reverse))}.ddoc .symbolGroup article>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.25rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem*var(--tw-space-y-reverse))}.ddoc .symbolGroup article>div:first-child{justify-content:space-between;align-items:flex-start;display:flex}.ddoc .symbolGroup article>div:first-child>div:first-child>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.ddoc .symbolGroup article>div:first-child>div:first-child{font-weight:500}.ddoc .docNodeKindIcon{flex-shrink:0;justify-content:flex-end;display:inline-flex}.ddoc .docNodeKindIcon div{-webkit-user-select:none;user-select:none;text-align:center;vertical-align:middle;border-radius:9999px;flex-shrink:0;width:1.25rem;height:1.25rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.75rem;font-weight:500;line-height:1.25rem}.ddoc .docNodeKindIcon>*+*{margin-left:-.375rem}.ddoc .example details summary{cursor:pointer;border-radius:.5rem;align-items:center;gap:.5rem;width:100%;padding-top:.5rem;padding-bottom:.5rem;line-height:1.5rem;list-style-type:none;display:flex}.ddoc .example details summary>div:first-child{-webkit-user-select:none;user-select:none;--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity))}.ddoc .example details[open] summary>div:first-child{--tw-rotate:90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y))rotate(var(--tw-rotate))skewX(var(--tw-skew-x))skewY(var(--tw-skew-y))scaleX(var(--tw-scale-x))scaleY(var(--tw-scale-y))}.ddoc .toc h3{margin-bottom:.75rem;font-size:1.125rem;font-weight:700;line-height:1.75rem}.ddoc .toc>div>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.25rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem*var(--tw-space-y-reverse))}.ddoc .toc .topSymbols>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.ddoc .toc .topSymbols{font-size:.875rem;line-height:1.25rem}.ddoc .toc .topSymbols ul{list-style-type:none}.ddoc .toc .topSymbols ul>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.625rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.625rem*var(--tw-space-y-reverse))}.ddoc .toc .topSymbols ul li{display:block}.ddoc .toc .topSymbols ul li a{align-items:center;gap:.5rem;display:flex}.ddoc .toc .topSymbols ul li a>span{text-overflow:ellipsis;white-space:nowrap;border-radius:.25rem;width:100%;margin-top:-.125rem;margin-bottom:-.125rem;margin-left:-.25rem;padding-top:.125rem;padding-bottom:.125rem;padding-left:.25rem;display:block;overflow:hidden}.ddoc .toc .topSymbols>a:hover{text-decoration-line:underline}.ddoc .toc .documentNavigation>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.ddoc .toc .documentNavigation{font-size:.875rem;line-height:1.25rem}@media not all and (min-width:1024px){.ddoc .toc .documentNavigation{display:none}}.ddoc .toc .documentNavigation>ul{flex-grow:1;display:block}.ddoc .toc .documentNavigation>ul>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .toc .documentNavigation>ul{overflow-y:auto}.ddoc .toc .documentNavigation>ul>li{margin-top:.125rem;margin-left:.75rem;margin-right:.75rem}.ddoc .toc .documentNavigation>ul li:has(>ul){margin-top:0!important}.ddoc .toc .documentNavigation>ul li:has(>a){padding-bottom:0!important}.ddoc .toc .documentNavigation>ul ul{margin-left:.875rem}.ddoc .toc .documentNavigation>ul ul>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .toc .documentNavigation>ul ul{--tw-text-opacity:1;color:rgb(134 135 137/var(--tw-text-opacity));font-size:.8rem;line-height:1}.ddoc .toc .documentNavigation>ul ul li{margin-top:.25rem!important}.ddoc .toc .documentNavigation>ul ul li a{padding:.25rem}.ddoc .toc .documentNavigation>ul ul li a:hover{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.ddoc .toc .documentNavigation a{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.ddoc .toc .documentNavigation a:hover{text-decoration-line:underline}.ddoc .usages nav{flex-direction:row;align-items:center;gap:.5rem;margin-bottom:.75rem;font-weight:600;display:flex}.ddoc .usages nav details>summary{cursor:pointer;-webkit-user-select:none;user-select:none;--tw-border-opacity:1;border-width:1px;border-color:rgb(209 213 219/var(--tw-border-opacity));border-radius:.25rem;gap:.25rem;padding:.5rem .75rem;display:flex}@media (min-width:768px){.ddoc .usages nav details>div{position:relative}}.ddoc .usages nav details>div>div{z-index:30;--tw-border-opacity:1;border-width:1px;border-color:rgb(209 213 219/var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));margin-top:.375rem;padding:.5rem;display:block;position:absolute}@media not all and (min-width:768px){.ddoc .usages nav details>div>div{border-left-width:0;border-right-width:0;left:0;right:0}}@media (min-width:768px){.ddoc .usages nav details>div>div{border-radius:.25rem;width:12rem}}.ddoc .usages nav details>div>div label{cursor:pointer;-webkit-user-select:none;user-select:none;border-radius:.125rem;align-items:center;gap:.5rem;padding:.25rem .5rem;line-height:1.5;display:flex}.ddoc .usages nav details>div>div label:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.ddoc .usageContent :not(.markdown) h3{margin-bottom:.75rem;font-size:1.125rem;font-weight:700;line-height:1.75rem}.ddoc .usageContent .markdown{--tw-text-opacity:1;color:rgb(104 104 104/var(--tw-text-opacity));font-size:.75rem;line-height:1rem}.ddoc .usageContent .markdown p{margin:0}.ddoc .usageContent pre.highlight{--tw-border-opacity:1;border-width:1px;border-color:rgb(209 213 219/var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}@media not all and (min-width:768px){.ddoc .usageContent pre.highlight{border-left-width:0;border-right-width:0}}.ddoc .usageContent pre.highlight{margin-top:.25rem!important}.ddoc .usageContent pre.highlight>code:first-child{scrollbar-width:thin;padding:.5rem .75rem}.ddoc .usageContent pre.highlight .context_button{border-width:0;display:none;top:.25rem;right:.5rem}.ddoc .usageContent pre.highlight .context_button svg rect{fill:#fff}.ddoc .usageContent pre.highlight:hover .context_button{opacity:1;display:block}.ddoc .contextLink{color:#0e6590cc;text-underline-offset:.15em;text-decoration-line:underline;text-decoration-color:#0e659080;text-decoration-thickness:1.5px}.ddoc .contextLink:hover{--tw-text-opacity:1;color:rgb(14 101 144/var(--tw-text-opacity));text-decoration-color:#0e6590}.ddoc .contextLink{-webkit-text-decoration-skip:ink;-webkit-text-decoration-skip-ink:auto;text-decoration-skip-ink:auto}.ddoc .breadcrumbs{word-break:break-all;flex-wrap:wrap;align-items:center;gap:.25rem;display:inline-flex}.ddoc .breadcrumbs>li:first-child{font-size:1.5rem;font-weight:700;line-height:1}.ddoc .breadcrumbs li{font-size:1.125rem;line-height:.9em;display:inline}@media (min-width:1024px){.ddoc .breadcrumbs li{font-size:1.25rem;line-height:1.75rem}}.ddoc .context_button{z-index:10;cursor:pointer;background-color:inherit;border-width:1px;border-radius:.25rem;padding:.375rem;line-height:0}.ddoc .context_button:hover{--tw-bg-opacity:1;background-color:rgb(231 229 228/var(--tw-bg-opacity))}.ddoc .markdown_border{border-color:#d6d3d166;border-left-width:2px;margin-left:.25rem;padding-left:.625rem}.ddoc .markdown_summary{--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity));display:inline}.ddoc .markdown_summary p{-webkit-line-clamp:4;-webkit-box-orient:vertical;display:inline-block;overflow:hidden}.ddoc .markdown_summary :not(pre)>code{--tw-bg-opacity:1;background-color:rgb(231 229 228/var(--tw-bg-opacity));border-radius:.25rem;padding:.125rem .375rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875rem;line-height:1.25rem}.ddoc .markdown{flex-shrink:1;min-width:0;max-width:40ch}.ddoc .markdown>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}@media (min-width:640px){.ddoc .markdown{max-width:640px}}@media (min-width:768px){.ddoc .markdown{max-width:768px}}@media (min-width:1024px){.ddoc .markdown{max-width:75ch}}.ddoc .markdown a:not(.no_color){--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity));transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter,backdrop-filter,-webkit-backdrop-filter;transition-duration:75ms;transition-timing-function:cubic-bezier(.4,0,.2,1)}.ddoc .markdown a:not(.no_color):hover{--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}.ddoc .markdown h1{--tw-border-opacity:1;border-bottom-width:1px;border-color:rgb(214 211 209/var(--tw-border-opacity));padding-bottom:.25rem;font-size:1.25rem;line-height:1.75rem}@media (min-width:768px){.ddoc .markdown h1{font-size:1.5rem;line-height:2rem}}@media (min-width:1024px){.ddoc .markdown h1{font-size:1.875rem;line-height:2.25rem}}.ddoc .markdown h2{--tw-border-opacity:1;border-bottom-width:1px;border-color:rgb(214 211 209/var(--tw-border-opacity));padding-bottom:.25rem;font-size:1.125rem;line-height:1.75rem}@media (min-width:768px){.ddoc .markdown h2{font-size:1.25rem;line-height:1.75rem}}@media (min-width:1024px){.ddoc .markdown h2{font-size:1.5rem;line-height:2rem}}.ddoc .markdown h3{font-weight:700}@media (min-width:768px){.ddoc .markdown h3{font-size:1.125rem;font-weight:400;line-height:1.75rem}}@media (min-width:1024px){.ddoc .markdown h3{font-size:1.25rem;font-weight:400;line-height:1.75rem}}.ddoc .markdown h4{font-weight:600}@media (min-width:768px){.ddoc .markdown h4{font-weight:700}}@media (min-width:1024px){.ddoc .markdown h4{font-size:1.125rem;font-weight:400;line-height:1.75rem}}.ddoc .markdown h5{font-style:italic}@media (min-width:768px){.ddoc .markdown h5{font-weight:600}}@media (min-width:1024px){.ddoc .markdown h5{font-weight:700}}@media (min-width:768px){.ddoc .markdown h6{font-style:italic}}@media (min-width:1024px){.ddoc .markdown h6{font-weight:600}}.ddoc .markdown hr{--tw-border-opacity:1;border-color:rgb(120 113 108/var(--tw-border-opacity));margin:.5rem}.ddoc .markdown ol,.ddoc .markdown ul{margin-left:1rem;list-style-position:outside}.ddoc .markdown ol{list-style-type:decimal}.ddoc .markdown ul{list-style-type:disc}.ddoc .markdown :not(pre)>code{--tw-bg-opacity:1;background-color:rgb(231 229 228/var(--tw-bg-opacity));border-radius:.375rem;padding:.125rem .375rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875rem;line-height:1.25rem}:is(.ddoc .markdown h1,.ddoc .markdown h2,.ddoc .markdown h3,.ddoc .markdown h4,.ddoc .markdown h5,.ddoc .markdown h6)>code{font-size:inherit!important}.ddoc .markdown pre{--tw-border-opacity:1;border-top-width:1.5px;border-bottom-width:1.5px;border-color:rgb(203 213 225/var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity));border-radius:0;margin-left:-1rem;margin-right:-1rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875rem;line-height:1.25rem}@media (min-width:768px){.ddoc .markdown pre{border-width:1.5px;border-radius:.375rem;margin-left:0;margin-right:0}}.ddoc .markdown pre>code:first-child{padding:1rem 1.5rem;display:block;overflow-x:auto}.ddoc .markdown p{margin:.25rem 0}.ddoc .markdown table{table-layout:auto;width:max-content;max-width:100%;display:block;overflow:auto}.ddoc .markdown td{padding:.5rem}.ddoc .markdown th{text-align:center;padding-top:.375rem;padding-bottom:.375rem;font-weight:700}.ddoc .markdown th,.ddoc .markdown td{--tw-border-opacity:1;border-width:1.5px;border-color:rgb(203 213 225/var(--tw-border-opacity))}.ddoc .markdown tr:nth-child(2n){--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}.ddoc .markdown img{display:inline-block}.ddoc .markdown .alert>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .markdown .alert{border-left-width:4px;padding:.5rem 1rem}.ddoc .markdown .alert div:first-child{align-items:center;gap:.375rem;font-weight:500;display:flex}.ddoc .markdown .alert div:first-child svg{width:1.25rem;height:1.25rem}.ddoc .markdown .alert-note{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity))}.ddoc .markdown .alert-note div:first-child{stroke:#2563eb;--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity))}.ddoc .markdown .alert-tip{--tw-border-opacity:1;border-color:rgb(22 163 74/var(--tw-border-opacity))}.ddoc .markdown .alert-tip div:first-child{stroke:#16a34a;--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity))}.ddoc .markdown .alert-important{--tw-border-opacity:1;border-color:rgb(147 51 234/var(--tw-border-opacity))}.ddoc .markdown .alert-important div:first-child{stroke:#9333ea;--tw-text-opacity:1;color:rgb(147 51 234/var(--tw-text-opacity))}.ddoc .markdown .alert-warning{--tw-border-opacity:1;border-color:rgb(202 138 4/var(--tw-border-opacity))}.ddoc .markdown .alert-warning div:first-child{stroke:#ca8a04;--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity))}.ddoc .markdown .alert-caution{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity))}.ddoc .markdown .alert-caution div:first-child{stroke:#dc2626;--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.ddoc .markdown .highlight{position:relative}.ddoc .markdown .highlight .lineNumbers{--tw-border-opacity:1;border-right-width:2px;border-color:rgb(214 211 209/var(--tw-border-opacity));text-align:right;flex:none;padding-right:.25rem}.ddoc .markdown .highlight .context_button{opacity:.6;position:absolute;top:.75rem;right:1rem}.ddoc .markdown .highlight .context_button:hover{opacity:1}.ddoc .markdown .highlight .pl-c{color:#6a737d}.ddoc .markdown .highlight .pl-c1,.ddoc .markdown .highlight .pl-s .pl-v{color:#005cc5}.ddoc .markdown .highlight .pl-e,.ddoc .markdown .highlight .pl-en{color:#6f42c1}.ddoc .markdown .highlight .pl-smi,.ddoc .markdown .highlight .pl-s .pl-s1{color:#24292e}.ddoc .markdown .highlight .pl-ent{color:#22863a}.ddoc .markdown .highlight .pl-k{color:#d73a49}.ddoc .markdown .highlight .pl-s,.ddoc .markdown .highlight .pl-pds,.ddoc .markdown .highlight .pl-s .pl-pse .pl-s1,.ddoc .markdown .highlight .pl-sr,.ddoc .markdown .highlight .pl-sr .pl-cce,.ddoc .markdown .highlight .pl-sr .pl-sre,.ddoc .markdown .highlight .pl-sr .pl-sra{color:#032f62}.ddoc .markdown .highlight .pl-v,.ddoc .markdown .highlight .pl-smw{color:#e36209}.ddoc .markdown .highlight .pl-bu{color:#b31d28}.ddoc .markdown .highlight .pl-ii{color:#fafbfc;background-color:#b31d28}.ddoc .markdown .highlight .pl-c2{color:#fafbfc;background-color:#d73a49}.ddoc .markdown .highlight .pl-c2:before{content:"^M"}.ddoc .markdown .highlight .pl-sr .pl-cce{color:#22863a;font-weight:700}.ddoc .markdown .highlight .pl-ml{color:#735c0f}.ddoc .markdown .highlight .pl-mh,.ddoc .markdown .highlight .pl-mh .pl-en,.ddoc .markdown .highlight .pl-ms{color:#005cc5;font-weight:700}.ddoc .markdown .highlight .pl-mi{color:#24292e;font-style:italic}.ddoc .markdown .highlight .pl-mb{color:#24292e;font-weight:700}.ddoc .markdown .highlight .pl-md{color:#b31d28;background-color:#ffeef0}.ddoc .markdown .highlight .pl-mi1{color:#22863a;background-color:#f0fff4}.ddoc .markdown .highlight .pl-mc{color:#e36209;background-color:#ffebda}.ddoc .markdown .highlight .pl-mi2{color:#f6f8fa;background-color:#005cc5}.ddoc .\*\:h-4>*{height:1rem}.ddoc .\*\:h-5>*{height:1.25rem}.ddoc .\*\:w-auto>*{width:auto}.ddoc .\*\:flex-none>*{flex:none}.ddoc .target\:bg-yellow-200:target{--tw-bg-opacity:1;background-color:rgb(254 240 138/var(--tw-bg-opacity))}.ddoc .hover\:bg-Class\/15:hover{background-color:#20b44b26}.ddoc .hover\:bg-Class\/5:hover{background-color:#20b44b0d}.ddoc .hover\:bg-Enum\/15:hover{background-color:#22abb026}.ddoc .hover\:bg-Enum\/5:hover{background-color:#22abb00d}.ddoc .hover\:bg-Function\/15:hover{background-color:#056cf026}.ddoc .hover\:bg-Function\/5:hover{background-color:#056cf00d}.ddoc .hover\:bg-Interface\/15:hover{background-color:#d2a06426}.ddoc .hover\:bg-Interface\/5:hover{background-color:#d2a0640d}.ddoc .hover\:bg-Method\/15:hover{background-color:#056cf026}.ddoc .hover\:bg-Method\/5:hover{background-color:#056cf00d}.ddoc .hover\:bg-Namespace\/15:hover{background-color:#d2564626}.ddoc .hover\:bg-Namespace\/5:hover{background-color:#d256460d}.ddoc .hover\:bg-Property\/15:hover{background-color:#7e57c026}.ddoc .hover\:bg-Property\/5:hover{background-color:#7e57c00d}.ddoc .hover\:bg-TypeAlias\/15:hover{background-color:#a4478c26}.ddoc .hover\:bg-TypeAlias\/5:hover{background-color:#a4478c0d}.ddoc .hover\:bg-Variable\/15:hover{background-color:#7e57c026}.ddoc .hover\:bg-Variable\/5:hover{background-color:#7e57c00d}.ddoc .hover\:bg-abstract\/15:hover{background-color:#0cafc626}.ddoc .hover\:bg-abstract\/5:hover{background-color:#0cafc60d}.ddoc .hover\:bg-deprecated\/15:hover{background-color:#dc262626}.ddoc .hover\:bg-deprecated\/5:hover{background-color:#dc26260d}.ddoc .hover\:bg-new\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-new\/5:hover{background-color:#7b61ff0d}.ddoc .hover\:bg-optional\/15:hover{background-color:#0cafc626}.ddoc .hover\:bg-optional\/5:hover{background-color:#0cafc60d}.ddoc .hover\:bg-other\/15:hover{background-color:#57534e26}.ddoc .hover\:bg-other\/5:hover{background-color:#57534e0d}.ddoc .hover\:bg-permissions\/15:hover{background-color:#0cafc626}.ddoc .hover\:bg-permissions\/5:hover{background-color:#0cafc60d}.ddoc .hover\:bg-private\/15:hover{background-color:#0cafc626}.ddoc .hover\:bg-private\/5:hover{background-color:#0cafc60d}.ddoc .hover\:bg-protected\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-protected\/5:hover{background-color:#7b61ff0d}.ddoc .hover\:bg-readonly\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-readonly\/5:hover{background-color:#7b61ff0d}.ddoc .hover\:bg-unstable\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-unstable\/5:hover{background-color:#7b61ff0d}.ddoc .hover\:bg-writeonly\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-writeonly\/5:hover{background-color:#7b61ff0d} \ No newline at end of file +.ddoc .container{width:100%}@media (min-width:640px){.ddoc .container{max-width:640px}}@media (min-width:768px){.ddoc .container{max-width:768px}}@media (min-width:1024px){.ddoc .container{max-width:1024px}}@media (min-width:1280px){.ddoc .container{max-width:1280px}}@media (min-width:1536px){.ddoc .container{max-width:1536px}}.ddoc .static{position:static}.ddoc .relative{position:relative}.ddoc .\!mb-0{margin-bottom:0!important}.ddoc .\!mt-2{margin-top:.5rem!important}.ddoc .mb-1{margin-bottom:.25rem}.ddoc .ml-4{margin-left:1rem}.ddoc .ml-indent{margin-left:2ch}.ddoc .mr-2{margin-right:.5rem}.ddoc .mt-3{margin-top:.75rem}.ddoc .block{display:block}.ddoc .inline{display:inline}.ddoc .\!flex{display:flex!important}.ddoc .flex{display:flex}.ddoc .inline-flex{display:inline-flex}.ddoc .table{display:table}.ddoc .contents{display:contents}.ddoc .hidden{display:none}.ddoc .h-4{height:1rem}.ddoc .h-5{height:1.25rem}.ddoc .min-w-0{min-width:0}.ddoc .max-w-\[75ch\]{max-width:75ch}.ddoc .flex-1{flex:1}.ddoc .flex-none{flex:none}.ddoc .grow{flex-grow:1}.ddoc .rotate-90{--tw-rotate:90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y))rotate(var(--tw-rotate))skewX(var(--tw-skew-x))skewY(var(--tw-skew-y))scaleX(var(--tw-scale-x))scaleY(var(--tw-scale-y))}.ddoc .scroll-mt-16{scroll-margin-top:4rem}.ddoc .items-center{align-items:center}.ddoc .gap-0{gap:0}.ddoc .gap-0\.5{gap:.125rem}.ddoc .gap-1{gap:.25rem}.ddoc .gap-2{gap:.5rem}.ddoc .space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(.25rem*var(--tw-space-x-reverse));margin-left:calc(.25rem*calc(1 - var(--tw-space-x-reverse)))}.ddoc .space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(.5rem*var(--tw-space-x-reverse));margin-left:calc(.5rem*calc(1 - var(--tw-space-x-reverse)))}.ddoc .space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .space-y-7>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.75rem*var(--tw-space-y-reverse))}.ddoc .space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.ddoc .overflow-x-auto{overflow-x:auto}.ddoc .break-words{overflow-wrap:break-word}.ddoc .break-all{word-break:break-all}.ddoc .rounded{border-radius:.25rem}.ddoc .rounded-md{border-radius:.375rem}.ddoc .border{border-width:1px}.ddoc .border-b{border-bottom-width:1px}.ddoc .border-l-2{border-left-width:2px}.ddoc .border-Class\/50{border-color:#20b44b80}.ddoc .border-Enum\/50{border-color:#22abb080}.ddoc .border-Function\/50{border-color:#056cf080}.ddoc .border-Interface\/50{border-color:#d2a06480}.ddoc .border-Method\/50{border-color:#056cf080}.ddoc .border-Namespace\/50{border-color:#d2564680}.ddoc .border-Property\/50{border-color:#7e57c080}.ddoc .border-TypeAlias\/50{border-color:#a4478c80}.ddoc .border-Variable\/50{border-color:#7e57c080}.ddoc .border-abstract\/50{border-color:#0cafc680}.ddoc .border-deprecated\/50{border-color:#dc262680}.ddoc .border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.ddoc .border-new\/50{border-color:#7b61ff80}.ddoc .border-optional\/50{border-color:#0cafc680}.ddoc .border-other\/50{border-color:#57534e80}.ddoc .border-permissions\/50,.ddoc .border-private\/50{border-color:#0cafc680}.ddoc .border-protected\/50,.ddoc .border-readonly\/50{border-color:#7b61ff80}.ddoc .border-stone-300{--tw-border-opacity:1;border-color:rgb(214 211 209/var(--tw-border-opacity))}.ddoc .border-unstable\/50,.ddoc .border-writeonly\/50{border-color:#7b61ff80}.ddoc .bg-Class\/15{background-color:#20b44b26}.ddoc .bg-Class\/5{background-color:#20b44b0d}.ddoc .bg-Enum\/15{background-color:#22abb026}.ddoc .bg-Enum\/5{background-color:#22abb00d}.ddoc .bg-Function\/15{background-color:#056cf026}.ddoc .bg-Function\/5{background-color:#056cf00d}.ddoc .bg-Interface\/15{background-color:#d2a06426}.ddoc .bg-Interface\/5{background-color:#d2a0640d}.ddoc .bg-Method\/15{background-color:#056cf026}.ddoc .bg-Method\/5{background-color:#056cf00d}.ddoc .bg-Namespace\/15{background-color:#d2564626}.ddoc .bg-Namespace\/5{background-color:#d256460d}.ddoc .bg-Property\/15{background-color:#7e57c026}.ddoc .bg-Property\/5{background-color:#7e57c00d}.ddoc .bg-TypeAlias\/15{background-color:#a4478c26}.ddoc .bg-TypeAlias\/5{background-color:#a4478c0d}.ddoc .bg-Variable\/15{background-color:#7e57c026}.ddoc .bg-Variable\/5{background-color:#7e57c00d}.ddoc .bg-abstract\/15{background-color:#0cafc626}.ddoc .bg-abstract\/5{background-color:#0cafc60d}.ddoc .bg-deprecated\/15{background-color:#dc262626}.ddoc .bg-deprecated\/5{background-color:#dc26260d}.ddoc .bg-new\/15{background-color:#7b61ff26}.ddoc .bg-new\/5{background-color:#7b61ff0d}.ddoc .bg-optional\/15{background-color:#0cafc626}.ddoc .bg-optional\/5{background-color:#0cafc60d}.ddoc .bg-other\/15{background-color:#57534e26}.ddoc .bg-other\/5{background-color:#57534e0d}.ddoc .bg-permissions\/15{background-color:#0cafc626}.ddoc .bg-permissions\/5{background-color:#0cafc60d}.ddoc .bg-private\/15{background-color:#0cafc626}.ddoc .bg-private\/5{background-color:#0cafc60d}.ddoc .bg-protected\/15{background-color:#7b61ff26}.ddoc .bg-protected\/5{background-color:#7b61ff0d}.ddoc .bg-readonly\/15{background-color:#7b61ff26}.ddoc .bg-readonly\/5{background-color:#7b61ff0d}.ddoc .bg-stone-100{--tw-bg-opacity:1;background-color:rgb(245 245 244/var(--tw-bg-opacity))}.ddoc .bg-unstable\/15{background-color:#7b61ff26}.ddoc .bg-unstable\/5{background-color:#7b61ff0d}.ddoc .bg-writeonly\/15{background-color:#7b61ff26}.ddoc .bg-writeonly\/5{background-color:#7b61ff0d}.ddoc .px-2{padding-left:.5rem;padding-right:.5rem}.ddoc .px-3{padding-left:.75rem;padding-right:.75rem}.ddoc .px-4{padding-left:1rem;padding-right:1rem}.ddoc .py-1{padding-top:.25rem;padding-bottom:.25rem}.ddoc .py-2{padding-top:.5rem;padding-bottom:.5rem}.ddoc .pb-5{padding-bottom:1.25rem}.ddoc .pt-4{padding-top:1rem}.ddoc .text-2xl{font-size:1.5rem;line-height:2rem}.ddoc .text-base{font-size:1rem;line-height:1.5rem}.ddoc .text-sm{font-size:.875rem;line-height:1.25rem}.ddoc .font-bold{font-weight:700}.ddoc .font-medium{font-weight:500}.ddoc .font-normal{font-weight:400}.ddoc .italic{font-style:italic}.ddoc .leading-none{line-height:1}.ddoc .text-Class{--tw-text-opacity:1;color:rgb(32 180 75/var(--tw-text-opacity))}.ddoc .text-Enum{--tw-text-opacity:1;color:rgb(34 171 176/var(--tw-text-opacity))}.ddoc .text-Function{--tw-text-opacity:1;color:rgb(5 108 240/var(--tw-text-opacity))}.ddoc .text-Interface{--tw-text-opacity:1;color:rgb(210 160 100/var(--tw-text-opacity))}.ddoc .text-Method{--tw-text-opacity:1;color:rgb(5 108 240/var(--tw-text-opacity))}.ddoc .text-Namespace{--tw-text-opacity:1;color:rgb(210 86 70/var(--tw-text-opacity))}.ddoc .text-Property{--tw-text-opacity:1;color:rgb(126 87 192/var(--tw-text-opacity))}.ddoc .text-TypeAlias{--tw-text-opacity:1;color:rgb(164 71 140/var(--tw-text-opacity))}.ddoc .text-Variable{--tw-text-opacity:1;color:rgb(126 87 192/var(--tw-text-opacity))}.ddoc .text-\[\#0F172A\]{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity))}.ddoc .text-abstract{--tw-text-opacity:1;color:rgb(12 175 198/var(--tw-text-opacity))}.ddoc .text-deprecated{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.ddoc .text-new{--tw-text-opacity:1;color:rgb(123 97 255/var(--tw-text-opacity))}.ddoc .text-optional{--tw-text-opacity:1;color:rgb(12 175 198/var(--tw-text-opacity))}.ddoc .text-other{--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity))}.ddoc .text-permissions,.ddoc .text-private{--tw-text-opacity:1;color:rgb(12 175 198/var(--tw-text-opacity))}.ddoc .text-protected,.ddoc .text-readonly{--tw-text-opacity:1;color:rgb(123 97 255/var(--tw-text-opacity))}.ddoc .text-stone-500{--tw-text-opacity:1;color:rgb(120 113 108/var(--tw-text-opacity))}.ddoc .text-unstable,.ddoc .text-writeonly{--tw-text-opacity:1;color:rgb(123 97 255/var(--tw-text-opacity))}.ddoc .filter{filter:var(--tw-blur)var(--tw-brightness)var(--tw-contrast)var(--tw-grayscale)var(--tw-hue-rotate)var(--tw-invert)var(--tw-saturate)var(--tw-sepia)var(--tw-drop-shadow)}.ddoc summary::-webkit-details-marker{display:none}.ddoc a{word-wrap:break-word}.ddoc{--ddoc-selection-border-width:2px;--ddoc-selection-border-color-default:#d6d3d1;--ddoc-selection-selected-border-color:#2564eb;--ddoc-selection-selected-bg:#056cf00c;--ddoc-selection-padding:9px 15px}.ddoc .link{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity));transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter,backdrop-filter,-webkit-backdrop-filter;transition-duration:75ms;transition-timing-function:cubic-bezier(.4,0,.2,1)}.ddoc .link:hover{--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}.ddoc .anchor{float:left;--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity));margin-left:-24px;padding:.25rem;line-height:1;display:none;top:0;bottom:0}.ddoc .anchorable{scroll-margin-top:4rem;position:relative}.ddoc .anchorable:hover .anchor{display:block}.ddoc .deprecated>div:first-child{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity));align-items:center;gap:.25rem;padding-top:.25rem;padding-bottom:.25rem;display:flex}.ddoc .deprecated>div:first-child>span{font-weight:600;line-height:1.5rem}.ddoc .deprecated>div:nth-child(2){--tw-border-opacity:1;border-left-width:4px;border-color:rgb(252 165 165/var(--tw-border-opacity));margin-left:.25rem;padding-left:.5rem}.ddoc .symbolSubtitle>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.125rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem*var(--tw-space-y-reverse))}.ddoc .symbolSubtitle{font-size:.875rem;line-height:1rem}.ddoc .symbolSubtitle .type{--tw-text-opacity:1;color:rgb(168 162 158/var(--tw-text-opacity));font-style:italic}.ddoc .docEntry{margin-bottom:1rem}.ddoc .docEntry>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .docEntry .docEntryHeader{justify-content:space-between;align-items:flex-start;display:flex}@media (min-width:768px){.ddoc .docEntry .docEntryHeader{font-size:1rem;line-height:1.5rem}}.ddoc .docEntry .docEntryHeader>div{overflow-wrap:break-word}.ddoc .section{margin-bottom:.5rem;scroll-margin-top:4rem}.ddoc .section>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .section>div:first-child>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.ddoc .section>div:first-child>h2{padding-top:.25rem;padding-bottom:.25rem;font-size:1.25rem;font-weight:600;line-height:1.5rem}.ddoc .section>div:first-child>.markdown_summary{max-width:75ch;font-size:1rem;line-height:1.5rem}.ddoc .namespaceSection{-moz-column-gap:2.5rem;grid-template-columns:repeat(1,minmax(0,1fr));gap:1.5rem 2.5rem;display:grid}@media (min-width:768px){.ddoc .namespaceSection{-moz-column-gap:2rem;grid-template-columns:repeat(2,minmax(0,1fr));gap:2rem}}@media (min-width:1024px){.ddoc .namespaceSection{grid-template-columns:repeat(3,minmax(0,1fr))}}.ddoc .namespaceSection .namespaceItem{-moz-column-gap:.625rem;column-gap:.625rem;display:flex}@media (min-width:768px){.ddoc .namespaceSection .namespaceItem{min-height:4rem}}@media (min-width:1024px){.ddoc .namespaceSection .namespaceItem{padding-right:1rem}}.ddoc .namespaceSection .namespaceItem .docNodeKindIcon{flex-direction:column;justify-content:flex-start;width:auto}.ddoc .namespaceSection .namespaceItem .docNodeKindIcon>*+*{margin-top:-.125rem;margin-left:0}.ddoc .namespaceSection .namespaceItem[aria-label=deprecated]{opacity:.6}.ddoc .namespaceSection .namespaceItem[aria-label=deprecated] .namespaceItemContent>a{--tw-text-opacity:1;color:rgb(120 113 108/var(--tw-text-opacity));text-decoration-line:line-through;text-decoration-color:#78716cb3;text-decoration-thickness:2px}.ddoc .namespaceSection .namespaceItem .namespaceItemContent>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.ddoc .namespaceSection .namespaceItem .namespaceItemContent>a{word-break:break-all;font-weight:500;line-height:1.25;display:block}.ddoc .namespaceSection .namespaceItem .namespaceItemContent>div{--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity));font-size:.875rem;line-height:1.25rem}.ddoc .symbolGroup>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(3rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(3rem*var(--tw-space-y-reverse))}.ddoc .symbolGroup article>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.25rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem*var(--tw-space-y-reverse))}.ddoc .symbolGroup article>div:first-child{justify-content:space-between;align-items:flex-start;display:flex}.ddoc .symbolGroup article>div:first-child>div:first-child>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.ddoc .symbolGroup article>div:first-child>div:first-child{font-weight:500}.ddoc .docNodeKindIcon{flex-shrink:0;justify-content:flex-end;display:inline-flex}.ddoc .docNodeKindIcon div{-webkit-user-select:none;user-select:none;text-align:center;vertical-align:middle;border-radius:9999px;flex-shrink:0;width:1.25rem;height:1.25rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.75rem;font-weight:500;line-height:1.25rem}.ddoc .docNodeKindIcon>*+*{margin-left:-.375rem}.ddoc .example details summary{cursor:pointer;border-radius:.5rem;align-items:center;gap:.5rem;width:100%;padding-top:.5rem;padding-bottom:.5rem;line-height:1.5rem;list-style-type:none;display:flex}.ddoc .example details summary>div:first-child{-webkit-user-select:none;user-select:none;--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity))}.ddoc .example details[open] summary>div:first-child{--tw-rotate:90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y))rotate(var(--tw-rotate))skewX(var(--tw-skew-x))skewY(var(--tw-skew-y))scaleX(var(--tw-scale-x))scaleY(var(--tw-scale-y))}.ddoc .toc h3{margin-bottom:.75rem;font-size:1.125rem;font-weight:700;line-height:1.75rem}.ddoc .toc>div>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.25rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem*var(--tw-space-y-reverse))}.ddoc .toc .topSymbols>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.ddoc .toc .topSymbols{font-size:.875rem;line-height:1.25rem}.ddoc .toc .topSymbols ul{list-style-type:none}.ddoc .toc .topSymbols ul>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.625rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.625rem*var(--tw-space-y-reverse))}.ddoc .toc .topSymbols ul li{display:block}.ddoc .toc .topSymbols ul li a{align-items:center;gap:.5rem;display:flex}.ddoc .toc .topSymbols ul li a>span{text-overflow:ellipsis;white-space:nowrap;border-radius:.25rem;width:100%;margin-top:-.125rem;margin-bottom:-.125rem;margin-left:-.25rem;padding-top:.125rem;padding-bottom:.125rem;padding-left:.25rem;display:block;overflow:hidden}.ddoc .toc .topSymbols>a:hover{text-decoration-line:underline}.ddoc .toc .documentNavigation>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.ddoc .toc .documentNavigation{font-size:.875rem;line-height:1.25rem}@media not all and (min-width:640px){.ddoc .toc .documentNavigation{display:none}}.ddoc .toc .documentNavigation>ul{flex-grow:1;display:block}.ddoc .toc .documentNavigation>ul>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .toc .documentNavigation>ul{overflow-y:auto}.ddoc .toc .documentNavigation>ul>li{margin-top:.125rem;margin-left:.75rem;margin-right:.75rem}.ddoc .toc .documentNavigation>ul li:has(>ul){margin-top:0!important}.ddoc .toc .documentNavigation>ul li:has(>a){padding-bottom:0!important}.ddoc .toc .documentNavigation>ul ul{margin-left:.875rem}.ddoc .toc .documentNavigation>ul ul>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .toc .documentNavigation>ul ul{--tw-text-opacity:1;color:rgb(134 135 137/var(--tw-text-opacity));font-size:.8rem;line-height:1}.ddoc .toc .documentNavigation>ul ul li{margin-top:.25rem!important}.ddoc .toc .documentNavigation>ul ul li a{padding:.25rem}.ddoc .toc .documentNavigation>ul ul li a:hover{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.ddoc .toc .documentNavigation a{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.ddoc .toc .documentNavigation a:hover{text-decoration-line:underline}.ddoc .usages nav{flex-direction:row;align-items:center;gap:.5rem;margin-bottom:.75rem;font-weight:600;display:flex}.ddoc .usages nav details>summary{cursor:pointer;-webkit-user-select:none;user-select:none;--tw-border-opacity:1;border-width:1px;border-color:rgb(209 213 219/var(--tw-border-opacity));border-radius:.25rem;gap:.25rem;padding:.5rem .75rem;display:flex}@media (min-width:768px){.ddoc .usages nav details>div{position:relative}}.ddoc .usages nav details>div>div{z-index:30;--tw-border-opacity:1;border-width:1px;border-color:rgb(209 213 219/var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));margin-top:.375rem;padding:.5rem;display:block;position:absolute}@media not all and (min-width:768px){.ddoc .usages nav details>div>div{border-left-width:0;border-right-width:0;left:0;right:0}}@media (min-width:768px){.ddoc .usages nav details>div>div{border-radius:.25rem;width:12rem}}.ddoc .usages nav details>div>div label{cursor:pointer;-webkit-user-select:none;user-select:none;border-radius:.125rem;align-items:center;gap:.5rem;padding:.25rem .5rem;line-height:1.5;display:flex}.ddoc .usages nav details>div>div label:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.ddoc .usageContent :not(.markdown) h3{margin-bottom:.75rem;font-size:1.125rem;font-weight:700;line-height:1.75rem}.ddoc .usageContent .markdown{--tw-text-opacity:1;color:rgb(104 104 104/var(--tw-text-opacity));font-size:.75rem;line-height:1rem}.ddoc .usageContent .markdown p{margin:0}.ddoc .usageContent pre.highlight{--tw-border-opacity:1;border-width:1px;border-color:rgb(209 213 219/var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}@media not all and (min-width:768px){.ddoc .usageContent pre.highlight{border-left-width:0;border-right-width:0}}.ddoc .usageContent pre.highlight{margin-top:.25rem!important}.ddoc .usageContent pre.highlight>code:first-child{scrollbar-width:thin;padding:.5rem .75rem}.ddoc .usageContent pre.highlight .context_button{border-width:0;display:none;top:.25rem;right:.5rem}.ddoc .usageContent pre.highlight .context_button svg rect{fill:#fff}.ddoc .usageContent pre.highlight:hover .context_button{opacity:1;display:block}.ddoc #categoryPanel{padding-top:.75rem}.ddoc #categoryPanel ul>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.ddoc #categoryPanel a{text-overflow:ellipsis;white-space:nowrap;padding:.375rem .875rem;display:block;overflow:hidden}.ddoc #categoryPanel a:hover{text-decoration-line:underline}.ddoc .contextLink{color:#0e6590cc;text-underline-offset:.15em;text-decoration-line:underline;text-decoration-color:#0e659080;text-decoration-thickness:1.5px}.ddoc .contextLink:hover{--tw-text-opacity:1;color:rgb(14 101 144/var(--tw-text-opacity));text-decoration-color:#0e6590}.ddoc .contextLink{-webkit-text-decoration-skip:ink;-webkit-text-decoration-skip-ink:auto;text-decoration-skip-ink:auto}.ddoc .breadcrumbs{word-break:break-all;flex-wrap:wrap;align-items:center;gap:.25rem;display:inline-flex}.ddoc .breadcrumbs>li:first-child{font-size:1.5rem;font-weight:700;line-height:1}.ddoc .breadcrumbs li{font-size:1.125rem;line-height:.9em;display:inline}@media (min-width:1024px){.ddoc .breadcrumbs li{font-size:1.25rem;line-height:1.75rem}}.ddoc .context_button{z-index:10;cursor:pointer;background-color:inherit;border-width:1px;border-radius:.25rem;padding:.375rem;line-height:0}.ddoc .context_button:hover{--tw-bg-opacity:1;background-color:rgb(231 229 228/var(--tw-bg-opacity))}.ddoc .markdown_border{border-color:#d6d3d166;border-left-width:2px;margin-left:.25rem;padding-left:.625rem}.ddoc .markdown_summary{--tw-text-opacity:1;color:rgb(87 83 78/var(--tw-text-opacity));display:inline}.ddoc .markdown_summary p{-webkit-line-clamp:4;-webkit-box-orient:vertical;display:inline-block;overflow:hidden}.ddoc .markdown_summary :not(pre)>code{--tw-bg-opacity:1;background-color:rgb(231 229 228/var(--tw-bg-opacity));border-radius:.25rem;padding:.125rem .375rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875rem;line-height:1.25rem}.ddoc .markdown{flex-shrink:1;min-width:0;max-width:40ch}.ddoc .markdown>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}@media (min-width:640px){.ddoc .markdown{max-width:640px}}@media (min-width:768px){.ddoc .markdown{max-width:768px}}@media (min-width:1024px){.ddoc .markdown{max-width:75ch}}.ddoc .markdown a:not(.no_color){--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity));transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter,backdrop-filter,-webkit-backdrop-filter;transition-duration:75ms;transition-timing-function:cubic-bezier(.4,0,.2,1)}.ddoc .markdown a:not(.no_color):hover{--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}.ddoc .markdown h1{--tw-border-opacity:1;border-bottom-width:1px;border-color:rgb(214 211 209/var(--tw-border-opacity));padding-bottom:.25rem;font-size:1.25rem;line-height:1.75rem}@media (min-width:768px){.ddoc .markdown h1{font-size:1.5rem;line-height:2rem}}@media (min-width:1024px){.ddoc .markdown h1{font-size:1.875rem;line-height:2.25rem}}.ddoc .markdown h2{--tw-border-opacity:1;border-bottom-width:1px;border-color:rgb(214 211 209/var(--tw-border-opacity));padding-bottom:.25rem;font-size:1.125rem;line-height:1.75rem}@media (min-width:768px){.ddoc .markdown h2{font-size:1.25rem;line-height:1.75rem}}@media (min-width:1024px){.ddoc .markdown h2{font-size:1.5rem;line-height:2rem}}.ddoc .markdown h3{font-weight:700}@media (min-width:768px){.ddoc .markdown h3{font-size:1.125rem;font-weight:400;line-height:1.75rem}}@media (min-width:1024px){.ddoc .markdown h3{font-size:1.25rem;font-weight:400;line-height:1.75rem}}.ddoc .markdown h4{font-weight:600}@media (min-width:768px){.ddoc .markdown h4{font-weight:700}}@media (min-width:1024px){.ddoc .markdown h4{font-size:1.125rem;font-weight:400;line-height:1.75rem}}.ddoc .markdown h5{font-style:italic}@media (min-width:768px){.ddoc .markdown h5{font-weight:600}}@media (min-width:1024px){.ddoc .markdown h5{font-weight:700}}@media (min-width:768px){.ddoc .markdown h6{font-style:italic}}@media (min-width:1024px){.ddoc .markdown h6{font-weight:600}}.ddoc .markdown hr{--tw-border-opacity:1;border-color:rgb(120 113 108/var(--tw-border-opacity));margin:.5rem}.ddoc .markdown ol,.ddoc .markdown ul{margin-left:1rem;list-style-position:outside}.ddoc .markdown ol{list-style-type:decimal}.ddoc .markdown ul{list-style-type:disc}.ddoc .markdown :not(pre)>code{--tw-bg-opacity:1;background-color:rgb(231 229 228/var(--tw-bg-opacity));border-radius:.375rem;padding:.125rem .375rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875rem;line-height:1.25rem}:is(.ddoc .markdown h1,.ddoc .markdown h2,.ddoc .markdown h3,.ddoc .markdown h4,.ddoc .markdown h5,.ddoc .markdown h6)>code{font-size:inherit!important}.ddoc .markdown pre{--tw-border-opacity:1;border-top-width:1.5px;border-bottom-width:1.5px;border-color:rgb(203 213 225/var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity));border-radius:0;margin-left:-1rem;margin-right:-1rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875rem;line-height:1.25rem}@media (min-width:768px){.ddoc .markdown pre{border-width:1.5px;border-radius:.375rem;margin-left:0;margin-right:0}}.ddoc .markdown pre>code:first-child{padding:1rem 1.5rem;display:block;overflow-x:auto}.ddoc .markdown p{margin:.25rem 0}.ddoc .markdown table{table-layout:auto;width:max-content;max-width:100%;display:block;overflow:auto}.ddoc .markdown td{padding:.5rem}.ddoc .markdown th{text-align:center;padding-top:.375rem;padding-bottom:.375rem;font-weight:700}.ddoc .markdown th,.ddoc .markdown td{--tw-border-opacity:1;border-width:1.5px;border-color:rgb(203 213 225/var(--tw-border-opacity))}.ddoc .markdown tr:nth-child(2n){--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}.ddoc .markdown img{display:inline-block}.ddoc .markdown .alert>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.ddoc .markdown .alert{border-left-width:4px;padding:.5rem 1rem}.ddoc .markdown .alert div:first-child{align-items:center;gap:.375rem;font-weight:500;display:flex}.ddoc .markdown .alert div:first-child svg{width:1.25rem;height:1.25rem}.ddoc .markdown .alert-note{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity))}.ddoc .markdown .alert-note div:first-child{stroke:#2563eb;--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity))}.ddoc .markdown .alert-tip{--tw-border-opacity:1;border-color:rgb(22 163 74/var(--tw-border-opacity))}.ddoc .markdown .alert-tip div:first-child{stroke:#16a34a;--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity))}.ddoc .markdown .alert-important{--tw-border-opacity:1;border-color:rgb(147 51 234/var(--tw-border-opacity))}.ddoc .markdown .alert-important div:first-child{stroke:#9333ea;--tw-text-opacity:1;color:rgb(147 51 234/var(--tw-text-opacity))}.ddoc .markdown .alert-warning{--tw-border-opacity:1;border-color:rgb(202 138 4/var(--tw-border-opacity))}.ddoc .markdown .alert-warning div:first-child{stroke:#ca8a04;--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity))}.ddoc .markdown .alert-caution{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity))}.ddoc .markdown .alert-caution div:first-child{stroke:#dc2626;--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.ddoc .markdown .highlight{position:relative}.ddoc .markdown .highlight .lineNumbers{--tw-border-opacity:1;border-right-width:2px;border-color:rgb(214 211 209/var(--tw-border-opacity));text-align:right;flex:none;padding-right:.25rem}.ddoc .markdown .highlight .context_button{opacity:.6;position:absolute;top:.75rem;right:1rem}.ddoc .markdown .highlight .context_button:hover{opacity:1}.ddoc .markdown .highlight .pl-c{color:#6a737d}.ddoc .markdown .highlight .pl-c1,.ddoc .markdown .highlight .pl-s .pl-v{color:#005cc5}.ddoc .markdown .highlight .pl-e,.ddoc .markdown .highlight .pl-en{color:#6f42c1}.ddoc .markdown .highlight .pl-smi,.ddoc .markdown .highlight .pl-s .pl-s1{color:#24292e}.ddoc .markdown .highlight .pl-ent{color:#22863a}.ddoc .markdown .highlight .pl-k{color:#d73a49}.ddoc .markdown .highlight .pl-s,.ddoc .markdown .highlight .pl-pds,.ddoc .markdown .highlight .pl-s .pl-pse .pl-s1,.ddoc .markdown .highlight .pl-sr,.ddoc .markdown .highlight .pl-sr .pl-cce,.ddoc .markdown .highlight .pl-sr .pl-sre,.ddoc .markdown .highlight .pl-sr .pl-sra{color:#032f62}.ddoc .markdown .highlight .pl-v,.ddoc .markdown .highlight .pl-smw{color:#e36209}.ddoc .markdown .highlight .pl-bu{color:#b31d28}.ddoc .markdown .highlight .pl-ii{color:#fafbfc;background-color:#b31d28}.ddoc .markdown .highlight .pl-c2{color:#fafbfc;background-color:#d73a49}.ddoc .markdown .highlight .pl-c2:before{content:"^M"}.ddoc .markdown .highlight .pl-sr .pl-cce{color:#22863a;font-weight:700}.ddoc .markdown .highlight .pl-ml{color:#735c0f}.ddoc .markdown .highlight .pl-mh,.ddoc .markdown .highlight .pl-mh .pl-en,.ddoc .markdown .highlight .pl-ms{color:#005cc5;font-weight:700}.ddoc .markdown .highlight .pl-mi{color:#24292e;font-style:italic}.ddoc .markdown .highlight .pl-mb{color:#24292e;font-weight:700}.ddoc .markdown .highlight .pl-md{color:#b31d28;background-color:#ffeef0}.ddoc .markdown .highlight .pl-mi1{color:#22863a;background-color:#f0fff4}.ddoc .markdown .highlight .pl-mc{color:#e36209;background-color:#ffebda}.ddoc .markdown .highlight .pl-mi2{color:#f6f8fa;background-color:#005cc5}.ddoc .\*\:h-4>*{height:1rem}.ddoc .\*\:h-5>*{height:1.25rem}.ddoc .\*\:w-auto>*{width:auto}.ddoc .\*\:flex-none>*{flex:none}.ddoc .target\:bg-yellow-200:target{--tw-bg-opacity:1;background-color:rgb(254 240 138/var(--tw-bg-opacity))}.ddoc .hover\:bg-Class\/15:hover{background-color:#20b44b26}.ddoc .hover\:bg-Class\/5:hover{background-color:#20b44b0d}.ddoc .hover\:bg-Enum\/15:hover{background-color:#22abb026}.ddoc .hover\:bg-Enum\/5:hover{background-color:#22abb00d}.ddoc .hover\:bg-Function\/15:hover{background-color:#056cf026}.ddoc .hover\:bg-Function\/5:hover{background-color:#056cf00d}.ddoc .hover\:bg-Interface\/15:hover{background-color:#d2a06426}.ddoc .hover\:bg-Interface\/5:hover{background-color:#d2a0640d}.ddoc .hover\:bg-Method\/15:hover{background-color:#056cf026}.ddoc .hover\:bg-Method\/5:hover{background-color:#056cf00d}.ddoc .hover\:bg-Namespace\/15:hover{background-color:#d2564626}.ddoc .hover\:bg-Namespace\/5:hover{background-color:#d256460d}.ddoc .hover\:bg-Property\/15:hover{background-color:#7e57c026}.ddoc .hover\:bg-Property\/5:hover{background-color:#7e57c00d}.ddoc .hover\:bg-TypeAlias\/15:hover{background-color:#a4478c26}.ddoc .hover\:bg-TypeAlias\/5:hover{background-color:#a4478c0d}.ddoc .hover\:bg-Variable\/15:hover{background-color:#7e57c026}.ddoc .hover\:bg-Variable\/5:hover{background-color:#7e57c00d}.ddoc .hover\:bg-abstract\/15:hover{background-color:#0cafc626}.ddoc .hover\:bg-abstract\/5:hover{background-color:#0cafc60d}.ddoc .hover\:bg-deprecated\/15:hover{background-color:#dc262626}.ddoc .hover\:bg-deprecated\/5:hover{background-color:#dc26260d}.ddoc .hover\:bg-new\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-new\/5:hover{background-color:#7b61ff0d}.ddoc .hover\:bg-optional\/15:hover{background-color:#0cafc626}.ddoc .hover\:bg-optional\/5:hover{background-color:#0cafc60d}.ddoc .hover\:bg-other\/15:hover{background-color:#57534e26}.ddoc .hover\:bg-other\/5:hover{background-color:#57534e0d}.ddoc .hover\:bg-permissions\/15:hover{background-color:#0cafc626}.ddoc .hover\:bg-permissions\/5:hover{background-color:#0cafc60d}.ddoc .hover\:bg-private\/15:hover{background-color:#0cafc626}.ddoc .hover\:bg-private\/5:hover{background-color:#0cafc60d}.ddoc .hover\:bg-protected\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-protected\/5:hover{background-color:#7b61ff0d}.ddoc .hover\:bg-readonly\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-readonly\/5:hover{background-color:#7b61ff0d}.ddoc .hover\:bg-unstable\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-unstable\/5:hover{background-color:#7b61ff0d}.ddoc .hover\:bg-writeonly\/15:hover{background-color:#7b61ff26}.ddoc .hover\:bg-writeonly\/5:hover{background-color:#7b61ff0d} \ No newline at end of file diff --git a/src/html/types.rs b/src/html/types.rs index 6f0009fb..dd3c6dd2 100644 --- a/src/html/types.rs +++ b/src/html/types.rs @@ -559,7 +559,7 @@ pub(crate) fn render_type_params( .iter() .filter_map(|tag| { if let JsDocTag::Template { name, doc } = tag { - doc.as_ref().map(|doc| (name.as_str(), doc.as_str())) + doc.as_ref().map(|doc| (&**name, &**doc)) } else { None } diff --git a/src/html/usage.rs b/src/html/usage.rs index 9b59fcab..919a6d3f 100644 --- a/src/html/usage.rs +++ b/src/html/usage.rs @@ -28,21 +28,21 @@ pub fn usage_to_md( ) -> String { let usage = if let UrlResolveKind::Symbol { symbol, .. } = ctx.get_current_resolve() { - let mut parts = symbol.split('.').collect::>(); + let mut parts = symbol.split('.'); let top_node = doc_nodes[0].get_topmost_ancestor(); let is_default = top_node.is_default.is_some_and(|is_default| is_default) - || top_node.name == "default"; + || &*top_node.name == "default"; let import_symbol = if is_default { if top_node.is_default.is_some_and(|is_default| is_default) { top_node.name.clone() } else { - "module".to_string() + "module".into() } } else { - parts[0].to_string() + parts.clone().next().unwrap().into() }; let usage_symbol = if doc_nodes @@ -50,26 +50,39 @@ pub fn usage_to_md( .all(|node| node.drilldown_parent_kind.is_some()) { None - } else if parts.len() > 1 { - parts.pop().map(|usage_symbol| { - ( - usage_symbol, - // if it is namespaces within namespaces, we simply re-join them together - // instead of trying to figure out some sort of nested restructuring - if is_default { - import_symbol.clone() - } else { - parts.join(".") - }, - ) - }) } else { - None + let last = parts.next_back(); + if let Some(usage_symbol) = last { + if usage_symbol == symbol { + None + } else { + Some(( + usage_symbol, + // if it is namespaces within namespaces, we simply re-join them together + // instead of trying to figure out some sort of nested restructuring + if is_default { + import_symbol.clone() + } else { + let capacity = symbol.len() - usage_symbol.len() - 1; + let mut joined = String::with_capacity(capacity); + for part in parts { + if !joined.is_empty() { + joined.push('.'); + } + joined.push_str(part); + } + joined.into_boxed_str() + }, + )) + } + } else { + None + } }; let is_type = doc_nodes.iter().all(|doc_node| { matches!( - doc_node.drilldown_parent_kind.unwrap_or(doc_node.kind), + doc_node.drilldown_parent_kind.unwrap_or(doc_node.kind()), DocNodeKind::TypeAlias | DocNodeKind::Interface ) }); diff --git a/src/html/util.rs b/src/html/util.rs index 4ddf432c..24431fcb 100644 --- a/src/html/util.rs +++ b/src/html/util.rs @@ -53,24 +53,24 @@ impl NamespacedSymbols { pub fn compute_namespaced_symbols( doc_nodes: &[DocNodeWithContext], ) -> HashSet> { - let mut namespaced_symbols = HashSet::new(); + let mut namespaced_symbols = HashSet::>::new(); for doc_node in doc_nodes { - if doc_node.kind == DocNodeKind::ModuleDoc - || doc_node.kind == DocNodeKind::Import + if doc_node.kind() == DocNodeKind::ModuleDoc + || doc_node.kind() == DocNodeKind::Import { continue; } // TODO: handle export aliasing - let name_path = Rc::new(doc_node.sub_qualifier()); + let name_path: Rc<[String]> = doc_node.sub_qualifier().into(); - match doc_node.kind { + match doc_node.kind() { DocNodeKind::Class => { - let class_def = doc_node.class_def.as_ref().unwrap(); + let class_def = doc_node.class_def().unwrap(); namespaced_symbols.extend(class_def.methods.iter().map(|method| { - let mut method_path = (*doc_node.ns_qualifiers).clone(); + let mut method_path = doc_node.ns_qualifiers.to_vec(); method_path.extend( qualify_drilldown_name( doc_node.get_name(), @@ -85,7 +85,7 @@ pub fn compute_namespaced_symbols( namespaced_symbols.extend(class_def.properties.iter().map( |property| { - let mut method_path = (*doc_node.ns_qualifiers).clone(); + let mut method_path = doc_node.ns_qualifiers.to_vec(); method_path.extend( qualify_drilldown_name( doc_node.get_name(), @@ -100,10 +100,10 @@ pub fn compute_namespaced_symbols( )); } DocNodeKind::Interface => { - let interface_def = doc_node.interface_def.as_ref().unwrap(); + let interface_def = doc_node.interface_def().unwrap(); namespaced_symbols.extend(interface_def.methods.iter().map(|method| { - let mut method_path = (*doc_node.ns_qualifiers).clone(); + let mut method_path = doc_node.ns_qualifiers.to_vec(); method_path.extend( qualify_drilldown_name(doc_node.get_name(), &method.name, true) .split('.') @@ -114,7 +114,7 @@ pub fn compute_namespaced_symbols( namespaced_symbols.extend(interface_def.properties.iter().map( |property| { - let mut method_path = (*doc_node.ns_qualifiers).clone(); + let mut method_path = doc_node.ns_qualifiers.to_vec(); method_path.extend( qualify_drilldown_name(doc_node.get_name(), &property.name, true) .split('.') @@ -125,13 +125,13 @@ pub fn compute_namespaced_symbols( )); } DocNodeKind::TypeAlias => { - let type_alias_def = doc_node.type_alias_def.as_ref().unwrap(); + let type_alias_def = doc_node.type_alias_def().unwrap(); if let Some(type_literal) = type_alias_def.ts_type.type_literal.as_ref() { namespaced_symbols.extend(type_literal.methods.iter().map( |method| { - let mut method_path = (*doc_node.ns_qualifiers).clone(); + let mut method_path = doc_node.ns_qualifiers.to_vec(); method_path.extend( qualify_drilldown_name(doc_node.get_name(), &method.name, true) .split('.') @@ -143,7 +143,7 @@ pub fn compute_namespaced_symbols( namespaced_symbols.extend(type_literal.properties.iter().map( |property| { - let mut method_path = (*doc_node.ns_qualifiers).clone(); + let mut method_path = doc_node.ns_qualifiers.to_vec(); method_path.extend( qualify_drilldown_name( doc_node.get_name(), @@ -159,7 +159,7 @@ pub fn compute_namespaced_symbols( } } DocNodeKind::Variable => { - let variable = doc_node.variable_def.as_ref().unwrap(); + let variable = doc_node.variable_def().unwrap(); if let Some(type_literal) = variable .ts_type @@ -168,7 +168,7 @@ pub fn compute_namespaced_symbols( { namespaced_symbols.extend(type_literal.methods.iter().map( |method| { - let mut method_path = (*doc_node.ns_qualifiers).clone(); + let mut method_path = doc_node.ns_qualifiers.to_vec(); method_path.extend( qualify_drilldown_name(doc_node.get_name(), &method.name, true) .split('.') @@ -180,7 +180,7 @@ pub fn compute_namespaced_symbols( namespaced_symbols.extend(type_literal.properties.iter().map( |property| { - let mut method_path = (*doc_node.ns_qualifiers).clone(); + let mut method_path = doc_node.ns_qualifiers.to_vec(); method_path.extend( qualify_drilldown_name( doc_node.get_name(), @@ -198,10 +198,10 @@ pub fn compute_namespaced_symbols( _ => {} } - namespaced_symbols.insert((*name_path).clone()); + namespaced_symbols.insert(name_path.to_vec()); - if doc_node.kind == DocNodeKind::Namespace { - let namespace_def = doc_node.namespace_def.as_ref().unwrap(); + if doc_node.kind() == DocNodeKind::Namespace { + let namespace_def = doc_node.namespace_def().unwrap(); namespaced_symbols.extend(compute_namespaced_symbols( &namespace_def .elements @@ -425,7 +425,7 @@ impl SectionHeaderCtx { let doc = module_doc_nodes .iter() - .find(|n| n.kind == DocNodeKind::ModuleDoc) + .find(|n| n.kind() == DocNodeKind::ModuleDoc) .and_then(|node| node.js_doc.doc.as_ref()) .and_then(|doc| { markdown_to_html( @@ -467,11 +467,8 @@ impl SectionCtx { title: &str, mut content: SectionContentCtx, ) -> Self { - let anchor = render_context.toc.add_entry( - 1, - title.to_owned(), - render_context.toc.anchorize(title.to_owned()), - ); + let anchor = render_context.toc.anchorize(title); + render_context.toc.add_entry(1, title, &anchor); match &mut content { SectionContentCtx::DocEntry(entries) => { @@ -480,37 +477,37 @@ impl SectionCtx { continue; }; - let anchor = render_context.toc.anchorize(entry.id.to_owned()); + let anchor = render_context.toc.anchorize(&entry.id); - entry.id = anchor.clone(); - entry.anchor.id = anchor.clone(); + render_context.toc.add_entry(2, name, &anchor); - render_context.toc.add_entry(2, name.clone(), anchor); + entry.id = anchor.clone(); + entry.anchor.id = anchor; } } SectionContentCtx::Example(examples) => { for example in examples { - let anchor = render_context.toc.anchorize(example.id.to_owned()); - - example.id = anchor.clone(); - example.anchor.id = anchor.clone(); + let anchor = render_context.toc.anchorize(&example.id); render_context.toc.add_entry( 2, - super::jsdoc::strip(render_context, &example.title), - anchor, + &super::jsdoc::strip(render_context, &example.title), + &anchor, ); + + example.id = anchor.clone(); + example.anchor.id = anchor; } } SectionContentCtx::IndexSignature(_) => {} SectionContentCtx::NamespaceSection(nodes) => { for node in nodes { - let anchor = render_context.toc.anchorize(node.id.to_owned()); + let anchor = render_context.toc.anchorize(&node.id); - node.id = anchor.clone(); - node.anchor.id = anchor.clone(); + render_context.toc.add_entry(2, &node.name, &anchor); - render_context.toc.add_entry(2, node.name.clone(), anchor); + node.id = anchor.clone(); + node.anchor.id = anchor; } } SectionContentCtx::Empty => {} @@ -540,8 +537,8 @@ pub enum Tag { Private, Optional, Unstable, - Permissions(Vec), - Other(String), + Permissions(Box<[Box]>), + Other(Box), } impl Tag { diff --git a/src/interface.rs b/src/interface.rs index e8062050..53338483 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -30,7 +30,7 @@ pub struct InterfaceDef { pub properties: Vec, pub call_signatures: Vec, pub index_signatures: Vec, - pub type_params: Vec, + pub type_params: Box<[TsTypeParamDef]>, } pub fn expr_to_name(expr: &deno_ast::swc::ast::Expr) -> String { @@ -148,7 +148,7 @@ pub fn get_doc_for_ts_interface_decl( optional: false, params: vec![], return_type: maybe_return_type, - type_params: vec![], + type_params: Box::new([]), }; methods.push(method_def); } @@ -172,7 +172,7 @@ pub fn get_doc_for_ts_interface_decl( optional: false, params, return_type: None, - type_params: vec![], + type_params: Box::new([]), }; methods.push(method_def); } diff --git a/src/js_doc.rs b/src/js_doc.rs index 5ce816b1..8201dc5b 100644 --- a/src/js_doc.rs +++ b/src/js_doc.rs @@ -22,9 +22,9 @@ lazy_static! { #[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq)] pub struct JsDoc { #[serde(skip_serializing_if = "Option::is_none", default)] - pub doc: Option, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub tags: Vec, + pub doc: Option>, + #[serde(skip_serializing_if = "<[_]>::is_empty", default)] + pub tags: Box<[JsDocTag]>, } impl JsDoc { @@ -36,43 +36,55 @@ impl JsDoc { impl From for JsDoc { fn from(value: String) -> Self { let mut tags = Vec::new(); - let mut doc_lines = Vec::new(); + let mut doc_lines: Option = None; let mut is_tag = false; - let mut current_tag: Vec<&str> = Vec::new(); + let mut current_tag: Option = None; let mut current_tag_name = ""; for line in value.lines() { let caps = JS_DOC_TAG_RE.captures(line); if is_tag || caps.is_some() { if !is_tag { is_tag = true; - assert!(current_tag.is_empty()); + assert!(current_tag.is_none()); } - if caps.is_some() && !current_tag.is_empty() { - tags.push(current_tag.join("\n").into()); - current_tag.clear(); + if caps.is_some() { + let current_tag = std::mem::take(&mut current_tag); + if let Some(current_tag) = current_tag { + tags.push(current_tag.into()); + } } if let Some(caps) = caps { current_tag_name = caps.get(1).unwrap().as_str(); } + let current_tag = if let Some(current_tag) = &mut current_tag { + current_tag.push('\n'); + current_tag + } else { + current_tag = Some(String::new()); + current_tag.as_mut().unwrap() + }; // certain tags, we want to preserve any leading whitespace if matches!(current_tag_name, "example") { - current_tag.push(line.trim_end()); + current_tag.push_str(line.trim_end()); } else { - current_tag.push(line.trim()); + current_tag.push_str(line.trim()); } + } else if let Some(doc_lines) = &mut doc_lines { + doc_lines.push('\n'); + doc_lines.push_str(line); } else { - doc_lines.push(line); + doc_lines = Some(String::new()); + doc_lines.as_mut().unwrap().push_str(line); } } - if !current_tag.is_empty() { - tags.push(current_tag.join("\n").into()); + if let Some(current_tag) = current_tag { + tags.push(current_tag.into()); + } + let doc = doc_lines.map(|doc_lines| doc_lines.into_boxed_str()); + Self { + doc, + tags: tags.into_boxed_slice(), } - let doc = if doc_lines.is_empty() { - None - } else { - Some(doc_lines.join("\n")) - }; - Self { doc, tags } } } @@ -81,48 +93,48 @@ impl From for JsDoc { pub enum JsDocTag { /// `@callback Predicate comment` Callback { - name: String, + name: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@category comment` Category { #[serde(default)] - doc: String, + doc: Box, }, /// `@constructor` or `@class` Constructor, /// `@default {value} comment` Default { - value: String, + value: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@deprecated comment` Deprecated { #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@enum {type} comment` Enum { #[serde(rename = "type")] - type_ref: String, + type_ref: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@example comment` Example { #[serde(default)] - doc: String, + doc: Box, }, /// `@experimental` Experimental, /// `@extends {type} comment` Extends { #[serde(rename = "type")] - type_ref: String, + type_ref: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@ignore` Ignore, @@ -134,15 +146,15 @@ pub enum JsDocTag { /// or `@param {type} [name=default] comment` /// or `@param {type} [name] comment` Param { - name: String, + name: Box, #[serde(rename = "type", skip_serializing_if = "Option::is_none", default)] - type_ref: Option, + type_ref: Option>, #[serde(skip_serializing_if = "core::ops::Not::not", default)] optional: bool, #[serde(skip_serializing_if = "Option::is_none", default)] - default: Option, + default: Option>, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@public` Public, @@ -150,11 +162,11 @@ pub enum JsDocTag { Private, /// `@property {type} name comment` or `@prop {type} name comment` Property { - name: String, + name: Box, #[serde(rename = "type", default)] - type_ref: String, + type_ref: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@protected` Protected, @@ -163,62 +175,62 @@ pub enum JsDocTag { /// `@return {type} comment` or `@returns {type} comment` Return { #[serde(rename = "type", skip_serializing_if = "Option::is_none", default)] - type_ref: Option, + type_ref: Option>, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@tags allow-read, allow-write` Tags { - tags: Vec, + tags: Box<[Box]>, }, /// `@template T comment` /// `@typeparam T comment` /// `@typeParam T comment` Template { - name: String, + name: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@this {type} comment` This { #[serde(rename = "type")] - type_ref: String, + type_ref: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@throws {type} comment` or `@exception {type} comment` Throws { #[serde(rename = "type")] - type_ref: Option, + type_ref: Option>, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@typedef {type} name comment` TypeDef { - name: String, + name: Box, #[serde(rename = "type")] - type_ref: String, + type_ref: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@type {type} comment` #[serde(rename = "type")] TypeRef { #[serde(rename = "type")] - type_ref: String, + type_ref: Box, #[serde(skip_serializing_if = "Option::is_none", default)] - doc: Option, + doc: Option>, }, /// `@see comment` See { - doc: String, + doc: Box, }, /// `@since version` Since { - doc: String, + doc: Box, }, Unsupported { - value: String, + value: Box, }, } @@ -240,8 +252,8 @@ impl From for JsDocTag { } } else if let Some(caps) = JS_DOC_TAG_NAMED_RE.captures(&value) { let kind = caps.get(1).unwrap().as_str(); - let name = caps.get(2).unwrap().as_str().to_string(); - let doc = caps.get(3).map(|m| m.as_str().to_string()); + let name = caps.get(2).unwrap().as_str().into(); + let doc = caps.get(3).map(|m| m.as_str().into()); match kind { "callback" => Self::Callback { name, doc }, "template" | "typeparam" | "typeParam" => Self::Template { name, doc }, @@ -249,8 +261,8 @@ impl From for JsDocTag { } } else if let Some(caps) = JS_DOC_TAG_TYPED_RE.captures(&value) { let kind = caps.get(1).unwrap().as_str(); - let type_ref = caps.get(2).unwrap().as_str().to_string(); - let doc = caps.get(3).map(|m| m.as_str().to_string()); + let type_ref = caps.get(2).unwrap().as_str().into(); + let doc = caps.get(3).map(|m| m.as_str().into()); match kind { "enum" => Self::Enum { type_ref, doc }, "extends" | "augments" => Self::Extends { type_ref, doc }, @@ -264,9 +276,9 @@ impl From for JsDocTag { } } else if let Some(caps) = JS_DOC_TAG_NAMED_TYPED_RE.captures(&value) { let kind = caps.get(1).unwrap().as_str(); - let type_ref = caps.get(2).unwrap().as_str().to_string(); - let name = caps.get(3).unwrap().as_str().to_string(); - let doc = caps.get(4).map(|m| m.as_str().to_string()); + let type_ref = caps.get(2).unwrap().as_str().into(); + let name = caps.get(3).unwrap().as_str().into(); + let doc = caps.get(4).map(|m| m.as_str().into()); match kind { "prop" | "property" => Self::Property { name, @@ -282,19 +294,19 @@ impl From for JsDocTag { } } else if let Some(caps) = JS_DOC_TAG_MAYBE_DOC_RE.captures(&value) { let kind = caps.get(1).unwrap().as_str(); - let doc = caps.get(2).map(|m| m.as_str().to_string()); + let doc = caps.get(2).map(|m| m.as_str().into()); match kind { "deprecated" => Self::Deprecated { doc }, _ => unreachable!("kind unexpected: {}", kind), } } else if let Some(caps) = JS_DOC_TAG_DOC_RE.captures(&value) { let kind = caps.get(1).unwrap().as_str(); - let doc = caps.get(2).unwrap().as_str().to_string(); + let doc = caps.get(2).unwrap().as_str().into(); match kind { "category" => Self::Category { doc }, "example" => Self::Example { doc }, "tags" => Self::Tags { - tags: doc.split(',').map(|i| i.trim().to_string()).collect(), + tags: doc.split(',').map(|i| i.trim().into()).collect(), }, "see" => Self::See { doc }, "since" => Self::Since { doc }, @@ -307,10 +319,10 @@ impl From for JsDocTag { .or(name_with_maybe_default) .unwrap() .as_str() - .to_string(); - let type_ref = caps.name("type").map(|m| m.as_str().to_string()); - let default = caps.name("default").map(|m| m.as_str().to_string()); - let doc = caps.name("doc").map(|m| m.as_str().to_string()); + .into(); + let type_ref = caps.name("type").map(|m| m.as_str().into()); + let default = caps.name("default").map(|m| m.as_str().into()); + let doc = caps.name("doc").map(|m| m.as_str().into()); Self::Param { name, type_ref, @@ -322,15 +334,17 @@ impl From for JsDocTag { JS_DOC_TAG_OPTIONAL_TYPE_AND_DOC_RE.captures(&value) { let kind = caps.get(1).unwrap().as_str(); - let type_ref = caps.get(2).map(|m| m.as_str().to_string()); - let doc = caps.get(3).map(|m| m.as_str().to_string()); + let type_ref = caps.get(2).map(|m| m.as_str().into()); + let doc = caps.get(3).map(|m| m.as_str().into()); match kind { "return" | "returns" => Self::Return { type_ref, doc }, "throws" | "exception" => Self::Throws { type_ref, doc }, _ => unreachable!("kind unexpected: {}", kind), } } else { - Self::Unsupported { value } + Self::Unsupported { + value: value.into(), + } } } } @@ -928,7 +942,7 @@ multi-line fn test_js_doc_tag_serialization() { assert_eq!( serde_json::to_value(JsDocTag::Callback { - name: "Predicate".to_string(), + name: "Predicate".into(), doc: None, }) .unwrap(), @@ -945,7 +959,7 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Default { - value: "true".to_string(), + value: "true".into(), doc: None, }) .unwrap(), @@ -956,7 +970,7 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Deprecated { - doc: Some("comment".to_string()), + doc: Some("comment".into()), }) .unwrap(), json!({ @@ -966,7 +980,7 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Enum { - type_ref: "number".to_string(), + type_ref: "number".into(), doc: None, }) .unwrap(), @@ -977,7 +991,7 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Extends { - type_ref: "OtherType".to_string(), + type_ref: "OtherType".into(), doc: None, }) .unwrap(), @@ -988,11 +1002,11 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Param { - name: "arg".to_string(), - type_ref: Some("number".to_string()), + name: "arg".into(), + type_ref: Some("number".into()), optional: false, - default: Some("1".to_string()), - doc: Some("comment".to_string()), + default: Some("1".into()), + doc: Some("comment".into()), }) .unwrap(), json!({ @@ -1005,11 +1019,11 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Param { - name: "arg".to_string(), + name: "arg".into(), type_ref: None, optional: false, default: None, - doc: Some("comment".to_string()), + doc: Some("comment".into()), }) .unwrap(), json!({ @@ -1028,8 +1042,8 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Property { - name: "prop".to_string(), - type_ref: "string".to_string(), + name: "prop".into(), + type_ref: "string".into(), doc: None, }) .unwrap(), @@ -1049,8 +1063,8 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Return { - type_ref: Some("string".to_string()), - doc: Some("comment".to_string()), + type_ref: Some("string".into()), + doc: Some("comment".into()), }) .unwrap(), json!({ @@ -1061,7 +1075,7 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Template { - name: "T".to_string(), + name: "T".into(), doc: None, }) .unwrap(), @@ -1072,7 +1086,7 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::This { - type_ref: "Record".to_string(), + type_ref: "Record".into(), doc: None, }) .unwrap(), @@ -1083,8 +1097,8 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::TypeDef { - name: "Interface".to_string(), - type_ref: "object".to_string(), + name: "Interface".into(), + type_ref: "object".into(), doc: None, }) .unwrap(), @@ -1096,7 +1110,7 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::TypeRef { - type_ref: "Map".to_string(), + type_ref: "Map".into(), doc: None, }) .unwrap(), @@ -1107,7 +1121,7 @@ multi-line ); assert_eq!( serde_json::to_value(JsDocTag::Unsupported { - value: "unsupported".to_string() + value: "unsupported".into() }) .unwrap(), json!({ diff --git a/src/lib.rs b/src/lib.rs index d735fe75..0a3d6559 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,7 +66,7 @@ mod tests; #[cfg(feature = "rust")] pub fn find_nodes_by_name_recursively( doc_nodes: Vec, - name: String, + name: &str, ) -> Vec { let mut parts = name.splitn(2, '.'); let name = parts.next(); @@ -76,17 +76,14 @@ pub fn find_nodes_by_name_recursively( } let name = name.unwrap(); - let doc_nodes = find_nodes_by_name(doc_nodes, name.to_string()); + let doc_nodes = find_nodes_by_name(doc_nodes, name); let mut found: Vec = vec![]; match leftover { Some(leftover) => { for node in doc_nodes { let children = get_children_of_node(node); - found.extend(find_nodes_by_name_recursively( - children, - leftover.to_string(), - )); + found.extend(find_nodes_by_name_recursively(children, leftover)); } found } @@ -95,10 +92,10 @@ pub fn find_nodes_by_name_recursively( } #[cfg(feature = "rust")] -fn find_nodes_by_name(doc_nodes: Vec, name: String) -> Vec { +fn find_nodes_by_name(doc_nodes: Vec, name: &str) -> Vec { let mut found: Vec = vec![]; for node in doc_nodes { - if node.name == name { + if &*node.name == name { found.push(node); } } @@ -107,17 +104,15 @@ fn find_nodes_by_name(doc_nodes: Vec, name: String) -> Vec { #[cfg(feature = "rust")] fn get_children_of_node(node: DocNode) -> Vec { - match node.kind { - DocNodeKind::Namespace => { - let namespace_def = node.namespace_def.unwrap(); - namespace_def - .elements - .into_iter() - .map(std::sync::Arc::unwrap_or_clone) - .collect() - } - DocNodeKind::Interface => { - let interface_def = node.interface_def.unwrap(); + use node::DocNodeDef; + + match node.def { + DocNodeDef::Namespace { namespace_def } => namespace_def + .elements + .into_iter() + .map(std::rc::Rc::unwrap_or_clone) + .collect(), + DocNodeDef::Interface { interface_def } => { let mut doc_nodes: Vec = vec![]; for method in interface_def.methods { doc_nodes.push(method.into()); @@ -127,13 +122,12 @@ fn get_children_of_node(node: DocNode) -> Vec { } doc_nodes } - DocNodeKind::Class => { - let class_def = node.class_def.unwrap(); + DocNodeDef::Class { class_def } => { let mut doc_nodes: Vec = vec![]; - for method in class_def.methods { + for method in class_def.methods.into_vec().into_iter() { doc_nodes.push(method.into()); } - for property in class_def.properties { + for property in class_def.properties.into_vec().into_iter() { doc_nodes.push(property.into()); } doc_nodes diff --git a/src/node.rs b/src/node.rs index be44bb93..4e139064 100644 --- a/src/node.rs +++ b/src/node.rs @@ -2,13 +2,13 @@ use serde::Deserialize; use serde::Serialize; -use std::sync::Arc; +use std::rc::Rc; use crate::js_doc::JsDoc; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct NamespaceDef { - pub elements: Vec>, + pub elements: Vec>, } #[derive( @@ -43,7 +43,7 @@ pub enum DocNodeKind { )] #[serde(rename_all = "camelCase")] pub struct Location { - pub filename: String, + pub filename: Box, /// The 1-indexed display line. /// todo(#150): why is one of these 0-indexed and the other 1-indexed? pub line: usize, @@ -117,57 +117,64 @@ pub enum DeclarationKind { #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct DocNode { - pub kind: DocNodeKind, - pub name: String, + pub name: Box, #[serde(skip_serializing_if = "Option::is_none", default)] pub is_default: Option, pub location: Location, pub declaration_kind: DeclarationKind, #[serde(skip_serializing_if = "JsDoc::is_empty", default)] pub js_doc: JsDoc, + #[serde(flatten)] + pub def: DocNodeDef, +} - #[serde(skip_serializing_if = "Option::is_none", default)] - pub function_def: Option, - - #[serde(skip_serializing_if = "Option::is_none", default)] - pub variable_def: Option, - - #[serde(skip_serializing_if = "Option::is_none", default)] - pub enum_def: Option, - - #[serde(skip_serializing_if = "Option::is_none", default)] - pub class_def: Option, - - #[serde(skip_serializing_if = "Option::is_none", default)] - pub type_alias_def: Option, - - #[serde(skip_serializing_if = "Option::is_none", default)] - pub namespace_def: Option, - - #[serde(skip_serializing_if = "Option::is_none", default)] - pub interface_def: Option, - - #[serde(skip_serializing_if = "Option::is_none", default)] - pub import_def: Option, +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(tag = "kind", rename_all = "camelCase")] +pub enum DocNodeDef { + #[serde(rename_all = "camelCase")] + Function { + function_def: super::function::FunctionDef, + }, + #[serde(rename_all = "camelCase")] + Variable { + variable_def: super::variable::VariableDef, + }, + #[serde(rename_all = "camelCase")] + Enum { + enum_def: super::r#enum::EnumDef, + }, + #[serde(rename_all = "camelCase")] + Class { + class_def: super::class::ClassDef, + }, + #[serde(rename_all = "camelCase")] + TypeAlias { + type_alias_def: super::type_alias::TypeAliasDef, + }, + #[serde(rename_all = "camelCase")] + Namespace { + namespace_def: NamespaceDef, + }, + #[serde(rename_all = "camelCase")] + Interface { + interface_def: super::interface::InterfaceDef, + }, + #[serde(rename_all = "camelCase")] + Import { + import_def: ImportDef, + }, + ModuleDoc, } impl Default for DocNode { fn default() -> Self { Self { - kind: DocNodeKind::ModuleDoc, is_default: None, - name: "".to_string(), + name: "".into(), declaration_kind: DeclarationKind::Private, location: Location::default(), js_doc: JsDoc::default(), - function_def: None, - variable_def: None, - enum_def: None, - class_def: None, - type_alias_def: None, - namespace_def: None, - interface_def: None, - import_def: None, + def: DocNodeDef::ModuleDoc, } } } @@ -175,17 +182,17 @@ impl Default for DocNode { impl DocNode { pub fn module_doc(location: Location, js_doc: JsDoc) -> Self { Self { - kind: DocNodeKind::ModuleDoc, - name: "".to_string(), + name: "".into(), + is_default: None, location, declaration_kind: DeclarationKind::Export, js_doc, - ..Default::default() + def: DocNodeDef::ModuleDoc, } } pub fn function( - name: String, + name: Box, is_default: bool, location: Location, declaration_kind: DeclarationKind, @@ -193,19 +200,19 @@ impl DocNode { fn_def: super::function::FunctionDef, ) -> Self { Self { - kind: DocNodeKind::Function, name, is_default: Some(is_default), location, declaration_kind, js_doc, - function_def: Some(fn_def), - ..Default::default() + def: DocNodeDef::Function { + function_def: fn_def, + }, } } pub fn variable( - name: String, + name: Box, is_default: bool, location: Location, declaration_kind: DeclarationKind, @@ -213,19 +220,19 @@ impl DocNode { var_def: super::variable::VariableDef, ) -> Self { Self { - kind: DocNodeKind::Variable, name, is_default: Some(is_default), declaration_kind, location, js_doc, - variable_def: Some(var_def), - ..Default::default() + def: DocNodeDef::Variable { + variable_def: var_def, + }, } } pub fn r#enum( - name: String, + name: Box, is_default: bool, location: Location, declaration_kind: DeclarationKind, @@ -233,19 +240,17 @@ impl DocNode { enum_def: super::r#enum::EnumDef, ) -> Self { Self { - kind: DocNodeKind::Enum, name, is_default: Some(is_default), declaration_kind, location, js_doc, - enum_def: Some(enum_def), - ..Default::default() + def: DocNodeDef::Enum { enum_def }, } } pub fn class( - name: String, + name: Box, is_default: bool, location: Location, declaration_kind: DeclarationKind, @@ -253,19 +258,17 @@ impl DocNode { class_def: super::class::ClassDef, ) -> Self { Self { - kind: DocNodeKind::Class, name, is_default: Some(is_default), declaration_kind, location, js_doc, - class_def: Some(class_def), - ..Default::default() + def: DocNodeDef::Class { class_def }, } } pub fn type_alias( - name: String, + name: Box, is_default: bool, location: Location, declaration_kind: DeclarationKind, @@ -273,19 +276,17 @@ impl DocNode { type_alias_def: super::type_alias::TypeAliasDef, ) -> Self { Self { - kind: DocNodeKind::TypeAlias, name, is_default: Some(is_default), declaration_kind, location, js_doc, - type_alias_def: Some(type_alias_def), - ..Default::default() + def: DocNodeDef::TypeAlias { type_alias_def }, } } pub fn namespace( - name: String, + name: Box, is_default: bool, location: Location, declaration_kind: DeclarationKind, @@ -293,19 +294,17 @@ impl DocNode { namespace_def: NamespaceDef, ) -> Self { Self { - kind: DocNodeKind::Namespace, name, is_default: Some(is_default), declaration_kind, location, js_doc, - namespace_def: Some(namespace_def), - ..Default::default() + def: DocNodeDef::Namespace { namespace_def }, } } pub fn interface( - name: String, + name: Box, is_default: bool, location: Location, declaration_kind: DeclarationKind, @@ -313,51 +312,116 @@ impl DocNode { interface_def: super::interface::InterfaceDef, ) -> Self { Self { - kind: DocNodeKind::Interface, name, is_default: Some(is_default), declaration_kind, location, js_doc, - interface_def: Some(interface_def), - ..Default::default() + def: DocNodeDef::Interface { interface_def }, } } pub fn import( - name: String, + name: Box, location: Location, js_doc: JsDoc, import_def: ImportDef, ) -> Self { Self { - kind: DocNodeKind::Import, name, + is_default: None, declaration_kind: DeclarationKind::Private, location, js_doc, - import_def: Some(import_def), - ..Default::default() + def: DocNodeDef::Import { import_def }, } } pub fn get_name(&self) -> &str { - let default_name = match self.kind { - DocNodeKind::Class => self.class_def.as_ref().unwrap().def_name.as_ref(), - DocNodeKind::Function => { - self.function_def.as_ref().unwrap().def_name.as_ref() + let default_name = match &self.def { + DocNodeDef::Class { class_def } => class_def.def_name.as_deref(), + DocNodeDef::Function { function_def } => function_def.def_name.as_deref(), + DocNodeDef::Interface { interface_def } => { + interface_def.def_name.as_deref() } - DocNodeKind::Interface => { - self.interface_def.as_ref().unwrap().def_name.as_ref() - } - DocNodeKind::Enum - | DocNodeKind::Import - | DocNodeKind::ModuleDoc - | DocNodeKind::Namespace - | DocNodeKind::TypeAlias - | DocNodeKind::Variable => None, + DocNodeDef::Enum { .. } + | DocNodeDef::Import { .. } + | DocNodeDef::ModuleDoc { .. } + | DocNodeDef::Namespace { .. } + | DocNodeDef::TypeAlias { .. } + | DocNodeDef::Variable { .. } => None, }; default_name.unwrap_or(&self.name) } + + pub fn kind(&self) -> DocNodeKind { + match &self.def { + DocNodeDef::Class { .. } => DocNodeKind::Class, + DocNodeDef::Function { .. } => DocNodeKind::Function, + DocNodeDef::Variable { .. } => DocNodeKind::Variable, + DocNodeDef::Enum { .. } => DocNodeKind::Enum, + DocNodeDef::TypeAlias { .. } => DocNodeKind::TypeAlias, + DocNodeDef::Namespace { .. } => DocNodeKind::Namespace, + DocNodeDef::Interface { .. } => DocNodeKind::Interface, + DocNodeDef::Import { .. } => DocNodeKind::Import, + DocNodeDef::ModuleDoc => DocNodeKind::ModuleDoc, + } + } + + pub fn class_def(&self) -> Option<&super::class::ClassDef> { + match &self.def { + DocNodeDef::Class { class_def } => Some(class_def), + _ => None, + } + } + + pub fn function_def(&self) -> Option<&super::function::FunctionDef> { + match &self.def { + DocNodeDef::Function { function_def } => Some(function_def), + _ => None, + } + } + + pub fn variable_def(&self) -> Option<&super::variable::VariableDef> { + match &self.def { + DocNodeDef::Variable { variable_def } => Some(variable_def), + _ => None, + } + } + + pub fn enum_def(&self) -> Option<&super::r#enum::EnumDef> { + match &self.def { + DocNodeDef::Enum { enum_def } => Some(enum_def), + _ => None, + } + } + + pub fn type_alias_def(&self) -> Option<&super::type_alias::TypeAliasDef> { + match &self.def { + DocNodeDef::TypeAlias { type_alias_def } => Some(type_alias_def), + _ => None, + } + } + + pub fn namespace_def(&self) -> Option<&NamespaceDef> { + match &self.def { + DocNodeDef::Namespace { namespace_def } => Some(namespace_def), + _ => None, + } + } + + pub fn interface_def(&self) -> Option<&super::interface::InterfaceDef> { + match &self.def { + DocNodeDef::Interface { interface_def } => Some(interface_def), + _ => None, + } + } + + pub fn import_def(&self) -> Option<&ImportDef> { + match &self.def { + DocNodeDef::Import { import_def } => Some(import_def), + _ => None, + } + } } diff --git a/src/params.rs b/src/params.rs index 2e84889e..fa8cd209 100644 --- a/src/params.rs +++ b/src/params.rs @@ -47,14 +47,14 @@ pub enum ParamPatternDef { pub struct ParamDef { #[serde(flatten)] pub pattern: ParamPatternDef, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub decorators: Vec, + #[serde(skip_serializing_if = "<[_]>::is_empty", default)] + pub decorators: Box<[DecoratorDef]>, pub ts_type: Option, } impl Display for ParamDef { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - for decorator in &self.decorators { + for decorator in self.decorators.iter() { write!(f, "{} ", decorator)?; } match &self.pattern { @@ -156,7 +156,7 @@ pub fn ident_to_param_def( name: ident.id.sym.to_string(), optional: ident.id.optional, }, - decorators: Vec::new(), + decorators: Box::new([]), ts_type, } } @@ -174,7 +174,7 @@ fn rest_pat_to_param_def( pattern: ParamPatternDef::Rest { arg: Box::new(pat_to_param_def(parsed_source, &rest_pat.arg)), }, - decorators: Vec::new(), + decorators: Box::new([]), ts_type, } } @@ -217,7 +217,7 @@ fn object_pat_to_param_def( props, optional: object_pat.optional, }, - decorators: Vec::new(), + decorators: Box::new([]), ts_type, } } @@ -241,7 +241,7 @@ fn array_pat_to_param_def( elements, optional: array_pat.optional, }, - decorators: Vec::new(), + decorators: Box::new([]), ts_type, } } @@ -265,7 +265,7 @@ pub fn assign_pat_to_param_def( left: Box::new(left), right: crate::interface::expr_to_name(&assign_pat.right), }, - decorators: Vec::new(), + decorators: Box::new([]), ts_type: None, } } diff --git a/src/parser.rs b/src/parser.rs index d27485c7..aae18555 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -70,7 +70,6 @@ use std::collections::HashSet; use std::error::Error; use std::fmt; use std::rc::Rc; -use std::sync::Arc; #[derive(Debug)] pub enum DocError { @@ -260,19 +259,19 @@ impl<'a> DocParser<'a> { // hoist any module doc to be the exported namespaces module doc let mut js_doc = JsDoc::default(); for doc_node in &doc_nodes { - if matches!(doc_node.kind, DocNodeKind::ModuleDoc) { + if matches!(doc_node.kind(), DocNodeKind::ModuleDoc) { js_doc = doc_node.js_doc.clone(); } } let ns_def = NamespaceDef { elements: doc_nodes .into_iter() - .filter(|dn| !matches!(dn.kind, DocNodeKind::ModuleDoc)) - .map(Arc::new) + .filter(|dn| !matches!(dn.kind(), DocNodeKind::ModuleDoc)) + .map(Rc::new) .collect(), }; let ns_doc_node = DocNode::namespace( - export_name, + export_name.into_boxed_str(), false, definition_location(first_def), DeclarationKind::Export, @@ -291,7 +290,7 @@ impl<'a> DocParser<'a> { decl.maybe_node(), ); for mut doc_node in maybe_docs { - doc_node.name = export_name.clone(); + doc_node.name = export_name.as_str().into(); doc_node.declaration_kind = DeclarationKind::Export; flattened_docs.push(doc_node); @@ -359,7 +358,7 @@ impl<'a> DocParser<'a> { }; let doc_node = DocNode::import( - name, + name.into_boxed_str(), location.clone(), js_doc.clone(), import_def, @@ -389,7 +388,7 @@ impl<'a> DocParser<'a> { let js_doc = js_doc_for_range(source, &expando_property.inner().range())?; Some(DocNode::variable( - expando_property.prop_name().to_string(), + expando_property.prop_name().to_string().into_boxed_str(), false, location, DeclarationKind::Declare, @@ -428,7 +427,7 @@ impl<'a> DocParser<'a> { .map(|(name, var_def)| { let location = get_location(module_info.source(), ident.start()); DocNode::variable( - name, + name.into_boxed_str(), false, location, DeclarationKind::Declare, @@ -456,7 +455,7 @@ impl<'a> DocParser<'a> { super::class::get_doc_for_class_decl(parsed_source, class_decl); let location = get_location(parsed_source, full_range.start); Some(DocNode::class( - name, + name.into_boxed_str(), false, location, DeclarationKind::Declare, @@ -476,7 +475,7 @@ impl<'a> DocParser<'a> { super::function::get_doc_for_fn_decl(parsed_source, fn_decl); let location = get_location(parsed_source, full_range.start); Some(DocNode::function( - name, + name.into_boxed_str(), false, location, DeclarationKind::Declare, @@ -499,7 +498,7 @@ impl<'a> DocParser<'a> { ); let location = get_location(parsed_source, full_range.start); Some(DocNode::interface( - name, + name.into_boxed_str(), false, location, DeclarationKind::Declare, @@ -522,7 +521,7 @@ impl<'a> DocParser<'a> { ); let location = get_location(parsed_source, full_range.start); Some(DocNode::type_alias( - name, + name.into_boxed_str(), false, location, DeclarationKind::Declare, @@ -542,7 +541,7 @@ impl<'a> DocParser<'a> { super::r#enum::get_doc_for_ts_enum_decl(parsed_source, ts_enum); let location = get_location(parsed_source, full_range.start); Some(DocNode::r#enum( - name, + name.into_boxed_str(), false, location, DeclarationKind::Declare, @@ -608,10 +607,10 @@ impl<'a> DocParser<'a> { definition.symbol_decl.maybe_node(), ); for mut doc_node in maybe_docs { - doc_node.name = export_name.to_string(); + doc_node.name = export_name.as_str().into(); doc_node.declaration_kind = DeclarationKind::Export; - elements.push(Arc::new(doc_node)); + elements.push(Rc::new(doc_node)); } } } @@ -634,7 +633,7 @@ impl<'a> DocParser<'a> { child_symbol, ) .into_iter() - .map(Arc::new), + .map(Rc::new), ); } } @@ -643,7 +642,7 @@ impl<'a> DocParser<'a> { let location = get_location(module_info.source(), full_range.start); let is_default = namespace_name == "default"; Some(DocNode::namespace( - namespace_name, + namespace_name.into_boxed_str(), is_default, location, DeclarationKind::Declare, @@ -692,8 +691,10 @@ impl<'a> DocParser<'a> { let doc_node = match &export_default_decl.decl { DefaultDecl::Class(class_expr) => { - let default_name = - class_expr.ident.as_ref().map(|ident| ident.sym.to_string()); + let default_name = class_expr + .ident + .as_ref() + .map(|ident| ident.sym.to_string().into_boxed_str()); let (class_def, decorator_js_doc) = crate::class::class_to_class_def( parsed_source, &class_expr.class, @@ -705,7 +706,7 @@ impl<'a> DocParser<'a> { js_doc }; DocNode::class( - name, + name.into_boxed_str(), true, location, DeclarationKind::Export, @@ -722,7 +723,7 @@ impl<'a> DocParser<'a> { default_name, ); DocNode::function( - name, + name.into_boxed_str(), true, location, DeclarationKind::Export, @@ -739,7 +740,7 @@ impl<'a> DocParser<'a> { Some(default_name), ); DocNode::interface( - name, + name.into_boxed_str(), true, location, DeclarationKind::Export, @@ -761,7 +762,7 @@ impl<'a> DocParser<'a> { { let location = get_location(parsed_source, export_expr.start()); Some(DocNode::variable( - String::from("default"), + "default".into(), true, location, DeclarationKind::Export, @@ -1015,7 +1016,7 @@ impl<'a> DocParser<'a> { definition.symbol_decl.maybe_node(), ); for mut doc_node in maybe_docs { - doc_node.name = export_name.clone(); + doc_node.name = export_name.as_str().into(); doc_node.is_default = Some(export_name == "default"); doc_node.declaration_kind = DeclarationKind::Export; @@ -1111,12 +1112,12 @@ impl<'a> DocParser<'a> { Some(SymbolNodeRef::ExpandoProperty(n)), ); for doc in &mut docs { - doc.name = name.clone(); + doc.name = name.as_str().into(); doc.declaration_kind = DeclarationKind::Declare; } docs }) - .map(Arc::new) + .map(Rc::new) .collect::>(); if elements.is_empty() { return None; @@ -1128,11 +1129,11 @@ impl<'a> DocParser<'a> { DeclarationKind::Declare, // give this a JS doc to prevent a missing JS doc diagnostic JsDoc { - doc: Some(format!( - "Additional properties on the `{}` function.", - func_doc.name - )), - tags: vec![], + doc: Some( + format!("Additional properties on the `{}` function.", func_doc.name) + .into_boxed_str(), + ), + tags: Box::new([]), }, NamespaceDef { elements }, )) @@ -1358,21 +1359,22 @@ fn parse_json_module_doc_node( ) -> Option { if let Ok(value) = serde_json::from_str(source) { Some(DocNode { - kind: DocNodeKind::Variable, - name: "default".to_string(), + name: "default".into(), is_default: Some(true), location: Location { - filename: specifier.to_string(), + filename: specifier.to_string().into_boxed_str(), col: 0, line: 1, byte_index: 0, }, declaration_kind: DeclarationKind::Export, - variable_def: Some(VariableDef { - kind: VarDeclKind::Var, - ts_type: Some(parse_json_module_type(&value)), - }), - ..Default::default() + js_doc: JsDoc::default(), + def: node::DocNodeDef::Variable { + variable_def: VariableDef { + kind: VarDeclKind::Var, + ts_type: Some(parse_json_module_type(&value)), + }, + }, }) } else { // no doc nodes @@ -1411,7 +1413,7 @@ fn parse_json_module_type(value: &serde_json::Value) -> TsTypeDef { readonly: false, computed: false, optional: false, - type_params: Vec::new(), + type_params: Box::new([]), location: Default::default(), }) .collect(), diff --git a/src/printer.rs b/src/printer.rs index 697f5435..4fbe946d 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -51,7 +51,8 @@ impl<'a> DocPrinter<'a> { let mut sorted = Vec::from(doc_nodes); sorted.sort_unstable_by(|a, b| { - let kind_cmp = self.kind_order(&a.kind).cmp(&self.kind_order(&b.kind)); + let kind_cmp = + self.kind_order(&a.kind()).cmp(&self.kind_order(&b.kind())); if kind_cmp == core::cmp::Ordering::Equal { a.name.cmp(&b.name) } else { @@ -60,10 +61,10 @@ impl<'a> DocPrinter<'a> { }); for node in &sorted { - let has_overloads = if node.kind == DocNodeKind::Function { + let has_overloads = if node.kind() == DocNodeKind::Function { sorted .iter() - .filter(|n| n.kind == DocNodeKind::Function && n.name == node.name) + .filter(|n| n.kind() == DocNodeKind::Function && n.name == node.name) .count() > 1 } else { @@ -72,8 +73,7 @@ impl<'a> DocPrinter<'a> { if !has_overloads || node - .function_def - .as_ref() + .function_def() .map(|def| !def.has_body) .unwrap_or(false) { @@ -97,7 +97,7 @@ impl<'a> DocPrinter<'a> { self.format_jsdoc(w, &node.js_doc, indent + 1)?; writeln!(w)?; - match node.kind { + match node.kind() { DocNodeKind::Class => self.format_class(w, node)?, DocNodeKind::Enum => self.format_enum(w, node)?, DocNodeKind::Interface => self.format_interface(w, node)?, @@ -134,7 +134,7 @@ impl<'a> DocPrinter<'a> { indent: i64, has_overloads: bool, ) -> FmtResult { - match node.kind { + match node.kind() { DocNodeKind::ModuleDoc => self.format_module_doc(w, node, indent), DocNodeKind::Function => { self.format_function_signature(w, node, indent, has_overloads) @@ -169,7 +169,7 @@ impl<'a> DocPrinter<'a> { if !js_doc.tags.is_empty() { writeln!(w)?; } - for tag in &js_doc.tags { + for tag in js_doc.tags.iter() { self.format_jsdoc_tag(w, tag, indent)?; } Ok(()) @@ -178,7 +178,7 @@ impl<'a> DocPrinter<'a> { fn format_jsdoc_tag_maybe_doc( &self, w: &mut Formatter<'_>, - maybe_doc: &Option, + maybe_doc: &Option>, indent: i64, ) -> FmtResult { if let Some(doc) = maybe_doc { @@ -418,9 +418,9 @@ impl<'a> DocPrinter<'a> { } fn format_class(&self, w: &mut Formatter<'_>, node: &DocNode) -> FmtResult { - let class_def = node.class_def.as_ref().unwrap(); + let class_def = node.class_def().unwrap(); let has_overloads = class_def.constructors.len() > 1; - for node in &class_def.constructors { + for node in class_def.constructors.iter() { if !has_overloads || !node.has_body { writeln!(w, "{}{}", Indent(1), node,)?; self.format_jsdoc(w, &node.js_doc, 2)?; @@ -433,13 +433,13 @@ impl<'a> DocPrinter<'a> { .unwrap_or(deno_ast::swc::ast::Accessibility::Public) != deno_ast::swc::ast::Accessibility::Private }) { - for d in &node.decorators { + for d in node.decorators.iter() { writeln!(w, "{}{}", Indent(1), d)?; } writeln!(w, "{}{}", Indent(1), node,)?; self.format_jsdoc(w, &node.js_doc, 2)?; } - for index_sign_def in &class_def.index_signatures { + for index_sign_def in class_def.index_signatures.iter() { writeln!(w, "{}{}", Indent(1), index_sign_def)?; } for node in class_def.methods.iter().filter(|node| { @@ -456,7 +456,7 @@ impl<'a> DocPrinter<'a> { .count() > 1; if !has_overloads || !node.function_def.has_body { - for d in &node.function_def.decorators { + for d in node.function_def.decorators.iter() { writeln!(w, "{}{}", Indent(1), d)?; } writeln!(w, "{}{}", Indent(1), node,)?; @@ -467,7 +467,7 @@ impl<'a> DocPrinter<'a> { } fn format_enum(&self, w: &mut Formatter<'_>, node: &DocNode) -> FmtResult { - let enum_def = node.enum_def.as_ref().unwrap(); + let enum_def = node.enum_def().unwrap(); for member in &enum_def.members { writeln!(w, "{}{}", Indent(1), colors::bold(&member.name))?; self.format_jsdoc(w, &member.js_doc, 2)?; @@ -480,7 +480,7 @@ impl<'a> DocPrinter<'a> { w: &mut Formatter<'_>, node: &DocNode, ) -> FmtResult { - let interface_def = node.interface_def.as_ref().unwrap(); + let interface_def = node.interface_def().unwrap(); for constructor in &interface_def.constructors { writeln!(w, "{}{}", Indent(1), constructor)?; @@ -505,12 +505,12 @@ impl<'a> DocPrinter<'a> { w: &mut Formatter<'_>, node: &DocNode, ) -> FmtResult { - let elements = &node.namespace_def.as_ref().unwrap().elements; + let elements = &node.namespace_def().unwrap().elements; for node in elements { - let has_overloads = if node.kind == DocNodeKind::Function { + let has_overloads = if node.kind() == DocNodeKind::Function { elements .iter() - .filter(|n| n.kind == DocNodeKind::Function && n.name == node.name) + .filter(|n| n.kind() == DocNodeKind::Function && n.name == node.name) .count() > 1 } else { @@ -528,8 +528,8 @@ impl<'a> DocPrinter<'a> { node: &DocNode, indent: i64, ) -> FmtResult { - let class_def = node.class_def.as_ref().unwrap(); - for node in &class_def.decorators { + let class_def = node.class_def().unwrap(); + for node in class_def.decorators.iter() { writeln!(w, "{}{}", Indent(indent), node)?; } write!( @@ -595,7 +595,7 @@ impl<'a> DocPrinter<'a> { indent: i64, has_overloads: bool, ) -> FmtResult { - let function_def = node.function_def.as_ref().unwrap(); + let function_def = node.function_def().unwrap(); if !has_overloads || !function_def.has_body { write!( w, @@ -633,7 +633,7 @@ impl<'a> DocPrinter<'a> { node: &DocNode, indent: i64, ) -> FmtResult { - let interface_def = node.interface_def.as_ref().unwrap(); + let interface_def = node.interface_def().unwrap(); write!( w, "{}{}{} {}", @@ -680,7 +680,7 @@ impl<'a> DocPrinter<'a> { node: &DocNode, indent: i64, ) -> FmtResult { - let type_alias_def = node.type_alias_def.as_ref().unwrap(); + let type_alias_def = node.type_alias_def().unwrap(); write!( w, "{}{}{} {}", @@ -723,7 +723,7 @@ impl<'a> DocPrinter<'a> { node: &DocNode, indent: i64, ) -> FmtResult { - let variable_def = node.variable_def.as_ref().unwrap(); + let variable_def = node.variable_def().unwrap(); write!( w, "{}{}{} {}", diff --git a/src/tests.rs b/src/tests.rs index f77097ed..6affbd43 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -577,67 +577,54 @@ export namespace Deno { .unwrap(); // Namespace - let found = - find_nodes_by_name_recursively(entries.clone(), "Deno".to_string()); + let found = find_nodes_by_name_recursively(entries.clone(), "Deno"); assert_eq!(found.len(), 1); - assert_eq!(found[0].name, "Deno".to_string()); + assert_eq!(found[0].name, "Deno".into()); // Overloaded functions - let found = - find_nodes_by_name_recursively(entries.clone(), "Deno.test".to_string()); + let found = find_nodes_by_name_recursively(entries.clone(), "Deno.test"); assert_eq!(found.len(), 3); - assert_eq!(found[0].name, "test".to_string()); - assert_eq!(found[1].name, "test".to_string()); - assert_eq!(found[2].name, "test".to_string()); + assert_eq!(found[0].name, "test".into()); + assert_eq!(found[1].name, "test".into()); + assert_eq!(found[2].name, "test".into()); // Nested namespace - let found = - find_nodes_by_name_recursively(entries.clone(), "Deno.Inner.a".to_string()); + let found = find_nodes_by_name_recursively(entries.clone(), "Deno.Inner.a"); assert_eq!(found.len(), 1); - assert_eq!(found[0].name, "a".to_string()); + assert_eq!(found[0].name, "a".into()); // Interface property - let found = find_nodes_by_name_recursively( - entries.clone(), - "Deno.Conn.rid".to_string(), - ); + let found = find_nodes_by_name_recursively(entries.clone(), "Deno.Conn.rid"); assert_eq!(found.len(), 1); - assert_eq!(found[0].name, "rid".to_string()); - assert_eq!(found[0].kind, DocNodeKind::Variable); + assert_eq!(found[0].name, "rid".into()); + assert_eq!(found[0].kind(), DocNodeKind::Variable); // Interface method - let found = find_nodes_by_name_recursively( - entries.clone(), - "Deno.Conn.closeWrite".to_string(), - ); + let found = + find_nodes_by_name_recursively(entries.clone(), "Deno.Conn.closeWrite"); assert_eq!(found.len(), 1); - assert_eq!(found[0].name, "closeWrite".to_string()); - assert_eq!(found[0].kind, DocNodeKind::Function); + assert_eq!(found[0].name, "closeWrite".into()); + assert_eq!(found[0].kind(), DocNodeKind::Function); // Class property - let found = find_nodes_by_name_recursively( - entries.clone(), - "Deno.Process.pid".to_string(), - ); + let found = + find_nodes_by_name_recursively(entries.clone(), "Deno.Process.pid"); assert_eq!(found.len(), 1); - assert_eq!(found[0].name, "pid".to_string()); - assert_eq!(found[0].kind, DocNodeKind::Variable); + assert_eq!(found[0].name, "pid".into()); + assert_eq!(found[0].kind(), DocNodeKind::Variable); // Class method - let found = find_nodes_by_name_recursively( - entries.clone(), - "Deno.Process.output".to_string(), - ); + let found = + find_nodes_by_name_recursively(entries.clone(), "Deno.Process.output"); assert_eq!(found.len(), 1); - assert_eq!(found[0].name, "output".to_string()); - assert_eq!(found[0].kind, DocNodeKind::Function); + assert_eq!(found[0].name, "output".into()); + assert_eq!(found[0].kind(), DocNodeKind::Function); // No match - let found = - find_nodes_by_name_recursively(entries.clone(), "Deno.test.a".to_string()); + let found = find_nodes_by_name_recursively(entries.clone(), "Deno.test.a"); assert_eq!(found.len(), 0); - let found = find_nodes_by_name_recursively(entries, "a.b.c".to_string()); + let found = find_nodes_by_name_recursively(entries, "a.b.c"); assert_eq!(found.len(), 0); } diff --git a/src/ts_type.rs b/src/ts_type.rs index 3cd3f21f..5398c4d4 100644 --- a/src/ts_type.rs +++ b/src/ts_type.rs @@ -242,7 +242,7 @@ impl TsTypeDef { .params .iter() .map(|ts_type| TsTypeDef::new(parsed_source, ts_type)) - .collect::>(); + .collect::>(); Some(ts_type_defs) } else { @@ -271,7 +271,7 @@ impl TsTypeDef { .params .iter() .map(|ts_type| TsTypeDef::new(parsed_source, ts_type)) - .collect::>(); + .collect::>(); Some(ts_type_defs) } else { @@ -399,7 +399,7 @@ impl TsTypeDef { computed: ts_getter_sig.computed, optional: false, return_type: maybe_return_type, - type_params: vec![], + type_params: Box::new([]), }; methods.push(method_def); } @@ -424,7 +424,7 @@ impl TsTypeDef { computed: ts_setter_sig.computed, optional: false, return_type: None, - type_params: vec![], + type_params: Box::new([]), }; methods.push(method_def); } @@ -758,7 +758,7 @@ fn ts_entity_name_to_name(entity_name: &TsEntityName) -> String { #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(rename_all = "camelCase")] pub struct TsTypeRefDef { - pub type_params: Option>, + pub type_params: Option>, pub type_name: String, } @@ -803,7 +803,7 @@ pub struct TsFnOrConstructorDef { pub constructor: bool, pub ts_type: TsTypeDef, pub params: Vec, - pub type_params: Vec, + pub type_params: Box<[TsTypeParamDef]>, } impl TsFnOrConstructorDef { @@ -924,7 +924,7 @@ pub struct ConstructorDef { pub js_doc: JsDoc, pub params: Vec, pub return_type: Option, - pub type_params: Vec, + pub type_params: Box<[TsTypeParamDef]>, pub location: Location, } @@ -953,13 +953,13 @@ pub struct MethodDef { pub computed: bool, pub optional: bool, pub return_type: Option, - pub type_params: Vec, + pub type_params: Box<[TsTypeParamDef]>, } impl From for DocNode { fn from(def: MethodDef) -> DocNode { DocNode::function( - def.name, + def.name.into_boxed_str(), false, def.location, DeclarationKind::Private, @@ -972,7 +972,7 @@ impl From for DocNode { is_async: false, is_generator: false, type_params: def.type_params, - decorators: vec![], + decorators: Box::new([]), }, ) } @@ -1008,13 +1008,13 @@ pub struct PropertyDef { pub computed: bool, pub optional: bool, pub ts_type: Option, - pub type_params: Vec, + pub type_params: Box<[TsTypeParamDef]>, } impl From for DocNode { fn from(def: PropertyDef) -> DocNode { DocNode::variable( - def.name, + def.name.into_boxed_str(), false, def.location, DeclarationKind::Private, @@ -1052,7 +1052,7 @@ pub struct CallSignatureDef { pub location: Location, pub params: Vec, pub ts_type: Option, - pub type_params: Vec, + pub type_params: Box<[TsTypeParamDef]>, } impl Display for CallSignatureDef { @@ -1813,7 +1813,7 @@ fn infer_ts_type_from_obj_inner( computed: false, optional: false, ts_type: None, - type_params: vec![], + type_params: Box::new([]), }); } Prop::KeyValue(kv) => { @@ -1826,7 +1826,7 @@ fn infer_ts_type_from_obj_inner( computed: kv.key.is_computed(), optional: false, ts_type: infer_ts_type_from_expr(parsed_source, &kv.value, false), - type_params: vec![], + type_params: Box::new([]), }); } Prop::Assign(_) => unreachable!("This is invalid for object literal!"), @@ -1846,7 +1846,7 @@ fn infer_ts_type_from_obj_inner( computed, optional: false, return_type, - type_params: vec![], + type_params: Box::new([]), }); } Prop::Setter(setter) => { @@ -1862,7 +1862,7 @@ fn infer_ts_type_from_obj_inner( computed, optional: false, return_type: None, - type_params: vec![], + type_params: Box::new([]), }); } Prop::Method(method) => { @@ -2144,14 +2144,14 @@ impl Display for TsTypeDef { pub fn maybe_type_param_instantiation_to_type_defs( parsed_source: &ParsedSource, maybe_type_param_instantiation: Option<&TsTypeParamInstantiation>, -) -> Vec { +) -> Box<[TsTypeDef]> { if let Some(type_param_instantiation) = maybe_type_param_instantiation { type_param_instantiation .params .iter() .map(|type_param| TsTypeDef::new(parsed_source, type_param)) - .collect::>() + .collect::>() } else { - vec![] + Box::new([]) } } diff --git a/src/ts_type_param.rs b/src/ts_type_param.rs index 576a471d..206a1369 100644 --- a/src/ts_type_param.rs +++ b/src/ts_type_param.rs @@ -58,14 +58,14 @@ impl TsTypeParamDef { pub fn maybe_type_param_decl_to_type_param_defs( parsed_source: &ParsedSource, maybe_type_param_decl: Option<&TsTypeParamDecl>, -) -> Vec { +) -> Box<[TsTypeParamDef]> { if let Some(type_params_decl) = maybe_type_param_decl { type_params_decl .params .iter() .map(|type_param| TsTypeParamDef::new(parsed_source, type_param)) - .collect::>() + .collect::>() } else { - vec![] + Box::new([]) } } diff --git a/src/type_alias.rs b/src/type_alias.rs index bdaf0fb0..880b480e 100644 --- a/src/type_alias.rs +++ b/src/type_alias.rs @@ -10,7 +10,7 @@ use serde::Serialize; #[serde(rename_all = "camelCase")] pub struct TypeAliasDef { pub ts_type: TsTypeDef, - pub type_params: Vec, + pub type_params: Box<[TsTypeParamDef]>, } pub fn get_doc_for_ts_type_alias_decl( diff --git a/src/util/swc.rs b/src/util/swc.rs index f1d807b0..46db3b90 100644 --- a/src/util/swc.rs +++ b/src/util/swc.rs @@ -119,7 +119,7 @@ pub fn get_text_info_location( text_info.line_and_column_display_with_indent_width(pos, 4); let byte_index = pos.as_byte_index(text_info.range().start); Location { - filename: specifier.to_string(), + filename: specifier.into(), // todo(#150): make 0-indexed line: line_and_column_index.line_number, col: line_and_column_index.column_number - 1, diff --git a/tests/specs/Jsdoc.txt b/tests/specs/Jsdoc.txt index ce03d52b..e577a76f 100644 --- a/tests/specs/Jsdoc.txt +++ b/tests/specs/Jsdoc.txt @@ -46,7 +46,6 @@ interface B # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -59,6 +58,7 @@ interface B "jsDoc": { "doc": "A is a class\n\nNothing more" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -72,7 +72,6 @@ interface B } }, { - "kind": "interface", "name": "B", "isDefault": false, "location": { @@ -85,6 +84,7 @@ interface B "jsDoc": { "doc": "B is an interface\n\nShould be" }, + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], @@ -96,7 +96,6 @@ interface B } }, { - "kind": "function", "name": "C", "isDefault": false, "location": { @@ -109,6 +108,7 @@ interface B "jsDoc": { "doc": "C is a function\n\nSummarised" }, + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/Jsdoc_for_source_starts_with_shebang.txt b/tests/specs/Jsdoc_for_source_starts_with_shebang.txt index 65fbfad2..cd3b5577 100644 --- a/tests/specs/Jsdoc_for_source_starts_with_shebang.txt +++ b/tests/specs/Jsdoc_for_source_starts_with_shebang.txt @@ -48,7 +48,6 @@ interface B # output.json [ { - "kind": "moduleDoc", "name": "", "location": { "filename": "file:///mod.ts", @@ -64,10 +63,10 @@ interface B "kind": "module" } ] - } + }, + "kind": "moduleDoc" }, { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -80,6 +79,7 @@ interface B "jsDoc": { "doc": "A is a simple class." }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -93,7 +93,6 @@ interface B } }, { - "kind": "interface", "name": "B", "isDefault": false, "location": { @@ -106,6 +105,7 @@ interface B "jsDoc": { "doc": "B is a simple interface." }, + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], @@ -117,7 +117,6 @@ interface B } }, { - "kind": "function", "name": "C", "isDefault": false, "location": { @@ -130,6 +129,7 @@ interface B "jsDoc": { "doc": "C is a function." }, + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/Overloads.txt b/tests/specs/Overloads.txt index e84526f9..e22bd26e 100644 --- a/tests/specs/Overloads.txt +++ b/tests/specs/Overloads.txt @@ -33,7 +33,6 @@ function a(b: number): number # output.json [ { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -43,6 +42,7 @@ function a(b: number): number "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -67,7 +67,6 @@ function a(b: number): number } }, { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -77,6 +76,7 @@ function a(b: number): number "byteIndex": 38 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -101,7 +101,6 @@ function a(b: number): number } }, { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -111,6 +110,7 @@ function a(b: number): number "byteIndex": 76 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/abstract_class.txt b/tests/specs/abstract_class.txt index 33bd148d..71898385 100644 --- a/tests/specs/abstract_class.txt +++ b/tests/specs/abstract_class.txt @@ -18,7 +18,6 @@ abstract class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -28,6 +27,7 @@ abstract class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": true, "constructors": [], diff --git a/tests/specs/abstract_class_abstract_method.txt b/tests/specs/abstract_class_abstract_method.txt index eebc00c8..353c103d 100644 --- a/tests/specs/abstract_class_abstract_method.txt +++ b/tests/specs/abstract_class_abstract_method.txt @@ -28,7 +28,6 @@ abstract class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -38,6 +37,7 @@ abstract class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": true, "constructors": [], diff --git a/tests/specs/class_async_method.txt b/tests/specs/class_async_method.txt index 3210d034..f1bcd263 100644 --- a/tests/specs/class_async_method.txt +++ b/tests/specs/class_async_method.txt @@ -28,7 +28,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_constructor.txt b/tests/specs/class_constructor.txt index 5827a57d..10094f4c 100644 --- a/tests/specs/class_constructor.txt +++ b/tests/specs/class_constructor.txt @@ -58,7 +58,6 @@ class Class3 # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -68,6 +67,7 @@ class Class3 "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [ @@ -109,7 +109,6 @@ class Class3 } }, { - "kind": "class", "name": "Class2", "isDefault": false, "location": { @@ -122,6 +121,7 @@ class Class3 "jsDoc": { "doc": "doc2" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [ @@ -148,7 +148,6 @@ class Class3 } }, { - "kind": "class", "name": "Class3", "isDefault": false, "location": { @@ -161,6 +160,7 @@ class Class3 "jsDoc": { "doc": "doc3" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [ diff --git a/tests/specs/class_declaration.txt b/tests/specs/class_declaration.txt index 62ecf040..44e54708 100644 --- a/tests/specs/class_declaration.txt +++ b/tests/specs/class_declaration.txt @@ -18,7 +18,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -28,6 +27,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_decorators.txt b/tests/specs/class_decorators.txt index 542b78f1..0edc09a4 100644 --- a/tests/specs/class_decorators.txt +++ b/tests/specs/class_decorators.txt @@ -76,7 +76,6 @@ class A # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -86,6 +85,7 @@ class A "byteIndex": 8 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_details.txt b/tests/specs/class_details.txt index 58c928a9..c064de50 100644 --- a/tests/specs/class_details.txt +++ b/tests/specs/class_details.txt @@ -32,7 +32,6 @@ class C # output.json [ { - "kind": "class", "name": "C", "isDefault": false, "location": { @@ -42,6 +41,7 @@ class C "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_details_all_with_private.txt b/tests/specs/class_details_all_with_private.txt index f8d6ac2c..8e8dc1dc 100644 --- a/tests/specs/class_details_all_with_private.txt +++ b/tests/specs/class_details_all_with_private.txt @@ -47,7 +47,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -57,6 +56,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_details_only_non_private_without_private.txt b/tests/specs/class_details_only_non_private_without_private.txt index 56cf2e0e..23c0022b 100644 --- a/tests/specs/class_details_only_non_private_without_private.txt +++ b/tests/specs/class_details_only_non_private_without_private.txt @@ -45,7 +45,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -55,6 +54,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_extends.txt b/tests/specs/class_extends.txt index ecb49dec..f3e5efc2 100644 --- a/tests/specs/class_extends.txt +++ b/tests/specs/class_extends.txt @@ -18,7 +18,6 @@ class Class extends Object # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -28,6 +27,7 @@ class Class extends Object "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_extends_implements.txt b/tests/specs/class_extends_implements.txt index 89a244d8..aee2c594 100644 --- a/tests/specs/class_extends_implements.txt +++ b/tests/specs/class_extends_implements.txt @@ -18,7 +18,6 @@ class Class extends Object implements Iterator, Iterable # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -28,6 +27,7 @@ class Class extends Object implements Iterator, Iterable "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_generic_extends_implements.txt b/tests/specs/class_generic_extends_implements.txt index a645271c..5e0e4287 100644 --- a/tests/specs/class_generic_extends_implements.txt +++ b/tests/specs/class_generic_extends_implements.txt @@ -18,7 +18,6 @@ class Class extends Map implements Iterator, Iterable # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -28,6 +27,7 @@ class Class extends Map implements Iterator, Iterable "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_getter_and_setter.txt b/tests/specs/class_getter_and_setter.txt index e36c911e..6850c4f5 100644 --- a/tests/specs/class_getter_and_setter.txt +++ b/tests/specs/class_getter_and_setter.txt @@ -37,7 +37,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -47,6 +46,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_implements.txt b/tests/specs/class_implements.txt index 0e423543..e9cd0e40 100644 --- a/tests/specs/class_implements.txt +++ b/tests/specs/class_implements.txt @@ -18,7 +18,6 @@ class Class implements Iterator # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -28,6 +27,7 @@ class Class implements Iterator "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_implements2.txt b/tests/specs/class_implements2.txt index 3e1b36ce..3a994aaa 100644 --- a/tests/specs/class_implements2.txt +++ b/tests/specs/class_implements2.txt @@ -18,7 +18,6 @@ class Class implements Iterator, Iterable # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -28,6 +27,7 @@ class Class implements Iterator, Iterable "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_index_signature.txt b/tests/specs/class_index_signature.txt index 59907509..c7d39dd0 100644 --- a/tests/specs/class_index_signature.txt +++ b/tests/specs/class_index_signature.txt @@ -28,7 +28,6 @@ class C # output.json [ { - "kind": "class", "name": "C", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class C "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_method.txt b/tests/specs/class_method.txt index d2bad7f8..81665ea6 100644 --- a/tests/specs/class_method.txt +++ b/tests/specs/class_method.txt @@ -28,7 +28,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_method_overloads.txt b/tests/specs/class_method_overloads.txt index d3303306..ff9ceef3 100644 --- a/tests/specs/class_method_overloads.txt +++ b/tests/specs/class_method_overloads.txt @@ -38,7 +38,6 @@ class A # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -48,6 +47,7 @@ class A "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_override_prop_method.txt b/tests/specs/class_override_prop_method.txt index 0c0dbac4..401bb07e 100644 --- a/tests/specs/class_override_prop_method.txt +++ b/tests/specs/class_override_prop_method.txt @@ -37,7 +37,6 @@ class C extends B # output.json [ { - "kind": "class", "name": "C", "isDefault": false, "location": { @@ -47,6 +46,7 @@ class C extends B "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_private_property.txt b/tests/specs/class_private_property.txt index d1b50786..f0667e28 100644 --- a/tests/specs/class_private_property.txt +++ b/tests/specs/class_private_property.txt @@ -22,7 +22,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -32,6 +31,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_property.txt b/tests/specs/class_property.txt index b17b7e54..86e8308b 100644 --- a/tests/specs/class_property.txt +++ b/tests/specs/class_property.txt @@ -37,7 +37,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -47,6 +46,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_readonly_index_signature.txt b/tests/specs/class_readonly_index_signature.txt index 015798f7..44feb765 100644 --- a/tests/specs/class_readonly_index_signature.txt +++ b/tests/specs/class_readonly_index_signature.txt @@ -28,7 +28,6 @@ class C # output.json [ { - "kind": "class", "name": "C", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class C "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_readonly_property.txt b/tests/specs/class_readonly_property.txt index 9534b938..7622f4a5 100644 --- a/tests/specs/class_readonly_property.txt +++ b/tests/specs/class_readonly_property.txt @@ -28,7 +28,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/class_static_property.txt b/tests/specs/class_static_property.txt index d33db0ec..5a880dd0 100644 --- a/tests/specs/class_static_property.txt +++ b/tests/specs/class_static_property.txt @@ -28,7 +28,6 @@ class Class # output.json [ { - "kind": "class", "name": "Class", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class Class "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/const_declaration.txt b/tests/specs/const_declaration.txt index 924dee69..16d67682 100644 --- a/tests/specs/const_declaration.txt +++ b/tests/specs/const_declaration.txt @@ -17,7 +17,6 @@ const Const: 0 # output.json [ { - "kind": "variable", "name": "Const", "isDefault": false, "location": { @@ -27,6 +26,7 @@ const Const: 0 "byteIndex": 13 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "0", diff --git a/tests/specs/ctor_overloads.txt b/tests/specs/ctor_overloads.txt index 285e156f..08e71d94 100644 --- a/tests/specs/ctor_overloads.txt +++ b/tests/specs/ctor_overloads.txt @@ -40,7 +40,6 @@ class A # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -50,6 +49,7 @@ class A "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [ diff --git a/tests/specs/declare_namespace.txt b/tests/specs/declare_namespace.txt index 54648936..81f70e50 100644 --- a/tests/specs/declare_namespace.txt +++ b/tests/specs/declare_namespace.txt @@ -41,7 +41,6 @@ namespace RootNs # output.json [ { - "kind": "namespace", "name": "RootNs", "isDefault": false, "location": { @@ -54,10 +53,10 @@ namespace RootNs "jsDoc": { "doc": "Namespace JSdoc" }, + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "variable", "name": "a", "isDefault": false, "location": { @@ -67,6 +66,7 @@ namespace RootNs "byteIndex": 60 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "a", @@ -80,7 +80,6 @@ namespace RootNs } }, { - "kind": "namespace", "name": "NestedNs", "isDefault": false, "location": { @@ -93,10 +92,10 @@ namespace RootNs "jsDoc": { "doc": "Nested namespace JSDoc" }, + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "enum", "name": "Foo", "isDefault": false, "location": { @@ -106,6 +105,7 @@ namespace RootNs "byteIndex": 135 }, "declarationKind": "export", + "kind": "enum", "enumDef": { "members": [ { diff --git a/tests/specs/declare_namespace_ignore.txt b/tests/specs/declare_namespace_ignore.txt index a95aa3ab..ffb8867e 100644 --- a/tests/specs/declare_namespace_ignore.txt +++ b/tests/specs/declare_namespace_ignore.txt @@ -34,7 +34,6 @@ namespace RootNs # output.json [ { - "kind": "namespace", "name": "RootNs", "isDefault": false, "location": { @@ -47,10 +46,10 @@ namespace RootNs "jsDoc": { "doc": "Namespace JSdoc" }, + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "variable", "name": "a", "isDefault": false, "location": { @@ -60,6 +59,7 @@ namespace RootNs "byteIndex": 60 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "a", diff --git a/tests/specs/decorators_jsdoc.txt b/tests/specs/decorators_jsdoc.txt index fb1cb5fe..f4826131 100644 --- a/tests/specs/decorators_jsdoc.txt +++ b/tests/specs/decorators_jsdoc.txt @@ -25,7 +25,6 @@ class A # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class A "jsDoc": { "doc": "jsdoc" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/default_exports_declared_earlier.txt b/tests/specs/default_exports_declared_earlier.txt index fd915b94..6d1b6f16 100644 --- a/tests/specs/default_exports_declared_earlier.txt +++ b/tests/specs/default_exports_declared_earlier.txt @@ -18,7 +18,6 @@ function default(): void # output.json [ { - "kind": "function", "name": "default", "isDefault": true, "location": { @@ -28,6 +27,7 @@ function default(): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/destructuring_assignment_array.txt b/tests/specs/destructuring_assignment_array.txt index 79bc7638..4c01142e 100644 --- a/tests/specs/destructuring_assignment_array.txt +++ b/tests/specs/destructuring_assignment_array.txt @@ -64,7 +64,6 @@ private const rest5 # output.json [ { - "kind": "variable", "name": "array", "isDefault": false, "location": { @@ -74,6 +73,7 @@ private const rest5 "byteIndex": 6 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -88,7 +88,6 @@ private const rest5 } }, { - "kind": "variable", "name": "a1", "isDefault": false, "location": { @@ -98,13 +97,13 @@ private const rest5 "byteIndex": 34 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "b1", "isDefault": false, "location": { @@ -114,13 +113,13 @@ private const rest5 "byteIndex": 38 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "a2", "isDefault": false, "location": { @@ -130,13 +129,13 @@ private const rest5 "byteIndex": 58 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "b2", "isDefault": false, "location": { @@ -146,13 +145,13 @@ private const rest5 "byteIndex": 64 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "a3", "isDefault": false, "location": { @@ -162,13 +161,13 @@ private const rest5 "byteIndex": 84 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "b3", "isDefault": false, "location": { @@ -178,13 +177,13 @@ private const rest5 "byteIndex": 96 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "a4", "isDefault": false, "location": { @@ -194,13 +193,13 @@ private const rest5 "byteIndex": 116 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "b4", "isDefault": false, "location": { @@ -210,13 +209,13 @@ private const rest5 "byteIndex": 120 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "rest4", "isDefault": false, "location": { @@ -226,13 +225,13 @@ private const rest5 "byteIndex": 127 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "a5", "isDefault": false, "location": { @@ -242,13 +241,13 @@ private const rest5 "byteIndex": 150 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "b5", "isDefault": false, "location": { @@ -258,13 +257,13 @@ private const rest5 "byteIndex": 156 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "rest5", "isDefault": false, "location": { @@ -274,6 +273,7 @@ private const rest5 "byteIndex": 163 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" diff --git a/tests/specs/destructuring_assignment_object.txt b/tests/specs/destructuring_assignment_object.txt index abe33f79..b3321af4 100644 --- a/tests/specs/destructuring_assignment_object.txt +++ b/tests/specs/destructuring_assignment_object.txt @@ -37,7 +37,6 @@ private const rest # output.json [ { - "kind": "variable", "name": "obj", "isDefault": false, "location": { @@ -47,6 +46,7 @@ private const rest "byteIndex": 6 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -100,7 +100,6 @@ private const rest } }, { - "kind": "variable", "name": "a", "isDefault": false, "location": { @@ -110,13 +109,13 @@ private const rest "byteIndex": 44 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "b", "isDefault": false, "location": { @@ -126,13 +125,13 @@ private const rest "byteIndex": 47 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "rest", "isDefault": false, "location": { @@ -142,13 +141,13 @@ private const rest "byteIndex": 53 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "a1", "isDefault": false, "location": { @@ -158,13 +157,13 @@ private const rest "byteIndex": 78 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "b1", "isDefault": false, "location": { @@ -174,13 +173,13 @@ private const rest "byteIndex": 85 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "a2", "isDefault": false, "location": { @@ -190,6 +189,7 @@ private const rest "byteIndex": 112 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" diff --git a/tests/specs/destructuring_assignment_object_assignment.txt b/tests/specs/destructuring_assignment_object_assignment.txt index bcb5c55e..6c1110e9 100644 --- a/tests/specs/destructuring_assignment_object_assignment.txt +++ b/tests/specs/destructuring_assignment_object_assignment.txt @@ -19,7 +19,6 @@ private const obj: { a: string; b: string; } # output.json [ { - "kind": "variable", "name": "obj", "isDefault": false, "location": { @@ -29,6 +28,7 @@ private const obj: { a: string; b: string; } "byteIndex": 6 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -82,7 +82,6 @@ private const obj: { a: string; b: string; } } }, { - "kind": "variable", "name": "a1", "isDefault": false, "location": { @@ -92,13 +91,13 @@ private const obj: { a: string; b: string; } "byteIndex": 47 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" } }, { - "kind": "variable", "name": "b", "isDefault": false, "location": { @@ -108,6 +107,7 @@ private const obj: { a: string; b: string; } "byteIndex": 57 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": null, "kind": "const" diff --git a/tests/specs/doc_printer_unsupported_tag.txt b/tests/specs/doc_printer_unsupported_tag.txt index e7e44d5e..2ecbf04b 100644 --- a/tests/specs/doc_printer_unsupported_tag.txt +++ b/tests/specs/doc_printer_unsupported_tag.txt @@ -25,7 +25,6 @@ function noop(): void # output.json [ { - "kind": "function", "name": "noop", "isDefault": false, "location": { @@ -47,6 +46,7 @@ function noop(): void } ] }, + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/enum_declaration.txt b/tests/specs/enum_declaration.txt index d77ee47f..25e04a58 100644 --- a/tests/specs/enum_declaration.txt +++ b/tests/specs/enum_declaration.txt @@ -18,7 +18,6 @@ enum Enum # output.json [ { - "kind": "enum", "name": "Enum", "isDefault": false, "location": { @@ -28,6 +27,7 @@ enum Enum "byteIndex": 0 }, "declarationKind": "export", + "kind": "enum", "enumDef": { "members": [] } diff --git a/tests/specs/enum_member.txt b/tests/specs/enum_member.txt index 008c7718..f67115c2 100644 --- a/tests/specs/enum_member.txt +++ b/tests/specs/enum_member.txt @@ -25,7 +25,6 @@ enum Enum # output.json [ { - "kind": "enum", "name": "Enum", "isDefault": false, "location": { @@ -35,6 +34,7 @@ enum Enum "byteIndex": 0 }, "declarationKind": "export", + "kind": "enum", "enumDef": { "members": [ { diff --git a/tests/specs/expando_props/basic.txt b/tests/specs/expando_props/basic.txt index c24aba05..19510684 100644 --- a/tests/specs/expando_props/basic.txt +++ b/tests/specs/expando_props/basic.txt @@ -35,7 +35,6 @@ namespace test # output.json [ { - "kind": "function", "name": "test", "isDefault": false, "location": { @@ -48,6 +47,7 @@ namespace test "jsDoc": { "doc": "Testing" }, + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -62,7 +62,6 @@ namespace test } }, { - "kind": "namespace", "name": "test", "isDefault": false, "location": { @@ -75,10 +74,10 @@ namespace test "jsDoc": { "doc": "Additional properties on the `test` function." }, + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "variable", "name": "skip", "isDefault": false, "location": { @@ -91,6 +90,7 @@ namespace test "jsDoc": { "doc": "doc1" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -121,7 +121,6 @@ namespace test } }, { - "kind": "variable", "name": "textProp", "isDefault": false, "location": { @@ -134,6 +133,7 @@ namespace test "jsDoc": { "doc": "doc2" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "asdf", @@ -147,7 +147,6 @@ namespace test } }, { - "kind": "variable", "name": "booleanProp", "isDefault": false, "location": { @@ -160,6 +159,7 @@ namespace test "jsDoc": { "doc": "doc3" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "true", diff --git a/tests/specs/export_class.txt b/tests/specs/export_class.txt index 4b3cb8f7..2bbebafa 100644 --- a/tests/specs/export_class.txt +++ b/tests/specs/export_class.txt @@ -122,7 +122,6 @@ class Foobar extends Fizz implements Buzz, Aldrin # output.json [ { - "kind": "class", "name": "Foobar", "isDefault": false, "location": { @@ -135,6 +134,7 @@ class Foobar extends Fizz implements Buzz, Aldrin "jsDoc": { "doc": "Class doc" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [ diff --git a/tests/specs/export_class_ctor_properties.txt b/tests/specs/export_class_ctor_properties.txt index 7a36338c..57ae7ac1 100644 --- a/tests/specs/export_class_ctor_properties.txt +++ b/tests/specs/export_class_ctor_properties.txt @@ -28,7 +28,6 @@ class A # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class A "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [ diff --git a/tests/specs/export_class_decorators.txt b/tests/specs/export_class_decorators.txt index cbd2b947..0e85e3eb 100644 --- a/tests/specs/export_class_decorators.txt +++ b/tests/specs/export_class_decorators.txt @@ -86,7 +86,6 @@ class A # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -96,6 +95,7 @@ class A "byteIndex": 8 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/export_class_ignore.txt b/tests/specs/export_class_ignore.txt index 7ccb986d..1278e1f3 100644 --- a/tests/specs/export_class_ignore.txt +++ b/tests/specs/export_class_ignore.txt @@ -86,7 +86,6 @@ class Foobar extends Fizz implements Buzz, Aldrin # output.json [ { - "kind": "class", "name": "Foobar", "isDefault": false, "location": { @@ -99,6 +98,7 @@ class Foobar extends Fizz implements Buzz, Aldrin "jsDoc": { "doc": "Class doc" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/export_class_object_extends.txt b/tests/specs/export_class_object_extends.txt index 8908df37..1fad6905 100644 --- a/tests/specs/export_class_object_extends.txt +++ b/tests/specs/export_class_object_extends.txt @@ -39,7 +39,6 @@ class Bar extends obj.Foo # output.json [ { - "kind": "class", "name": "Bar", "isDefault": false, "location": { @@ -49,6 +48,7 @@ class Bar extends obj.Foo "byteIndex": 38 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -62,7 +62,6 @@ class Bar extends obj.Foo } }, { - "kind": "variable", "name": "obj", "isDefault": false, "location": { @@ -72,6 +71,7 @@ class Bar extends obj.Foo "byteIndex": 19 }, "declarationKind": "private", + "kind": "variable", "variableDef": { "tsType": { "repr": "", diff --git a/tests/specs/export_const_basic.txt b/tests/specs/export_const_basic.txt index 1d5d12d4..dc83bcde 100644 --- a/tests/specs/export_const_basic.txt +++ b/tests/specs/export_const_basic.txt @@ -118,7 +118,6 @@ const tpl2: string # output.json [ { - "kind": "variable", "name": "fizzBuzz", "isDefault": false, "location": { @@ -131,6 +130,7 @@ const tpl2: string "jsDoc": { "doc": "Something about fizzBuzz" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "fizzBuzz", @@ -144,7 +144,6 @@ const tpl2: string } }, { - "kind": "variable", "name": "env", "isDefault": false, "location": { @@ -154,6 +153,7 @@ const tpl2: string "byteIndex": 82 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -256,7 +256,6 @@ const tpl2: string } }, { - "kind": "variable", "name": "num", "isDefault": false, "location": { @@ -266,6 +265,7 @@ const tpl2: string "byteIndex": 221 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "100", @@ -279,7 +279,6 @@ const tpl2: string } }, { - "kind": "variable", "name": "bool", "isDefault": false, "location": { @@ -289,6 +288,7 @@ const tpl2: string "byteIndex": 245 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "false", @@ -302,7 +302,6 @@ const tpl2: string } }, { - "kind": "variable", "name": "bigint", "isDefault": false, "location": { @@ -312,6 +311,7 @@ const tpl2: string "byteIndex": 272 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "123", @@ -325,7 +325,6 @@ const tpl2: string } }, { - "kind": "variable", "name": "regex", "isDefault": false, "location": { @@ -335,6 +334,7 @@ const tpl2: string "byteIndex": 300 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "hello", @@ -348,7 +348,6 @@ const tpl2: string } }, { - "kind": "variable", "name": "date", "isDefault": false, "location": { @@ -358,6 +357,7 @@ const tpl2: string "byteIndex": 330 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "Date", @@ -371,7 +371,6 @@ const tpl2: string } }, { - "kind": "variable", "name": "tpl1", "isDefault": false, "location": { @@ -381,6 +380,7 @@ const tpl2: string "byteIndex": 362 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "foo", @@ -403,7 +403,6 @@ const tpl2: string } }, { - "kind": "variable", "name": "tpl2", "isDefault": false, "location": { @@ -413,6 +412,7 @@ const tpl2: string "byteIndex": 389 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "string", diff --git a/tests/specs/export_const_destructured.txt b/tests/specs/export_const_destructured.txt index 924cd2fb..bb9a7726 100644 --- a/tests/specs/export_const_destructured.txt +++ b/tests/specs/export_const_destructured.txt @@ -53,7 +53,6 @@ const h: number # output.json [ { - "kind": "variable", "name": "a", "isDefault": false, "location": { @@ -66,6 +65,7 @@ const h: number "jsDoc": { "doc": "export a doc" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "string", @@ -76,7 +76,6 @@ const h: number } }, { - "kind": "variable", "name": "b", "isDefault": false, "location": { @@ -89,6 +88,7 @@ const h: number "jsDoc": { "doc": "export b doc" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "number", @@ -99,7 +99,6 @@ const h: number } }, { - "kind": "variable", "name": "f", "isDefault": false, "location": { @@ -109,6 +108,7 @@ const h: number "byteIndex": 250 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "string", @@ -119,7 +119,6 @@ const h: number } }, { - "kind": "variable", "name": "h", "isDefault": false, "location": { @@ -129,6 +128,7 @@ const h: number "byteIndex": 256 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "number", diff --git a/tests/specs/export_declaration_merged_namespace.txt b/tests/specs/export_declaration_merged_namespace.txt index a588f1d4..d77c7d40 100644 --- a/tests/specs/export_declaration_merged_namespace.txt +++ b/tests/specs/export_declaration_merged_namespace.txt @@ -41,7 +41,6 @@ namespace Namespace1 # output.json [ { - "kind": "namespace", "name": "Namespace1", "isDefault": false, "location": { @@ -51,10 +50,10 @@ namespace Namespace1 "byteIndex": 0 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "class", "name": "Test1", "isDefault": false, "location": { @@ -64,6 +63,7 @@ namespace Namespace1 "byteIndex": 25 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -77,7 +77,6 @@ namespace Namespace1 } }, { - "kind": "class", "name": "Test2", "isDefault": false, "location": { @@ -87,6 +86,7 @@ namespace Namespace1 "byteIndex": 74 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/export_default_class.txt b/tests/specs/export_default_class.txt index e7da34aa..a9b2eb1f 100644 --- a/tests/specs/export_default_class.txt +++ b/tests/specs/export_default_class.txt @@ -17,7 +17,6 @@ class default # output.json [ { - "kind": "class", "name": "default", "isDefault": true, "location": { @@ -30,6 +29,7 @@ class default "jsDoc": { "doc": "Class doc" }, + "kind": "class", "classDef": { "defName": "Foobar", "isAbstract": false, diff --git a/tests/specs/export_default_expr.txt b/tests/specs/export_default_expr.txt index 2bd84126..3b90819a 100644 --- a/tests/specs/export_default_expr.txt +++ b/tests/specs/export_default_expr.txt @@ -17,7 +17,6 @@ var default: "foo" # output.json [ { - "kind": "variable", "name": "default", "isDefault": true, "location": { @@ -27,6 +26,7 @@ var default: "foo" "byteIndex": 0 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "foo", diff --git a/tests/specs/export_default_fn.txt b/tests/specs/export_default_fn.txt index 658db171..fd87d9e2 100644 --- a/tests/specs/export_default_fn.txt +++ b/tests/specs/export_default_fn.txt @@ -30,7 +30,6 @@ function default(a: number) # output.json [ { - "kind": "function", "name": "default", "isDefault": true, "location": { @@ -40,6 +39,7 @@ function default(a: number) "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "defName": "foo", "params": [ diff --git a/tests/specs/export_default_interface.txt b/tests/specs/export_default_interface.txt index 873c7e3c..6215dbc5 100644 --- a/tests/specs/export_default_interface.txt +++ b/tests/specs/export_default_interface.txt @@ -19,7 +19,6 @@ interface default # output.json [ { - "kind": "interface", "name": "default", "isDefault": true, "location": { @@ -32,6 +31,7 @@ interface default "jsDoc": { "doc": "Interface js doc" }, + "kind": "interface", "interfaceDef": { "defName": "Reader", "extends": [], diff --git a/tests/specs/export_enum.txt b/tests/specs/export_enum.txt index 61bf4ec0..bc3d685c 100644 --- a/tests/specs/export_enum.txt +++ b/tests/specs/export_enum.txt @@ -25,7 +25,6 @@ enum Hello # output.json [ { - "kind": "enum", "name": "Hello", "isDefault": false, "location": { @@ -38,6 +37,7 @@ enum Hello "jsDoc": { "doc": "Some enum for good measure" }, + "kind": "enum", "enumDef": { "members": [ { diff --git a/tests/specs/export_fn.txt b/tests/specs/export_fn.txt index 2a75e372..38e607cf 100644 --- a/tests/specs/export_fn.txt +++ b/tests/specs/export_fn.txt @@ -35,7 +35,6 @@ function foo(a: string, b?: number, cb: (...cbArgs: unknown[]) => void, ...args: # output.json [ { - "kind": "moduleDoc", "name": "", "location": { "filename": "file:///mod.ts", @@ -50,10 +49,10 @@ function foo(a: string, b?: number, cb: (...cbArgs: unknown[]) => void, ...args: "kind": "module" } ] - } + }, + "kind": "moduleDoc" }, { - "kind": "function", "name": "foo", "isDefault": false, "location": { @@ -66,6 +65,7 @@ function foo(a: string, b?: number, cb: (...cbArgs: unknown[]) => void, ...args: "jsDoc": { "doc": "Hello there, this is a multiline JSdoc.\n\nIt has many lines\n\nOr not that many?" }, + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/export_fn2.txt b/tests/specs/export_fn2.txt index c0bfdc5d..c335b00b 100644 --- a/tests/specs/export_fn2.txt +++ b/tests/specs/export_fn2.txt @@ -43,7 +43,6 @@ private interface AssignOpts # output.json [ { - "kind": "function", "name": "foo", "isDefault": false, "location": { @@ -53,6 +52,7 @@ private interface AssignOpts "byteIndex": 39 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -160,7 +160,6 @@ private interface AssignOpts } }, { - "kind": "interface", "name": "AssignOpts", "isDefault": false, "location": { @@ -170,6 +169,7 @@ private interface AssignOpts "byteIndex": 0 }, "declarationKind": "private", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/export_interface.txt b/tests/specs/export_interface.txt index af8ecfb7..0d8f8243 100644 --- a/tests/specs/export_interface.txt +++ b/tests/specs/export_interface.txt @@ -65,7 +65,6 @@ interface Reader extends Foo, Bar # output.json [ { - "kind": "interface", "name": "Reader", "isDefault": false, "location": { @@ -78,6 +77,7 @@ interface Reader extends Foo, Bar "jsDoc": { "doc": "Interface js doc" }, + "kind": "interface", "interfaceDef": { "extends": [ { @@ -191,7 +191,6 @@ interface Reader extends Foo, Bar } }, { - "kind": "interface", "name": "Foo", "isDefault": false, "location": { @@ -201,6 +200,7 @@ interface Reader extends Foo, Bar "byteIndex": 0 }, "declarationKind": "private", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], @@ -212,7 +212,6 @@ interface Reader extends Foo, Bar } }, { - "kind": "interface", "name": "Bar", "isDefault": false, "location": { @@ -222,6 +221,7 @@ interface Reader extends Foo, Bar "byteIndex": 18 }, "declarationKind": "private", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/export_interface2.txt b/tests/specs/export_interface2.txt index abe08a9d..81c14b7a 100644 --- a/tests/specs/export_interface2.txt +++ b/tests/specs/export_interface2.txt @@ -28,7 +28,6 @@ interface TypedIface # output.json [ { - "kind": "interface", "name": "TypedIface", "isDefault": false, "location": { @@ -38,6 +37,7 @@ interface TypedIface "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/export_interface_accessors.txt b/tests/specs/export_interface_accessors.txt index 3bea39ba..596371eb 100644 --- a/tests/specs/export_interface_accessors.txt +++ b/tests/specs/export_interface_accessors.txt @@ -44,7 +44,6 @@ interface Thing # output.json [ { - "kind": "interface", "name": "Thing", "isDefault": false, "location": { @@ -54,6 +53,7 @@ interface Thing "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/export_let.txt b/tests/specs/export_let.txt index 7a010b04..31a11def 100644 --- a/tests/specs/export_let.txt +++ b/tests/specs/export_let.txt @@ -89,7 +89,6 @@ let tpl: `foobarbaz` # output.json [ { - "kind": "variable", "name": "str", "isDefault": false, "location": { @@ -99,6 +98,7 @@ let tpl: `foobarbaz` "byteIndex": 11 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "string", @@ -109,7 +109,6 @@ let tpl: `foobarbaz` } }, { - "kind": "variable", "name": "num", "isDefault": false, "location": { @@ -119,6 +118,7 @@ let tpl: `foobarbaz` "byteIndex": 37 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "number", @@ -129,7 +129,6 @@ let tpl: `foobarbaz` } }, { - "kind": "variable", "name": "bool", "isDefault": false, "location": { @@ -139,6 +138,7 @@ let tpl: `foobarbaz` "byteIndex": 59 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "boolean", @@ -149,7 +149,6 @@ let tpl: `foobarbaz` } }, { - "kind": "variable", "name": "dateStr", "isDefault": false, "location": { @@ -159,6 +158,7 @@ let tpl: `foobarbaz` "byteIndex": 84 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "Date", @@ -169,7 +169,6 @@ let tpl: `foobarbaz` } }, { - "kind": "variable", "name": "regex", "isDefault": false, "location": { @@ -179,6 +178,7 @@ let tpl: `foobarbaz` "byteIndex": 113 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "RegExp", @@ -192,7 +192,6 @@ let tpl: `foobarbaz` } }, { - "kind": "variable", "name": "sym", "isDefault": false, "location": { @@ -202,6 +201,7 @@ let tpl: `foobarbaz` "byteIndex": 150 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "Symbol", @@ -212,7 +212,6 @@ let tpl: `foobarbaz` } }, { - "kind": "variable", "name": "tpl", "isDefault": false, "location": { @@ -222,6 +221,7 @@ let tpl: `foobarbaz` "byteIndex": 182 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "foobarbaz", diff --git a/tests/specs/export_namespace.txt b/tests/specs/export_namespace.txt index d7d88e26..ebecb5e9 100644 --- a/tests/specs/export_namespace.txt +++ b/tests/specs/export_namespace.txt @@ -60,7 +60,6 @@ namespace RootNs # output.json [ { - "kind": "namespace", "name": "RootNs", "isDefault": false, "location": { @@ -73,10 +72,10 @@ namespace RootNs "jsDoc": { "doc": "Namespace JSdoc" }, + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "variable", "name": "a", "isDefault": false, "location": { @@ -86,6 +85,7 @@ namespace RootNs "byteIndex": 66 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "a", @@ -99,7 +99,6 @@ namespace RootNs } }, { - "kind": "namespace", "name": "NestedNs", "isDefault": false, "location": { @@ -112,10 +111,10 @@ namespace RootNs "jsDoc": { "doc": "Nested namespace JSDoc" }, + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "enum", "name": "Foo", "isDefault": false, "location": { @@ -125,6 +124,7 @@ namespace RootNs "byteIndex": 148 }, "declarationKind": "export", + "kind": "enum", "enumDef": { "members": [ { @@ -185,7 +185,6 @@ namespace RootNs } }, { - "kind": "namespace", "name": "OtherNs", "isDefault": false, "location": { @@ -195,10 +194,10 @@ namespace RootNs "byteIndex": 235 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "class", "name": "Other", "isDefault": false, "location": { @@ -208,6 +207,7 @@ namespace RootNs "byteIndex": 264 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/export_namespace_enum_same_name.txt b/tests/specs/export_namespace_enum_same_name.txt index fd89b816..5b0e327b 100644 --- a/tests/specs/export_namespace_enum_same_name.txt +++ b/tests/specs/export_namespace_enum_same_name.txt @@ -49,7 +49,6 @@ namespace RootNs # output.json [ { - "kind": "namespace", "name": "RootNs", "isDefault": false, "location": { @@ -59,10 +58,10 @@ namespace RootNs "byteIndex": 0 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "namespace", "name": "NestedNs", "isDefault": false, "location": { @@ -72,10 +71,10 @@ namespace RootNs "byteIndex": 28 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "enum", "name": "Foo", "isDefault": false, "location": { @@ -85,6 +84,7 @@ namespace RootNs "byteIndex": 60 }, "declarationKind": "export", + "kind": "enum", "enumDef": { "members": [] } @@ -93,7 +93,6 @@ namespace RootNs } }, { - "kind": "enum", "name": "Foo", "isDefault": false, "location": { @@ -103,6 +102,7 @@ namespace RootNs "byteIndex": 91 }, "declarationKind": "export", + "kind": "enum", "enumDef": { "members": [] } diff --git a/tests/specs/export_private.txt b/tests/specs/export_private.txt index 08c0d6f1..6d648f88 100644 --- a/tests/specs/export_private.txt +++ b/tests/specs/export_private.txt @@ -19,7 +19,6 @@ const foo: string # output.json [ { - "kind": "variable", "name": "foo", "isDefault": false, "location": { @@ -29,6 +28,7 @@ const foo: string "byteIndex": 6 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "string", diff --git a/tests/specs/export_type_alias.txt b/tests/specs/export_type_alias.txt index ba9dfc5e..ffdb7227 100644 --- a/tests/specs/export_type_alias.txt +++ b/tests/specs/export_type_alias.txt @@ -11,7 +11,6 @@ type NumberArray = Array # output.json [ { - "kind": "typeAlias", "name": "NumberArray", "isDefault": false, "location": { @@ -24,6 +23,7 @@ type NumberArray = Array "jsDoc": { "doc": "Array holding numbers" }, + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "Array", diff --git a/tests/specs/export_type_alias_literal.txt b/tests/specs/export_type_alias_literal.txt index f6cc8237..6fa0cb3a 100644 --- a/tests/specs/export_type_alias_literal.txt +++ b/tests/specs/export_type_alias_literal.txt @@ -23,7 +23,6 @@ type A = { a(): void; b?(): void; c(): string; c(v: number); } # output.json [ { - "kind": "typeAlias", "name": "A", "isDefault": false, "location": { @@ -33,6 +32,7 @@ type A = { a(): void; b?(): void; c(): string; c(v: number); } "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "", diff --git a/tests/specs/exports_all_with_private.txt b/tests/specs/exports_all_with_private.txt index f85e6ce5..465291c2 100644 --- a/tests/specs/exports_all_with_private.txt +++ b/tests/specs/exports_all_with_private.txt @@ -80,7 +80,6 @@ private namespace H # output.json [ { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -90,6 +89,7 @@ private namespace H "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -104,7 +104,6 @@ private namespace H } }, { - "kind": "class", "name": "C", "isDefault": false, "location": { @@ -114,6 +113,7 @@ private namespace H "byteIndex": 39 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -127,7 +127,6 @@ private namespace H } }, { - "kind": "interface", "name": "E", "isDefault": false, "location": { @@ -137,6 +136,7 @@ private namespace H "byteIndex": 68 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], @@ -148,7 +148,6 @@ private namespace H } }, { - "kind": "namespace", "name": "G", "isDefault": false, "location": { @@ -158,12 +157,12 @@ private namespace H "byteIndex": 105 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [] } }, { - "kind": "function", "name": "b", "isDefault": false, "location": { @@ -173,6 +172,7 @@ private namespace H "byteIndex": 23 }, "declarationKind": "private", + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -187,7 +187,6 @@ private namespace H } }, { - "kind": "class", "name": "D", "isDefault": false, "location": { @@ -197,6 +196,7 @@ private namespace H "byteIndex": 57 }, "declarationKind": "private", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -210,7 +210,6 @@ private namespace H } }, { - "kind": "interface", "name": "F", "isDefault": false, "location": { @@ -220,6 +219,7 @@ private namespace H "byteIndex": 90 }, "declarationKind": "private", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], @@ -231,7 +231,6 @@ private namespace H } }, { - "kind": "namespace", "name": "H", "isDefault": false, "location": { @@ -241,6 +240,7 @@ private namespace H "byteIndex": 127 }, "declarationKind": "private", + "kind": "namespace", "namespaceDef": { "elements": [] } diff --git a/tests/specs/exports_declared_earlier.txt b/tests/specs/exports_declared_earlier.txt index 4a6daff0..37eff469 100644 --- a/tests/specs/exports_declared_earlier.txt +++ b/tests/specs/exports_declared_earlier.txt @@ -42,7 +42,6 @@ const hello: "world" # output.json [ { - "kind": "variable", "name": "hello", "isDefault": false, "location": { @@ -52,6 +51,7 @@ const hello: "world" "byteIndex": 6 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "world", @@ -65,7 +65,6 @@ const hello: "world" } }, { - "kind": "function", "name": "say", "isDefault": false, "location": { @@ -75,6 +74,7 @@ const hello: "world" "byteIndex": 23 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -100,7 +100,6 @@ const hello: "world" } }, { - "kind": "function", "name": "bar", "isDefault": false, "location": { @@ -110,6 +109,7 @@ const hello: "world" "byteIndex": 61 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/function_array_deconstruction.txt b/tests/specs/function_array_deconstruction.txt index f0df955a..37c69f18 100644 --- a/tests/specs/function_array_deconstruction.txt +++ b/tests/specs/function_array_deconstruction.txt @@ -17,7 +17,6 @@ function f([a, b, ...c]): void # output.json [ { - "kind": "function", "name": "f", "isDefault": false, "location": { @@ -27,6 +26,7 @@ function f([a, b, ...c]): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/function_async.txt b/tests/specs/function_async.txt index 9c1383d5..259f4404 100644 --- a/tests/specs/function_async.txt +++ b/tests/specs/function_async.txt @@ -19,7 +19,6 @@ async function a(): Promise # output.json [ { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -29,6 +28,7 @@ async function a(): Promise "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/function_async_generator.txt b/tests/specs/function_async_generator.txt index d3c7662e..b6bea4bd 100644 --- a/tests/specs/function_async_generator.txt +++ b/tests/specs/function_async_generator.txt @@ -24,7 +24,6 @@ async function* ag() # output.json [ { - "kind": "function", "name": "ag", "isDefault": false, "location": { @@ -34,6 +33,7 @@ async function* ag() "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": null, diff --git a/tests/specs/function_declaration.txt b/tests/specs/function_declaration.txt index f0fa5856..ed8e9484 100644 --- a/tests/specs/function_declaration.txt +++ b/tests/specs/function_declaration.txt @@ -17,7 +17,6 @@ function fun(): void # output.json [ { - "kind": "function", "name": "fun", "isDefault": false, "location": { @@ -27,6 +26,7 @@ function fun(): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/function_generator.txt b/tests/specs/function_generator.txt index f3f24661..194490cd 100644 --- a/tests/specs/function_generator.txt +++ b/tests/specs/function_generator.txt @@ -24,7 +24,6 @@ function* g() # output.json [ { - "kind": "function", "name": "g", "isDefault": false, "location": { @@ -34,6 +33,7 @@ function* g() "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": null, diff --git a/tests/specs/function_generic.txt b/tests/specs/function_generic.txt index 60d69465..76ef0dd0 100644 --- a/tests/specs/function_generic.txt +++ b/tests/specs/function_generic.txt @@ -24,7 +24,6 @@ function add(a: T, b: T) # output.json [ { - "kind": "function", "name": "add", "isDefault": false, "location": { @@ -34,6 +33,7 @@ function add(a: T, b: T) "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/function_object_deconstruction.txt b/tests/specs/function_object_deconstruction.txt index 0df6f68f..1de678a3 100644 --- a/tests/specs/function_object_deconstruction.txt +++ b/tests/specs/function_object_deconstruction.txt @@ -17,7 +17,6 @@ function f({a, b, ...c}): void # output.json [ { - "kind": "function", "name": "f", "isDefault": false, "location": { @@ -27,6 +26,7 @@ function f({a, b, ...c}): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/function_overloads.txt b/tests/specs/function_overloads.txt index 79e36b38..f8bf4b7f 100644 --- a/tests/specs/function_overloads.txt +++ b/tests/specs/function_overloads.txt @@ -31,7 +31,6 @@ function a(b: number): number # output.json [ { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -41,6 +40,7 @@ function a(b: number): number "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -65,7 +65,6 @@ function a(b: number): number } }, { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -75,6 +74,7 @@ function a(b: number): number "byteIndex": 38 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -99,7 +99,6 @@ function a(b: number): number } }, { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -109,6 +108,7 @@ function a(b: number): number "byteIndex": 76 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/generic_instantiated_with_tuple_type.txt b/tests/specs/generic_instantiated_with_tuple_type.txt index 32b06421..cae97c93 100644 --- a/tests/specs/generic_instantiated_with_tuple_type.txt +++ b/tests/specs/generic_instantiated_with_tuple_type.txt @@ -30,7 +30,6 @@ interface Generic # output.json [ { - "kind": "interface", "name": "Generic", "isDefault": false, "location": { @@ -40,6 +39,7 @@ interface Generic "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], @@ -55,7 +55,6 @@ interface Generic } }, { - "kind": "function", "name": "f", "isDefault": false, "location": { @@ -65,6 +64,7 @@ interface Generic "byteIndex": 31 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/import_equals.txt b/tests/specs/import_equals.txt index 4e98cfc5..f954f5a4 100644 --- a/tests/specs/import_equals.txt +++ b/tests/specs/import_equals.txt @@ -25,7 +25,6 @@ interface Options # output.json [ { - "kind": "interface", "name": "Options", "isDefault": false, "location": { @@ -35,6 +34,7 @@ interface Options "byteIndex": 24 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/import_types.txt b/tests/specs/import_types.txt index bf8c9c14..a8b297aa 100644 --- a/tests/specs/import_types.txt +++ b/tests/specs/import_types.txt @@ -19,7 +19,6 @@ function adopt(p: import("./module.ts").Pet): void # output.json [ { - "kind": "function", "name": "adopt", "isDefault": false, "location": { @@ -29,6 +28,7 @@ function adopt(p: import("./module.ts").Pet): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/indented_with_tabs.txt b/tests/specs/indented_with_tabs.txt index c0159b0c..8815131c 100644 --- a/tests/specs/indented_with_tabs.txt +++ b/tests/specs/indented_with_tabs.txt @@ -46,7 +46,6 @@ namespace Tabs # output.json [ { - "kind": "namespace", "name": "Tabs", "isDefault": false, "location": { @@ -59,10 +58,10 @@ namespace Tabs "jsDoc": { "doc": "Line 1\n\nLine 2\n\n\tIndented" }, + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "interface", "name": "Tabs", "isDefault": false, "location": { @@ -75,6 +74,7 @@ namespace Tabs "jsDoc": { "doc": "Line 1\n\nLine 2\n\n\tIndented" }, + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/infer_function_assignment.txt b/tests/specs/infer_function_assignment.txt index 3ec872a7..d5f17b79 100644 --- a/tests/specs/infer_function_assignment.txt +++ b/tests/specs/infer_function_assignment.txt @@ -17,7 +17,6 @@ function foo(n: number, b: string): void # output.json [ { - "kind": "function", "name": "foo", "isDefault": false, "location": { @@ -27,6 +26,7 @@ function foo(n: number, b: string): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/infer_object_literal.txt b/tests/specs/infer_object_literal.txt index 576f9c4e..eb41a87e 100644 --- a/tests/specs/infer_object_literal.txt +++ b/tests/specs/infer_object_literal.txt @@ -34,7 +34,6 @@ const a: { d(e: string): void; h(): string; h(value: string); [[t]](u: string): # output.json [ { - "kind": "variable", "name": "a", "isDefault": false, "location": { @@ -44,6 +43,7 @@ const a: { d(e: string): void; h(): string; h(value: string); [[t]](u: string): "byteIndex": 84 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", diff --git a/tests/specs/infer_object_literal_satifies.txt b/tests/specs/infer_object_literal_satifies.txt index 887c924a..ccb5905c 100644 --- a/tests/specs/infer_object_literal_satifies.txt +++ b/tests/specs/infer_object_literal_satifies.txt @@ -50,7 +50,6 @@ type Colors = "red" | "green" | "blue" # output.json [ { - "kind": "typeAlias", "name": "Colors", "isDefault": false, "location": { @@ -60,6 +59,7 @@ type Colors = "red" | "green" | "blue" "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "", @@ -95,7 +95,6 @@ type Colors = "red" | "green" | "blue" } }, { - "kind": "variable", "name": "favoriteColors", "isDefault": false, "location": { @@ -105,6 +104,7 @@ type Colors = "red" | "green" | "blue" "byteIndex": 116 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -194,7 +194,6 @@ type Colors = "red" | "green" | "blue" } }, { - "kind": "variable", "name": "g", "isDefault": false, "location": { @@ -204,6 +203,7 @@ type Colors = "red" | "green" | "blue" "byteIndex": 331 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "boolean", diff --git a/tests/specs/infer_simple_ts_arr_types.txt b/tests/specs/infer_simple_ts_arr_types.txt index 82a26520..9ec4aab9 100644 --- a/tests/specs/infer_simple_ts_arr_types.txt +++ b/tests/specs/infer_simple_ts_arr_types.txt @@ -89,7 +89,6 @@ const g: ("a" | 1 | true)[] # output.json [ { - "kind": "variable", "name": "a", "isDefault": false, "location": { @@ -99,6 +98,7 @@ const g: ("a" | 1 | true)[] "byteIndex": 13 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -113,7 +113,6 @@ const g: ("a" | 1 | true)[] } }, { - "kind": "variable", "name": "b", "isDefault": false, "location": { @@ -123,6 +122,7 @@ const g: ("a" | 1 | true)[] "byteIndex": 41 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -137,7 +137,6 @@ const g: ("a" | 1 | true)[] } }, { - "kind": "variable", "name": "c", "isDefault": false, "location": { @@ -147,6 +146,7 @@ const g: ("a" | 1 | true)[] "byteIndex": 72 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -161,7 +161,6 @@ const g: ("a" | 1 | true)[] } }, { - "kind": "variable", "name": "d", "isDefault": false, "location": { @@ -171,6 +170,7 @@ const g: ("a" | 1 | true)[] "byteIndex": 102 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -196,7 +196,6 @@ const g: ("a" | 1 | true)[] } }, { - "kind": "variable", "name": "e", "isDefault": false, "location": { @@ -206,6 +205,7 @@ const g: ("a" | 1 | true)[] "byteIndex": 135 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -220,7 +220,6 @@ const g: ("a" | 1 | true)[] } }, { - "kind": "variable", "name": "f", "isDefault": false, "location": { @@ -230,6 +229,7 @@ const g: ("a" | 1 | true)[] "byteIndex": 169 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "any[]", @@ -244,7 +244,6 @@ const g: ("a" | 1 | true)[] } }, { - "kind": "variable", "name": "g", "isDefault": false, "location": { @@ -254,6 +253,7 @@ const g: ("a" | 1 | true)[] "byteIndex": 205 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", diff --git a/tests/specs/infer_simple_ts_types.txt b/tests/specs/infer_simple_ts_types.txt index e83ed787..451c4e7e 100644 --- a/tests/specs/infer_simple_ts_types.txt +++ b/tests/specs/infer_simple_ts_types.txt @@ -185,7 +185,6 @@ const tpl: `foobar` # output.json [ { - "kind": "variable", "name": "s", "isDefault": false, "location": { @@ -195,6 +194,7 @@ const tpl: `foobar` "byteIndex": 13 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "hello", @@ -208,7 +208,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "n", "isDefault": false, "location": { @@ -218,6 +217,7 @@ const tpl: `foobar` "byteIndex": 39 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "123", @@ -231,7 +231,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "b", "isDefault": false, "location": { @@ -241,6 +240,7 @@ const tpl: `foobar` "byteIndex": 61 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "false", @@ -254,7 +254,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "bi", "isDefault": false, "location": { @@ -264,6 +263,7 @@ const tpl: `foobar` "byteIndex": 85 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "100", @@ -277,7 +277,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "re", "isDefault": false, "location": { @@ -287,6 +286,7 @@ const tpl: `foobar` "byteIndex": 109 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "hello", @@ -300,7 +300,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "tpl", "isDefault": false, "location": { @@ -310,6 +309,7 @@ const tpl: `foobar` "byteIndex": 136 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "foobar", @@ -332,7 +332,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "d", "isDefault": false, "location": { @@ -342,6 +341,7 @@ const tpl: `foobar` "byteIndex": 165 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "Date", @@ -355,7 +355,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "s2", "isDefault": false, "location": { @@ -365,6 +364,7 @@ const tpl: `foobar` "byteIndex": 194 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "String", @@ -375,7 +375,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "n2", "isDefault": false, "location": { @@ -385,6 +384,7 @@ const tpl: `foobar` "byteIndex": 227 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "Number", @@ -395,7 +395,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "bi2", "isDefault": false, "location": { @@ -405,6 +404,7 @@ const tpl: `foobar` "byteIndex": 258 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "BigInt", @@ -415,7 +415,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "sym", "isDefault": false, "location": { @@ -425,6 +424,7 @@ const tpl: `foobar` "byteIndex": 290 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "Symbol", @@ -435,7 +435,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "m", "isDefault": false, "location": { @@ -445,6 +444,7 @@ const tpl: `foobar` "byteIndex": 326 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "Map", @@ -469,7 +469,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "fn1", "isDefault": false, "location": { @@ -479,6 +478,7 @@ const tpl: `foobar` "byteIndex": 370 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -509,7 +509,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "fn2", "isDefault": false, "location": { @@ -519,6 +518,7 @@ const tpl: `foobar` "byteIndex": 414 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -549,7 +549,6 @@ const tpl: `foobar` } }, { - "kind": "variable", "name": "s3", "isDefault": false, "location": { @@ -559,6 +558,7 @@ const tpl: `foobar` "byteIndex": 463 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "string", diff --git a/tests/specs/infer_ts_types.txt b/tests/specs/infer_ts_types.txt index 1b0a23f5..01df5e46 100644 --- a/tests/specs/infer_ts_types.txt +++ b/tests/specs/infer_ts_types.txt @@ -313,7 +313,6 @@ namespace MyNamespace # output.json [ { - "kind": "variable", "name": "s", "isDefault": false, "location": { @@ -323,6 +322,7 @@ namespace MyNamespace "byteIndex": 11 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "string", @@ -333,7 +333,6 @@ namespace MyNamespace } }, { - "kind": "variable", "name": "n", "isDefault": false, "location": { @@ -343,6 +342,7 @@ namespace MyNamespace "byteIndex": 35 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "number", @@ -353,7 +353,6 @@ namespace MyNamespace } }, { - "kind": "variable", "name": "b", "isDefault": false, "location": { @@ -363,6 +362,7 @@ namespace MyNamespace "byteIndex": 55 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "boolean", @@ -373,7 +373,6 @@ namespace MyNamespace } }, { - "kind": "variable", "name": "bi", "isDefault": false, "location": { @@ -383,6 +382,7 @@ namespace MyNamespace "byteIndex": 77 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "bigint", @@ -393,7 +393,6 @@ namespace MyNamespace } }, { - "kind": "variable", "name": "re", "isDefault": false, "location": { @@ -403,6 +402,7 @@ namespace MyNamespace "byteIndex": 99 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "hello", @@ -416,7 +416,6 @@ namespace MyNamespace } }, { - "kind": "variable", "name": "tpl", "isDefault": false, "location": { @@ -426,6 +425,7 @@ namespace MyNamespace "byteIndex": 124 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "foobar", @@ -448,7 +448,6 @@ namespace MyNamespace } }, { - "kind": "variable", "name": "complexTpl", "isDefault": false, "location": { @@ -458,6 +457,7 @@ namespace MyNamespace "byteIndex": 151 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "f${string | number}${string | null}o${string}${number}o", @@ -554,7 +554,6 @@ namespace MyNamespace } }, { - "kind": "function", "name": "test", "isDefault": false, "location": { @@ -564,6 +563,7 @@ namespace MyNamespace "byteIndex": 219 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -578,7 +578,6 @@ namespace MyNamespace } }, { - "kind": "function", "name": "testAsync", "isDefault": false, "location": { @@ -588,6 +587,7 @@ namespace MyNamespace "byteIndex": 271 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -611,7 +611,6 @@ namespace MyNamespace } }, { - "kind": "function", "name": "cannotInfer", "isDefault": false, "location": { @@ -621,6 +620,7 @@ namespace MyNamespace "byteIndex": 338 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": null, @@ -631,7 +631,6 @@ namespace MyNamespace } }, { - "kind": "function", "name": "cannotInferAsync", "isDefault": false, "location": { @@ -641,6 +640,7 @@ namespace MyNamespace "byteIndex": 415 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": null, @@ -651,7 +651,6 @@ namespace MyNamespace } }, { - "kind": "function", "name": "cannotInferGenerator", "isDefault": false, "location": { @@ -661,6 +660,7 @@ namespace MyNamespace "byteIndex": 525 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": null, @@ -671,7 +671,6 @@ namespace MyNamespace } }, { - "kind": "class", "name": "MyClass", "isDefault": false, "location": { @@ -681,6 +680,7 @@ namespace MyNamespace "byteIndex": 570 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -822,7 +822,6 @@ namespace MyNamespace } }, { - "kind": "namespace", "name": "MyNamespace", "isDefault": false, "location": { @@ -832,10 +831,10 @@ namespace MyNamespace "byteIndex": 825 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "function", "name": "cannotInfer", "isDefault": false, "location": { @@ -845,6 +844,7 @@ namespace MyNamespace "byteIndex": 909 }, "declarationKind": "declare", + "kind": "function", "functionDef": { "params": [], "returnType": null, diff --git a/tests/specs/infer_types.txt b/tests/specs/infer_types.txt index 04129e4a..04930214 100644 --- a/tests/specs/infer_types.txt +++ b/tests/specs/infer_types.txt @@ -17,7 +17,6 @@ type Flatten = T extends Array ? U : T # output.json [ { - "kind": "typeAlias", "name": "Flatten", "isDefault": false, "location": { @@ -27,6 +26,7 @@ type Flatten = T extends Array ? U : T "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "", diff --git a/tests/specs/infer_variable.txt b/tests/specs/infer_variable.txt index 64d2d8f2..dada344c 100644 --- a/tests/specs/infer_variable.txt +++ b/tests/specs/infer_variable.txt @@ -82,7 +82,6 @@ const k: (value: string) => unknown # output.json [ { - "kind": "variable", "name": "a", "isDefault": false, "location": { @@ -95,6 +94,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc1" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "number", @@ -105,7 +105,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "b", "isDefault": false, "location": { @@ -118,6 +117,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc2" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "number", @@ -128,7 +128,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "c", "isDefault": false, "location": { @@ -141,6 +140,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc3" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "string", @@ -151,7 +151,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "d", "isDefault": false, "location": { @@ -164,6 +163,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc4" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "string", @@ -174,7 +174,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "e", "isDefault": false, "location": { @@ -187,6 +186,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc5" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -200,7 +200,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "f", "isDefault": false, "location": { @@ -213,6 +212,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc6" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "", @@ -240,7 +240,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "g", "isDefault": false, "location": { @@ -253,6 +252,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc7" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "a", @@ -266,7 +266,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "h", "isDefault": false, "location": { @@ -279,6 +278,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc8" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "never", @@ -289,7 +289,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "i", "isDefault": false, "location": { @@ -302,6 +301,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc9" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "boolean", @@ -312,7 +312,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "j", "isDefault": false, "location": { @@ -325,6 +324,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc10" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "number", @@ -335,7 +335,6 @@ const k: (value: string) => unknown } }, { - "kind": "variable", "name": "k", "isDefault": false, "location": { @@ -348,6 +347,7 @@ const k: (value: string) => unknown "jsDoc": { "doc": "doc11" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "", diff --git a/tests/specs/interface_construct.txt b/tests/specs/interface_construct.txt index c84f9459..05efc970 100644 --- a/tests/specs/interface_construct.txt +++ b/tests/specs/interface_construct.txt @@ -35,7 +35,6 @@ interface I # output.json [ { - "kind": "interface", "name": "I", "isDefault": false, "location": { @@ -45,6 +44,7 @@ interface I "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [ diff --git a/tests/specs/interface_declaration.txt b/tests/specs/interface_declaration.txt index 6a8fd125..0d2f2f5c 100644 --- a/tests/specs/interface_declaration.txt +++ b/tests/specs/interface_declaration.txt @@ -18,7 +18,6 @@ interface Interface # output.json [ { - "kind": "interface", "name": "Interface", "isDefault": false, "location": { @@ -28,6 +27,7 @@ interface Interface "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/interface_extends.txt b/tests/specs/interface_extends.txt index 41a5eb2d..b4efb810 100644 --- a/tests/specs/interface_extends.txt +++ b/tests/specs/interface_extends.txt @@ -18,7 +18,6 @@ interface Interface extends Iterator # output.json [ { - "kind": "interface", "name": "Interface", "isDefault": false, "location": { @@ -28,6 +27,7 @@ interface Interface extends Iterator "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [ { diff --git a/tests/specs/interface_extends2.txt b/tests/specs/interface_extends2.txt index 5b239550..a9af726a 100644 --- a/tests/specs/interface_extends2.txt +++ b/tests/specs/interface_extends2.txt @@ -18,7 +18,6 @@ interface Interface extends Iterator, Iterable # output.json [ { - "kind": "interface", "name": "Interface", "isDefault": false, "location": { @@ -28,6 +27,7 @@ interface Interface extends Iterator, Iterable "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [ { diff --git a/tests/specs/interface_generic.txt b/tests/specs/interface_generic.txt index a087e6c7..802acf19 100644 --- a/tests/specs/interface_generic.txt +++ b/tests/specs/interface_generic.txt @@ -18,7 +18,6 @@ interface Interface # output.json [ { - "kind": "interface", "name": "Interface", "isDefault": false, "location": { @@ -28,6 +27,7 @@ interface Interface "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/interface_generic_extends.txt b/tests/specs/interface_generic_extends.txt index 5a13ebf6..733090dc 100644 --- a/tests/specs/interface_generic_extends.txt +++ b/tests/specs/interface_generic_extends.txt @@ -18,7 +18,6 @@ interface Interface extends Iterable # output.json [ { - "kind": "interface", "name": "Interface", "isDefault": false, "location": { @@ -28,6 +27,7 @@ interface Interface extends Iterable "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [ { diff --git a/tests/specs/interface_index_signature.txt b/tests/specs/interface_index_signature.txt index 3fbd85b7..5b4ddcf3 100644 --- a/tests/specs/interface_index_signature.txt +++ b/tests/specs/interface_index_signature.txt @@ -28,7 +28,6 @@ interface Interface # output.json [ { - "kind": "interface", "name": "Interface", "isDefault": false, "location": { @@ -38,6 +37,7 @@ interface Interface "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/interface_method.txt b/tests/specs/interface_method.txt index 8fec4835..8db8e01a 100644 --- a/tests/specs/interface_method.txt +++ b/tests/specs/interface_method.txt @@ -67,7 +67,6 @@ interface I # output.json [ { - "kind": "interface", "name": "I", "isDefault": false, "location": { @@ -77,6 +76,7 @@ interface I "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/interface_number_literal_property.txt b/tests/specs/interface_number_literal_property.txt index 31d61b31..e47cbe5c 100644 --- a/tests/specs/interface_number_literal_property.txt +++ b/tests/specs/interface_number_literal_property.txt @@ -37,7 +37,6 @@ interface I # output.json [ { - "kind": "interface", "name": "I", "isDefault": false, "location": { @@ -47,6 +46,7 @@ interface I "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/interface_property.txt b/tests/specs/interface_property.txt index cf5557fa..64989cdc 100644 --- a/tests/specs/interface_property.txt +++ b/tests/specs/interface_property.txt @@ -55,7 +55,6 @@ interface I # output.json [ { - "kind": "interface", "name": "I", "isDefault": false, "location": { @@ -65,6 +64,7 @@ interface I "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/interface_readonly_index_signature.txt b/tests/specs/interface_readonly_index_signature.txt index f8f54734..c02166ba 100644 --- a/tests/specs/interface_readonly_index_signature.txt +++ b/tests/specs/interface_readonly_index_signature.txt @@ -28,7 +28,6 @@ interface Interface # output.json [ { - "kind": "interface", "name": "Interface", "isDefault": false, "location": { @@ -38,6 +37,7 @@ interface Interface "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/interface_string_literal_property.txt b/tests/specs/interface_string_literal_property.txt index 0c6c0aa2..2eff5c21 100644 --- a/tests/specs/interface_string_literal_property.txt +++ b/tests/specs/interface_string_literal_property.txt @@ -37,7 +37,6 @@ interface I # output.json [ { - "kind": "interface", "name": "I", "isDefault": false, "location": { @@ -47,6 +46,7 @@ interface I "byteIndex": 0 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/internal_tag.txt b/tests/specs/internal_tag.txt index 44bd6d2f..9c7dd05d 100644 --- a/tests/specs/internal_tag.txt +++ b/tests/specs/internal_tag.txt @@ -78,7 +78,6 @@ type Test = OtherPrivateType # output.json [ { - "kind": "class", "name": "MyClass", "isDefault": false, "location": { @@ -95,6 +94,7 @@ type Test = OtherPrivateType } ] }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -169,7 +169,6 @@ type Test = OtherPrivateType } }, { - "kind": "class", "name": "Other", "isDefault": false, "location": { @@ -182,6 +181,7 @@ type Test = OtherPrivateType "jsDoc": { "doc": "Test" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -248,7 +248,6 @@ type Test = OtherPrivateType } }, { - "kind": "typeAlias", "name": "Test", "isDefault": false, "location": { @@ -258,6 +257,7 @@ type Test = OtherPrivateType "byteIndex": 480 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "OtherPrivateType", @@ -271,7 +271,6 @@ type Test = OtherPrivateType } }, { - "kind": "typeAlias", "name": "PrivateType", "isDefault": false, "location": { @@ -288,6 +287,7 @@ type Test = OtherPrivateType } ] }, + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "string", diff --git a/tests/specs/jsdoc_tags.txt b/tests/specs/jsdoc_tags.txt index e7af06db..beca8ed0 100644 --- a/tests/specs/jsdoc_tags.txt +++ b/tests/specs/jsdoc_tags.txt @@ -44,7 +44,6 @@ function a(b, c, d): void # output.json [ { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -97,6 +96,7 @@ function a(b, c, d): void } ] }, + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/mapped_types.txt b/tests/specs/mapped_types.txt index 54e145f3..9b82ad26 100644 --- a/tests/specs/mapped_types.txt +++ b/tests/specs/mapped_types.txt @@ -19,7 +19,6 @@ type MappedTypeWithNewProperties = readonly [Properties in keyof Type as N # output.json [ { - "kind": "typeAlias", "name": "MappedTypeWithNewProperties", "isDefault": false, "location": { @@ -29,6 +28,7 @@ type MappedTypeWithNewProperties = readonly [Properties in keyof Type as N "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "", diff --git a/tests/specs/module_docs.txt b/tests/specs/module_docs.txt index d40d6455..57df1ded 100644 --- a/tests/specs/module_docs.txt +++ b/tests/specs/module_docs.txt @@ -26,7 +26,6 @@ class A # output.json [ { - "kind": "moduleDoc", "name": "", "location": { "filename": "file:///mod.ts", @@ -42,10 +41,10 @@ class A "kind": "module" } ] - } + }, + "kind": "moduleDoc" }, { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -58,6 +57,7 @@ class A "jsDoc": { "doc": "One associated with a class" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/module_docs_ignore_no_module_tag.txt b/tests/specs/module_docs_ignore_no_module_tag.txt index b1b7702c..d8e13495 100644 --- a/tests/specs/module_docs_ignore_no_module_tag.txt +++ b/tests/specs/module_docs_ignore_no_module_tag.txt @@ -19,7 +19,6 @@ class A # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -32,6 +31,7 @@ class A "jsDoc": { "doc": "One associated with a class" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/namespace_declaration.txt b/tests/specs/namespace_declaration.txt index d5406593..5c4edf9d 100644 --- a/tests/specs/namespace_declaration.txt +++ b/tests/specs/namespace_declaration.txt @@ -18,7 +18,6 @@ namespace Namespace # output.json [ { - "kind": "namespace", "name": "Namespace", "isDefault": false, "location": { @@ -28,6 +27,7 @@ namespace Namespace "byteIndex": 0 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [] } diff --git a/tests/specs/namespace_details.txt b/tests/specs/namespace_details.txt index 152b63b7..6ab55efa 100644 --- a/tests/specs/namespace_details.txt +++ b/tests/specs/namespace_details.txt @@ -39,7 +39,6 @@ namespace Namespace # output.json [ { - "kind": "namespace", "name": "Namespace", "isDefault": false, "location": { @@ -49,10 +48,10 @@ namespace Namespace "byteIndex": 0 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -65,6 +64,7 @@ namespace Namespace "jsDoc": { "doc": "Doc comment 1\n\nDetails 1" }, + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -79,7 +79,6 @@ namespace Namespace } }, { - "kind": "class", "name": "B", "isDefault": false, "location": { @@ -92,6 +91,7 @@ namespace Namespace "jsDoc": { "doc": "Doc comment 2\n\nDetails 2" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/namespace_fn_overloads.txt b/tests/specs/namespace_fn_overloads.txt index 4cdc40f0..f81bf60e 100644 --- a/tests/specs/namespace_fn_overloads.txt +++ b/tests/specs/namespace_fn_overloads.txt @@ -38,7 +38,6 @@ namespace Namespace # output.json [ { - "kind": "namespace", "name": "Namespace", "isDefault": false, "location": { @@ -48,10 +47,10 @@ namespace Namespace "byteIndex": 0 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -61,6 +60,7 @@ namespace Namespace "byteIndex": 31 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -85,7 +85,6 @@ namespace Namespace } }, { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -95,6 +94,7 @@ namespace Namespace "byteIndex": 71 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -119,7 +119,6 @@ namespace Namespace } }, { - "kind": "function", "name": "a", "isDefault": false, "location": { @@ -129,6 +128,7 @@ namespace Namespace "byteIndex": 111 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/no_ambient_in_module.txt b/tests/specs/no_ambient_in_module.txt index 59ba41bf..3c1e1466 100644 --- a/tests/specs/no_ambient_in_module.txt +++ b/tests/specs/no_ambient_in_module.txt @@ -18,7 +18,6 @@ function bar(): void # output.json [ { - "kind": "function", "name": "bar", "isDefault": false, "location": { @@ -28,6 +27,7 @@ function bar(): void "byteIndex": 32 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/non_implemented_renamed_exports_declared_earlier.txt b/tests/specs/non_implemented_renamed_exports_declared_earlier.txt index ed8441fc..3135bfc1 100644 --- a/tests/specs/non_implemented_renamed_exports_declared_earlier.txt +++ b/tests/specs/non_implemented_renamed_exports_declared_earlier.txt @@ -18,7 +18,6 @@ function bar(): void # output.json [ { - "kind": "function", "name": "bar", "isDefault": false, "location": { @@ -28,6 +27,7 @@ function bar(): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/optional_return_type.txt b/tests/specs/optional_return_type.txt index 6aa4d0fe..4b07b744 100644 --- a/tests/specs/optional_return_type.txt +++ b/tests/specs/optional_return_type.txt @@ -26,7 +26,6 @@ function foo(a: number) # output.json [ { - "kind": "function", "name": "foo", "isDefault": false, "location": { @@ -36,6 +35,7 @@ function foo(a: number) "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/private_type_class_property.txt b/tests/specs/private_type_class_property.txt index ee6028b4..c9c1a9fa 100644 --- a/tests/specs/private_type_class_property.txt +++ b/tests/specs/private_type_class_property.txt @@ -105,7 +105,6 @@ private namespace MyNamespace3 # output.json [ { - "kind": "typeAlias", "name": "PrivatePropThroughNamespaceRef", "isDefault": false, "location": { @@ -115,6 +114,7 @@ private namespace MyNamespace3 "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "MyNamespace.Export.someProp", @@ -125,7 +125,6 @@ private namespace MyNamespace3 } }, { - "kind": "namespace", "name": "MyNamespace", "isDefault": false, "location": { @@ -135,10 +134,10 @@ private namespace MyNamespace3 "byteIndex": 82 }, "declarationKind": "private", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "class", "name": "Export", "isDefault": false, "location": { @@ -148,6 +147,7 @@ private namespace MyNamespace3 "byteIndex": 259 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -184,7 +184,6 @@ private namespace MyNamespace3 } }, { - "kind": "namespace", "name": "MyNamespace2", "isDefault": false, "location": { @@ -194,10 +193,10 @@ private namespace MyNamespace3 "byteIndex": 156 }, "declarationKind": "private", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "class", "name": "MyClass", "isDefault": false, "location": { @@ -207,6 +206,7 @@ private namespace MyNamespace3 "byteIndex": 259 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -243,7 +243,6 @@ private namespace MyNamespace3 } }, { - "kind": "namespace", "name": "MyNamespace3", "isDefault": false, "location": { @@ -253,10 +252,10 @@ private namespace MyNamespace3 "byteIndex": 232 }, "declarationKind": "private", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "class", "name": "MyClass", "isDefault": false, "location": { @@ -266,6 +265,7 @@ private namespace MyNamespace3 "byteIndex": 259 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/private_type_ignored_class_not_namespace.txt b/tests/specs/private_type_ignored_class_not_namespace.txt index 0a5a79f9..1117d8e7 100644 --- a/tests/specs/private_type_ignored_class_not_namespace.txt +++ b/tests/specs/private_type_ignored_class_not_namespace.txt @@ -27,7 +27,6 @@ private namespace MyNamespace # output.json [ { - "kind": "typeAlias", "name": "PrivateProp", "isDefault": false, "location": { @@ -40,6 +39,7 @@ private namespace MyNamespace "jsDoc": { "doc": "Comment" }, + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "MyNamespace.MyInternal", @@ -50,7 +50,6 @@ private namespace MyNamespace } }, { - "kind": "namespace", "name": "MyNamespace", "isDefault": false, "location": { @@ -60,10 +59,10 @@ private namespace MyNamespace "byteIndex": 163 }, "declarationKind": "private", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "class", "name": "MyInternal", "isDefault": false, "location": { @@ -80,6 +79,7 @@ private namespace MyNamespace } ] }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/private_type_implementation_signature.txt b/tests/specs/private_type_implementation_signature.txt index 6bdb49da..1916b1e3 100644 --- a/tests/specs/private_type_implementation_signature.txt +++ b/tests/specs/private_type_implementation_signature.txt @@ -77,7 +77,6 @@ namespace SameName # output.json [ { - "kind": "namespace", "name": "SameName", "isDefault": false, "location": { @@ -90,12 +89,12 @@ namespace SameName "jsDoc": { "doc": "Comment" }, + "kind": "namespace", "namespaceDef": { "elements": [] } }, { - "kind": "function", "name": "SameName", "isDefault": false, "location": { @@ -108,6 +107,7 @@ namespace SameName "jsDoc": { "doc": "Comment" }, + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -125,7 +125,6 @@ namespace SameName } }, { - "kind": "function", "name": "test", "isDefault": false, "location": { @@ -138,6 +137,7 @@ namespace SameName "jsDoc": { "doc": "Comment" }, + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -154,7 +154,6 @@ namespace SameName } }, { - "kind": "function", "name": "test", "isDefault": false, "location": { @@ -164,6 +163,7 @@ namespace SameName "byteIndex": 162 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -181,7 +181,6 @@ namespace SameName } }, { - "kind": "interface", "name": "YesDiagnostic1", "isDefault": false, "location": { @@ -191,6 +190,7 @@ namespace SameName "byteIndex": 205 }, "declarationKind": "private", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], @@ -202,7 +202,6 @@ namespace SameName } }, { - "kind": "interface", "name": "YesDiagnostic2", "isDefault": false, "location": { @@ -212,6 +211,7 @@ namespace SameName "byteIndex": 233 }, "declarationKind": "private", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/private_type_in_namespace.txt b/tests/specs/private_type_in_namespace.txt index b366282e..242f609a 100644 --- a/tests/specs/private_type_in_namespace.txt +++ b/tests/specs/private_type_in_namespace.txt @@ -66,7 +66,6 @@ private namespace Test # output.json [ { - "kind": "interface", "name": "Output", "isDefault": false, "location": { @@ -76,6 +75,7 @@ private namespace Test "byteIndex": 44 }, "declarationKind": "export", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], @@ -109,7 +109,6 @@ private namespace Test } }, { - "kind": "namespace", "name": "Test", "isDefault": false, "location": { @@ -119,10 +118,10 @@ private namespace Test "byteIndex": 0 }, "declarationKind": "private", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "class", "name": "Other", "isDefault": false, "location": { @@ -132,6 +131,7 @@ private namespace Test "byteIndex": 19 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/private_type_other_module.txt b/tests/specs/private_type_other_module.txt index f09eb2a1..f9dd41b8 100644 --- a/tests/specs/private_type_other_module.txt +++ b/tests/specs/private_type_other_module.txt @@ -96,7 +96,6 @@ Defined in file:///mod.ts:1:1 # output.json [ { - "kind": "class", "name": "MyClass", "isDefault": false, "location": { @@ -106,6 +105,7 @@ Defined in file:///mod.ts:1:1 "byteIndex": 64 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -164,7 +164,6 @@ Defined in file:///mod.ts:1:1 } }, { - "kind": "import", "name": "MyNamespace", "location": { "filename": "file:///mod.ts", @@ -173,13 +172,13 @@ Defined in file:///mod.ts:1:1 "byteIndex": 0 }, "declarationKind": "private", + "kind": "import", "importDef": { "src": "file:///diagnostic.ts", "imported": "MyNamespace" } }, { - "kind": "import", "name": "YesDiagnostic2", "location": { "filename": "file:///mod.ts", @@ -188,6 +187,7 @@ Defined in file:///mod.ts:1:1 "byteIndex": 0 }, "declarationKind": "private", + "kind": "import", "importDef": { "src": "file:///diagnostic.ts", "imported": "YesDiagnostic2" diff --git a/tests/specs/private_type_private_member.txt b/tests/specs/private_type_private_member.txt index e0f221a7..00c5d0c7 100644 --- a/tests/specs/private_type_private_member.txt +++ b/tests/specs/private_type_private_member.txt @@ -57,7 +57,6 @@ private interface YesDiagnostic # output.json [ { - "kind": "class", "name": "MyClass", "isDefault": false, "location": { @@ -70,6 +69,7 @@ private interface YesDiagnostic "jsDoc": { "doc": "Comment" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -142,7 +142,6 @@ private interface YesDiagnostic } }, { - "kind": "interface", "name": "YesDiagnostic", "isDefault": false, "location": { @@ -152,6 +151,7 @@ private interface YesDiagnostic "byteIndex": 133 }, "declarationKind": "private", + "kind": "interface", "interfaceDef": { "extends": [], "constructors": [], diff --git a/tests/specs/private_type_re_export_referencing.txt b/tests/specs/private_type_re_export_referencing.txt index 229eb212..a841824e 100644 --- a/tests/specs/private_type_re_export_referencing.txt +++ b/tests/specs/private_type_re_export_referencing.txt @@ -69,7 +69,6 @@ class Data # output.json [ { - "kind": "class", "name": "Data", "isDefault": false, "location": { @@ -82,6 +81,7 @@ class Data "jsDoc": { "doc": "doc" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/private_type_referenced_from_class_member.txt b/tests/specs/private_type_referenced_from_class_member.txt index 7071eb67..6f9e2727 100644 --- a/tests/specs/private_type_referenced_from_class_member.txt +++ b/tests/specs/private_type_referenced_from_class_member.txt @@ -39,7 +39,6 @@ private class YesDiagnostic # output.json [ { - "kind": "class", "name": "Other", "isDefault": false, "location": { @@ -52,6 +51,7 @@ private class YesDiagnostic "jsDoc": { "doc": "Comment" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -91,7 +91,6 @@ private class YesDiagnostic } }, { - "kind": "class", "name": "YesDiagnostic", "isDefault": false, "location": { @@ -101,6 +100,7 @@ private class YesDiagnostic "byteIndex": 78 }, "declarationKind": "private", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/private_type_referenced_from_namespace.txt b/tests/specs/private_type_referenced_from_namespace.txt index f5933edc..be5e2f5d 100644 --- a/tests/specs/private_type_referenced_from_namespace.txt +++ b/tests/specs/private_type_referenced_from_namespace.txt @@ -54,7 +54,6 @@ namespace Test # output.json [ { - "kind": "namespace", "name": "Test", "isDefault": false, "location": { @@ -64,10 +63,10 @@ namespace Test "byteIndex": 0 }, "declarationKind": "export", + "kind": "namespace", "namespaceDef": { "elements": [ { - "kind": "class", "name": "Other", "isDefault": false, "location": { @@ -77,6 +76,7 @@ namespace Test "byteIndex": 26 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -93,7 +93,6 @@ namespace Test } }, { - "kind": "class", "name": "YesDiagnostic", "isDefault": false, "location": { @@ -103,6 +102,7 @@ namespace Test "byteIndex": 121 }, "declarationKind": "private", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/re_export_all.txt b/tests/specs/re_export_all.txt index 6e2351a6..c9d35983 100644 --- a/tests/specs/re_export_all.txt +++ b/tests/specs/re_export_all.txt @@ -45,7 +45,6 @@ class Test # output.json [ { - "kind": "class", "name": "Test", "isDefault": false, "location": { @@ -55,6 +54,7 @@ class Test "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -68,7 +68,6 @@ class Test } }, { - "kind": "variable", "name": "test1", "isDefault": false, "location": { @@ -78,6 +77,7 @@ class Test "byteIndex": 6 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "string", diff --git a/tests/specs/re_export_clashes_private_type_bug.txt b/tests/specs/re_export_clashes_private_type_bug.txt index f2c3015a..e1607f80 100644 --- a/tests/specs/re_export_clashes_private_type_bug.txt +++ b/tests/specs/re_export_clashes_private_type_bug.txt @@ -139,7 +139,6 @@ class MyClass # output.json [ { - "kind": "variable", "name": "Test1", "isDefault": false, "location": { @@ -152,6 +151,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -165,7 +165,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test2", "isDefault": false, "location": { @@ -178,6 +177,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -191,7 +191,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test3", "isDefault": false, "location": { @@ -204,6 +203,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -217,7 +217,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test4", "isDefault": false, "location": { @@ -230,6 +229,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -243,7 +243,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test5", "isDefault": false, "location": { @@ -256,6 +255,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -269,7 +269,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test6", "isDefault": false, "location": { @@ -282,6 +281,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -295,7 +295,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test7", "isDefault": false, "location": { @@ -308,6 +307,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -321,7 +321,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test8", "isDefault": false, "location": { @@ -334,6 +333,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -347,7 +347,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test9", "isDefault": false, "location": { @@ -360,6 +359,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -373,7 +373,6 @@ class MyClass } }, { - "kind": "variable", "name": "Test10", "isDefault": false, "location": { @@ -386,6 +385,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "variable", "variableDef": { "tsType": { "repr": "1", @@ -399,7 +399,6 @@ class MyClass } }, { - "kind": "class", "name": "MyClass", "isDefault": false, "location": { @@ -412,6 +411,7 @@ class MyClass "jsDoc": { "doc": "Test" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -476,7 +476,6 @@ class MyClass } }, { - "kind": "class", "name": "Internal1", "isDefault": false, "location": { @@ -486,6 +485,7 @@ class MyClass "byteIndex": 115 }, "declarationKind": "private", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -499,7 +499,6 @@ class MyClass } }, { - "kind": "class", "name": "Internal2", "isDefault": false, "location": { @@ -509,6 +508,7 @@ class MyClass "byteIndex": 134 }, "declarationKind": "private", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/reexport_deep.txt b/tests/specs/reexport_deep.txt index 87b10627..8022deeb 100644 --- a/tests/specs/reexport_deep.txt +++ b/tests/specs/reexport_deep.txt @@ -62,7 +62,6 @@ Defined in file:///mod.ts:1:1 # output.json [ { - "kind": "typeAlias", "name": "UrlMessageEntity", "isDefault": false, "location": { @@ -72,6 +71,7 @@ Defined in file:///mod.ts:1:1 "byteIndex": 45 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "MessageEntity.TextLinkMessageEntity", @@ -85,7 +85,6 @@ Defined in file:///mod.ts:1:1 } }, { - "kind": "import", "name": "MessageEntity", "location": { "filename": "file:///mod.ts", @@ -94,6 +93,7 @@ Defined in file:///mod.ts:1:1 "byteIndex": 0 }, "declarationKind": "private", + "kind": "import", "importDef": { "src": "file:///a.ts", "imported": "MessageEntity" diff --git a/tests/specs/reexport_existing_export.txt b/tests/specs/reexport_existing_export.txt index 7f2b7c5c..978dac13 100644 --- a/tests/specs/reexport_existing_export.txt +++ b/tests/specs/reexport_existing_export.txt @@ -22,7 +22,6 @@ function foo(): void # output.json [ { - "kind": "function", "name": "foo", "isDefault": false, "location": { @@ -32,6 +31,7 @@ function foo(): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { @@ -46,7 +46,6 @@ function foo(): void } }, { - "kind": "function", "name": "bar", "isDefault": false, "location": { @@ -56,6 +55,7 @@ function foo(): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": { diff --git a/tests/specs/remote_module_re_export_no_diagnostics.txt b/tests/specs/remote_module_re_export_no_diagnostics.txt index 8ee58d9b..d49bd86c 100644 --- a/tests/specs/remote_module_re_export_no_diagnostics.txt +++ b/tests/specs/remote_module_re_export_no_diagnostics.txt @@ -51,7 +51,6 @@ class PublicType2 # output.json [ { - "kind": "function", "name": "myFunction", "isDefault": false, "location": { @@ -61,6 +60,7 @@ class PublicType2 "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": null, @@ -71,7 +71,6 @@ class PublicType2 } }, { - "kind": "class", "name": "PublicType", "isDefault": false, "location": { @@ -81,6 +80,7 @@ class PublicType2 "byteIndex": 58 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], @@ -117,7 +117,6 @@ class PublicType2 } }, { - "kind": "function", "name": "myFunction2", "isDefault": false, "location": { @@ -127,6 +126,7 @@ class PublicType2 "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [], "returnType": null, @@ -137,7 +137,6 @@ class PublicType2 } }, { - "kind": "class", "name": "PublicType2", "isDefault": false, "location": { @@ -147,6 +146,7 @@ class PublicType2 "byteIndex": 59 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/structured_jsdoc.txt b/tests/specs/structured_jsdoc.txt index 7b473ba8..40024bb5 100644 --- a/tests/specs/structured_jsdoc.txt +++ b/tests/specs/structured_jsdoc.txt @@ -64,7 +64,6 @@ class A # output.json [ { - "kind": "class", "name": "A", "isDefault": false, "location": { @@ -77,6 +76,7 @@ class A "jsDoc": { "doc": "Class doc" }, + "kind": "class", "classDef": { "isAbstract": false, "constructors": [ diff --git a/tests/specs/ts_lit_types.txt b/tests/specs/ts_lit_types.txt index 6e3684a8..b93adae5 100644 --- a/tests/specs/ts_lit_types.txt +++ b/tests/specs/ts_lit_types.txt @@ -65,7 +65,6 @@ type tplLitArg = `test${number}` # output.json [ { - "kind": "typeAlias", "name": "boolLit", "isDefault": false, "location": { @@ -75,6 +74,7 @@ type tplLitArg = `test${number}` "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "false", @@ -88,7 +88,6 @@ type tplLitArg = `test${number}` } }, { - "kind": "typeAlias", "name": "strLit", "isDefault": false, "location": { @@ -98,6 +97,7 @@ type tplLitArg = `test${number}` "byteIndex": 29 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "text", @@ -111,7 +111,6 @@ type tplLitArg = `test${number}` } }, { - "kind": "typeAlias", "name": "tplLit", "isDefault": false, "location": { @@ -121,6 +120,7 @@ type tplLitArg = `test${number}` "byteIndex": 58 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "text", @@ -143,7 +143,6 @@ type tplLitArg = `test${number}` } }, { - "kind": "typeAlias", "name": "tplLitArg", "isDefault": false, "location": { @@ -153,6 +152,7 @@ type tplLitArg = `test${number}` "byteIndex": 87 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "test${number}", @@ -188,7 +188,6 @@ type tplLitArg = `test${number}` } }, { - "kind": "typeAlias", "name": "numLit", "isDefault": false, "location": { @@ -198,6 +197,7 @@ type tplLitArg = `test${number}` "byteIndex": 128 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "5", diff --git a/tests/specs/ts_template_with_args.txt b/tests/specs/ts_template_with_args.txt index 9048a72e..3e9b49b7 100644 --- a/tests/specs/ts_template_with_args.txt +++ b/tests/specs/ts_template_with_args.txt @@ -17,7 +17,6 @@ const tpl: `test${number}` # output.json [ { - "kind": "variable", "name": "tpl", "isDefault": false, "location": { @@ -27,6 +26,7 @@ const tpl: `test${number}` "byteIndex": 13 }, "declarationKind": "export", + "kind": "variable", "variableDef": { "tsType": { "repr": "test${number}", diff --git a/tests/specs/ts_type_assertion.txt b/tests/specs/ts_type_assertion.txt index d49bd041..7fb88df9 100644 --- a/tests/specs/ts_type_assertion.txt +++ b/tests/specs/ts_type_assertion.txt @@ -17,7 +17,6 @@ function foo(bar: any): asserts bar # output.json [ { - "kind": "function", "name": "foo", "isDefault": false, "location": { @@ -27,6 +26,7 @@ function foo(bar: any): asserts bar "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/ts_type_predicate1.txt b/tests/specs/ts_type_predicate1.txt index 66264b47..16cdad63 100644 --- a/tests/specs/ts_type_predicate1.txt +++ b/tests/specs/ts_type_predicate1.txt @@ -17,7 +17,6 @@ function foo(bar: A | B): bar is A # output.json [ { - "kind": "function", "name": "foo", "isDefault": false, "location": { @@ -27,6 +26,7 @@ function foo(bar: A | B): bar is A "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/ts_type_predicate2.txt b/tests/specs/ts_type_predicate2.txt index 6d8b59d5..5ea64830 100644 --- a/tests/specs/ts_type_predicate2.txt +++ b/tests/specs/ts_type_predicate2.txt @@ -17,7 +17,6 @@ function foo(bar: A | B): asserts bar is B # output.json [ { - "kind": "function", "name": "foo", "isDefault": false, "location": { @@ -27,6 +26,7 @@ function foo(bar: A | B): asserts bar is B "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/ts_type_predicate3.txt b/tests/specs/ts_type_predicate3.txt index 4dbe601a..70c75a36 100644 --- a/tests/specs/ts_type_predicate3.txt +++ b/tests/specs/ts_type_predicate3.txt @@ -28,7 +28,6 @@ class C # output.json [ { - "kind": "class", "name": "C", "isDefault": false, "location": { @@ -38,6 +37,7 @@ class C "byteIndex": 0 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/ts_user_defined_type_guards.txt b/tests/specs/ts_user_defined_type_guards.txt index fae5ef1a..9d870caf 100644 --- a/tests/specs/ts_user_defined_type_guards.txt +++ b/tests/specs/ts_user_defined_type_guards.txt @@ -84,7 +84,6 @@ class C # output.json [ { - "kind": "function", "name": "f1", "isDefault": false, "location": { @@ -94,6 +93,7 @@ class C "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -150,7 +150,6 @@ class C } }, { - "kind": "function", "name": "f2", "isDefault": false, "location": { @@ -160,6 +159,7 @@ class C "byteIndex": 46 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -196,7 +196,6 @@ class C } }, { - "kind": "function", "name": "f3", "isDefault": false, "location": { @@ -206,6 +205,7 @@ class C "byteIndex": 103 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -238,7 +238,6 @@ class C } }, { - "kind": "function", "name": "assertIsDefined", "isDefault": false, "location": { @@ -248,6 +247,7 @@ class C "byteIndex": 150 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { @@ -303,7 +303,6 @@ class C } }, { - "kind": "class", "name": "C", "isDefault": false, "location": { @@ -313,6 +312,7 @@ class C "byteIndex": 372 }, "declarationKind": "export", + "kind": "class", "classDef": { "isAbstract": false, "constructors": [], diff --git a/tests/specs/type_alias.txt b/tests/specs/type_alias.txt index 0aeddaf8..00be7a50 100644 --- a/tests/specs/type_alias.txt +++ b/tests/specs/type_alias.txt @@ -17,7 +17,6 @@ type A = number # output.json [ { - "kind": "typeAlias", "name": "A", "isDefault": false, "location": { @@ -27,6 +26,7 @@ type A = number "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "number", diff --git a/tests/specs/type_alias_infer_type.txt b/tests/specs/type_alias_infer_type.txt index 04129e4a..04930214 100644 --- a/tests/specs/type_alias_infer_type.txt +++ b/tests/specs/type_alias_infer_type.txt @@ -17,7 +17,6 @@ type Flatten = T extends Array ? U : T # output.json [ { - "kind": "typeAlias", "name": "Flatten", "isDefault": false, "location": { @@ -27,6 +26,7 @@ type Flatten = T extends Array ? U : T "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "", diff --git a/tests/specs/type_generic_alias.txt b/tests/specs/type_generic_alias.txt index ee6e9adc..3017d64f 100644 --- a/tests/specs/type_generic_alias.txt +++ b/tests/specs/type_generic_alias.txt @@ -17,7 +17,6 @@ type A = T # output.json [ { - "kind": "typeAlias", "name": "A", "isDefault": false, "location": { @@ -27,6 +26,7 @@ type A = T "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "T", diff --git a/tests/specs/type_import_type.txt b/tests/specs/type_import_type.txt index 99499439..f0f429f7 100644 --- a/tests/specs/type_import_type.txt +++ b/tests/specs/type_import_type.txt @@ -17,7 +17,6 @@ function adopt(p: import("./module.ts").Pet): void # output.json [ { - "kind": "function", "name": "adopt", "isDefault": false, "location": { @@ -27,6 +26,7 @@ function adopt(p: import("./module.ts").Pet): void "byteIndex": 0 }, "declarationKind": "export", + "kind": "function", "functionDef": { "params": [ { diff --git a/tests/specs/type_literal_declaration.txt b/tests/specs/type_literal_declaration.txt index 994160cf..ce4fea65 100644 --- a/tests/specs/type_literal_declaration.txt +++ b/tests/specs/type_literal_declaration.txt @@ -17,7 +17,6 @@ type T = { } # output.json [ { - "kind": "typeAlias", "name": "T", "isDefault": false, "location": { @@ -27,6 +26,7 @@ type T = { } "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "", diff --git a/tests/specs/type_literal_index_signature.txt b/tests/specs/type_literal_index_signature.txt index 3893e8cf..5b7df4ac 100644 --- a/tests/specs/type_literal_index_signature.txt +++ b/tests/specs/type_literal_index_signature.txt @@ -17,7 +17,6 @@ type T = { [key: string]: number; } # output.json [ { - "kind": "typeAlias", "name": "T", "isDefault": false, "location": { @@ -27,6 +26,7 @@ type T = { [key: string]: number; } "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "", diff --git a/tests/specs/type_literal_mapped_type.txt b/tests/specs/type_literal_mapped_type.txt index fdef3390..fc00d627 100644 --- a/tests/specs/type_literal_mapped_type.txt +++ b/tests/specs/type_literal_mapped_type.txt @@ -17,7 +17,6 @@ type T = readonly [P in keyof Type as NewType]: Type[P] # output.json [ { - "kind": "typeAlias", "name": "T", "isDefault": false, "location": { @@ -27,6 +26,7 @@ type T = readonly [P in keyof Type as NewType]: Type[P] "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "", diff --git a/tests/specs/type_literal_readonly_index_signature.txt b/tests/specs/type_literal_readonly_index_signature.txt index d7e0cd18..e87ae4c7 100644 --- a/tests/specs/type_literal_readonly_index_signature.txt +++ b/tests/specs/type_literal_readonly_index_signature.txt @@ -17,7 +17,6 @@ type T = { readonly [key: string]: number; } # output.json [ { - "kind": "typeAlias", "name": "T", "isDefault": false, "location": { @@ -27,6 +26,7 @@ type T = { readonly [key: string]: number; } "byteIndex": 0 }, "declarationKind": "export", + "kind": "typeAlias", "typeAliasDef": { "tsType": { "repr": "",