diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/Cargo.toml | 4 | ||||
-rw-r--r-- | cli/tools/doc.rs | 45 |
2 files changed, 47 insertions, 2 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml index fcf497692..0e7050d92 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -67,7 +67,7 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposa deno_cache_dir = { workspace = true } deno_config = { version = "=0.28.0", features = ["workspace", "sync"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } -deno_doc = { version = "0.145.0", features = ["html", "syntect"] } +deno_doc = { version = "0.146.0", features = ["html", "syntect"] } deno_emit = "=0.44.0" deno_graph = { version = "=0.81.2" } deno_lint = { version = "=0.62.0", features = ["docs"] } @@ -155,7 +155,7 @@ tokio.workspace = true tokio-util.workspace = true tower-lsp.workspace = true twox-hash.workspace = true -typed-arena = "=2.0.1" +typed-arena = "=2.0.2" uuid = { workspace = true, features = ["serde"] } which.workspace = true zeromq.workspace = true diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index e7eab9b91..ce31c8068 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -301,6 +301,35 @@ impl deno_doc::html::HrefResolver for DocResolver { fn resolve_source(&self, location: &deno_doc::Location) -> Option<String> { Some(location.filename.to_string()) } + + fn resolve_external_jsdoc_module( + &self, + module: &str, + _symbol: Option<&str>, + ) -> Option<(String, String)> { + if let Ok(url) = deno_core::url::Url::parse(module) { + match url.scheme() { + "npm" => { + let res = + deno_semver::npm::NpmPackageReqReference::from_str(module).ok()?; + let name = &res.req().name; + Some(( + format!("https://www.npmjs.com/package/{name}"), + name.to_owned(), + )) + } + "jsr" => { + let res = + deno_semver::jsr::JsrPackageReqReference::from_str(module).ok()?; + let name = &res.req().name; + Some((format!("https://jsr.io/{name}"), name.to_owned())) + } + _ => None, + } + } else { + None + } + } } struct DenoDocResolver(bool); @@ -343,6 +372,14 @@ impl deno_doc::html::HrefResolver for DenoDocResolver { fn resolve_source(&self, _location: &deno_doc::Location) -> Option<String> { None } + + fn resolve_external_jsdoc_module( + &self, + _module: &str, + _symbol: Option<&str>, + ) -> Option<(String, String)> { + None + } } struct NodeDocResolver(bool); @@ -387,6 +424,14 @@ impl deno_doc::html::HrefResolver for NodeDocResolver { fn resolve_source(&self, _location: &deno_doc::Location) -> Option<String> { None } + + fn resolve_external_jsdoc_module( + &self, + _module: &str, + _symbol: Option<&str>, + ) -> Option<(String, String)> { + None + } } fn generate_docs_directory( |