mirror of
https://github.com/denoland/deno.git
synced 2025-02-08 07:16:56 -05:00
chore: update deno_doc (#23544)
This commit is contained in:
parent
ac71d876d7
commit
5a7414e163
6 changed files with 515 additions and 512 deletions
976
Cargo.lock
generated
976
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -66,7 +66,7 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposa
|
||||||
deno_cache_dir = { workspace = true }
|
deno_cache_dir = { workspace = true }
|
||||||
deno_config = "=0.16.1"
|
deno_config = "=0.16.1"
|
||||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||||
deno_doc = { version = "=0.125.0", features = ["html"] }
|
deno_doc = { version = "=0.128.0", features = ["html"] }
|
||||||
deno_emit = "=0.40.0"
|
deno_emit = "=0.40.0"
|
||||||
deno_graph = { version = "=0.73.1", features = ["tokio_executor"] }
|
deno_graph = { version = "=0.73.1", features = ["tokio_executor"] }
|
||||||
deno_lint = { version = "=0.58.3", features = ["docs"] }
|
deno_lint = { version = "=0.58.3", features = ["docs"] }
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl Default for DocSourceFileFlag {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct DocHtmlFlag {
|
pub struct DocHtmlFlag {
|
||||||
pub name: String,
|
pub name: Option<String>,
|
||||||
pub output: String,
|
pub output: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1695,7 +1695,6 @@ Show documentation for runtime built-ins:
|
||||||
.long("name")
|
.long("name")
|
||||||
.help("The name that will be displayed in the docs")
|
.help("The name that will be displayed in the docs")
|
||||||
.action(ArgAction::Set)
|
.action(ArgAction::Set)
|
||||||
.required_if_eq("html", "true")
|
|
||||||
.require_equals(true)
|
.require_equals(true)
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -3690,7 +3689,7 @@ fn doc_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
||||||
let json = matches.get_flag("json");
|
let json = matches.get_flag("json");
|
||||||
let filter = matches.remove_one::<String>("filter");
|
let filter = matches.remove_one::<String>("filter");
|
||||||
let html = if matches.get_flag("html") {
|
let html = if matches.get_flag("html") {
|
||||||
let name = matches.remove_one::<String>("name").unwrap();
|
let name = matches.remove_one::<String>("name");
|
||||||
let output = matches
|
let output = matches
|
||||||
.remove_one::<String>("output")
|
.remove_one::<String>("output")
|
||||||
.unwrap_or(String::from("./docs/"));
|
.unwrap_or(String::from("./docs/"));
|
||||||
|
@ -8353,7 +8352,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let r = flags_from_vec(svec!["deno", "doc", "--html", "path/to/module.ts"]);
|
let r = flags_from_vec(svec!["deno", "doc", "--html", "path/to/module.ts"]);
|
||||||
assert!(r.is_err());
|
assert!(r.is_ok());
|
||||||
|
|
||||||
let r = flags_from_vec(svec![
|
let r = flags_from_vec(svec![
|
||||||
"deno",
|
"deno",
|
||||||
|
@ -8370,7 +8369,7 @@ mod tests {
|
||||||
json: false,
|
json: false,
|
||||||
lint: false,
|
lint: false,
|
||||||
html: Some(DocHtmlFlag {
|
html: Some(DocHtmlFlag {
|
||||||
name: "My library".to_string(),
|
name: Some("My library".to_string()),
|
||||||
output: String::from("./docs/"),
|
output: String::from("./docs/"),
|
||||||
}),
|
}),
|
||||||
source_files: DocSourceFileFlag::Paths(svec!["path/to/module.ts"]),
|
source_files: DocSourceFileFlag::Paths(svec!["path/to/module.ts"]),
|
||||||
|
@ -8396,7 +8395,7 @@ mod tests {
|
||||||
private: false,
|
private: false,
|
||||||
json: false,
|
json: false,
|
||||||
html: Some(DocHtmlFlag {
|
html: Some(DocHtmlFlag {
|
||||||
name: "My library".to_string(),
|
name: Some("My library".to_string()),
|
||||||
output: String::from("./foo"),
|
output: String::from("./foo"),
|
||||||
}),
|
}),
|
||||||
lint: true,
|
lint: true,
|
||||||
|
|
|
@ -18,6 +18,7 @@ use deno_core::anyhow::bail;
|
||||||
use deno_core::anyhow::Context;
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_doc as doc;
|
use deno_doc as doc;
|
||||||
|
use deno_doc::html::UrlResolveKind;
|
||||||
use deno_graph::source::NullFileSystem;
|
use deno_graph::source::NullFileSystem;
|
||||||
use deno_graph::GraphKind;
|
use deno_graph::GraphKind;
|
||||||
use deno_graph::ModuleAnalyzer;
|
use deno_graph::ModuleAnalyzer;
|
||||||
|
@ -35,7 +36,7 @@ async fn generate_doc_nodes_for_builtin_types(
|
||||||
analyzer: &dyn ModuleAnalyzer,
|
analyzer: &dyn ModuleAnalyzer,
|
||||||
) -> Result<IndexMap<ModuleSpecifier, Vec<doc::DocNode>>, AnyError> {
|
) -> Result<IndexMap<ModuleSpecifier, Vec<doc::DocNode>>, AnyError> {
|
||||||
let source_file_specifier =
|
let source_file_specifier =
|
||||||
ModuleSpecifier::parse("internal://lib.deno.d.ts").unwrap();
|
ModuleSpecifier::parse("file:///lib.deno.d.ts").unwrap();
|
||||||
let content = get_types_declaration_file_text();
|
let content = get_types_declaration_file_text();
|
||||||
let loader = deno_graph::source::MemoryLoader::new(
|
let loader = deno_graph::source::MemoryLoader::new(
|
||||||
vec![(
|
vec![(
|
||||||
|
@ -160,11 +161,18 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
|
||||||
.await?;
|
.await?;
|
||||||
let (_, deno_ns) = deno_ns.into_iter().next().unwrap();
|
let (_, deno_ns) = deno_ns.into_iter().next().unwrap();
|
||||||
|
|
||||||
|
let short_path = Rc::new(ShortPath::new(
|
||||||
|
ModuleSpecifier::parse("file:///lib.deno.d.ts").unwrap(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
));
|
||||||
|
|
||||||
deno_doc::html::compute_namespaced_symbols(
|
deno_doc::html::compute_namespaced_symbols(
|
||||||
deno_ns
|
deno_ns
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|node| deno_doc::html::DocNodeWithContext {
|
.map(|node| deno_doc::html::DocNodeWithContext {
|
||||||
origin: Rc::new(ShortPath::from("deno".to_string())),
|
origin: short_path.clone(),
|
||||||
ns_qualifiers: Rc::new(vec![]),
|
ns_qualifiers: Rc::new(vec![]),
|
||||||
kind_with_drilldown:
|
kind_with_drilldown:
|
||||||
deno_doc::html::DocNodeKindWithDrilldown::Other(node.kind),
|
deno_doc::html::DocNodeKindWithDrilldown::Other(node.kind),
|
||||||
|
@ -205,6 +213,14 @@ struct DocResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl deno_doc::html::HrefResolver for DocResolver {
|
impl deno_doc::html::HrefResolver for DocResolver {
|
||||||
|
fn resolve_path(
|
||||||
|
&self,
|
||||||
|
current: UrlResolveKind,
|
||||||
|
target: UrlResolveKind,
|
||||||
|
) -> String {
|
||||||
|
deno_doc::html::href_path_resolve(current, target)
|
||||||
|
}
|
||||||
|
|
||||||
fn resolve_global_symbol(&self, symbol: &[String]) -> Option<String> {
|
fn resolve_global_symbol(&self, symbol: &[String]) -> Option<String> {
|
||||||
if self.deno_ns.contains(symbol) {
|
if self.deno_ns.contains(symbol) {
|
||||||
Some(format!(
|
Some(format!(
|
||||||
|
@ -232,12 +248,8 @@ impl deno_doc::html::HrefResolver for DocResolver {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_usage(
|
fn resolve_usage(&self, current_resolve: UrlResolveKind) -> Option<String> {
|
||||||
&self,
|
current_resolve.get_file().map(|file| file.path.to_string())
|
||||||
_current_specifier: &ModuleSpecifier,
|
|
||||||
current_file: Option<&ShortPath>,
|
|
||||||
) -> Option<String> {
|
|
||||||
current_file.map(|f| f.as_str().to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_source(&self, location: &deno_doc::Location) -> Option<String> {
|
fn resolve_source(&self, location: &deno_doc::Location) -> Option<String> {
|
||||||
|
@ -254,13 +266,12 @@ fn generate_docs_directory(
|
||||||
let output_dir_resolved = cwd.join(&html_options.output);
|
let output_dir_resolved = cwd.join(&html_options.output);
|
||||||
|
|
||||||
let options = deno_doc::html::GenerateOptions {
|
let options = deno_doc::html::GenerateOptions {
|
||||||
package_name: Some(html_options.name.to_owned()),
|
package_name: html_options.name.clone(),
|
||||||
main_entrypoint: None,
|
main_entrypoint: None,
|
||||||
rewrite_map: None,
|
rewrite_map: None,
|
||||||
hide_module_doc_title: false,
|
|
||||||
href_resolver: Rc::new(DocResolver { deno_ns }),
|
href_resolver: Rc::new(DocResolver { deno_ns }),
|
||||||
sidebar_flatten_namespaces: false,
|
|
||||||
usage_composer: None,
|
usage_composer: None,
|
||||||
|
composable_output: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let files = deno_doc::html::generate(options, doc_nodes_by_url)
|
let files = deno_doc::html::generate(options, doc_nodes_by_url)
|
||||||
|
|
|
@ -139,7 +139,7 @@ fn deno_doc_html() {
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
output.assert_exit_code(0);
|
output.assert_exit_code(0);
|
||||||
assert_contains!(output.stderr(), "Written 14 files to");
|
assert_contains!(output.stderr(), "Written 13 files to");
|
||||||
assert!(temp_dir.path().join("all_symbols.html").exists());
|
assert!(temp_dir.path().join("all_symbols.html").exists());
|
||||||
assert!(temp_dir.path().join("index.html").exists());
|
assert!(temp_dir.path().join("index.html").exists());
|
||||||
assert!(temp_dir.path().join("fuse.js").exists());
|
assert!(temp_dir.path().join("fuse.js").exists());
|
||||||
|
@ -156,5 +156,4 @@ fn deno_doc_html() {
|
||||||
.path()
|
.path()
|
||||||
.join("~/MyClass.prototype.prop.html")
|
.join("~/MyClass.prototype.prop.html")
|
||||||
.exists());
|
.exists());
|
||||||
assert!(temp_dir.path().join("~/index.html").exists());
|
|
||||||
}
|
}
|
||||||
|
|
2
tests/testdata/doc/lint_success_html.out
vendored
2
tests/testdata/doc/lint_success_html.out
vendored
|
@ -1 +1 @@
|
||||||
Written 12 files to "./docs/"
|
Written 11 files to "./docs/"
|
||||||
|
|
Loading…
Add table
Reference in a new issue