mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
fix(doc): deno doc should parse modules if they haven't been parsed before (#15941)
This commit is contained in:
parent
391108f16f
commit
ff2f128d56
5 changed files with 39 additions and 12 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -978,9 +978,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_doc"
|
name = "deno_doc"
|
||||||
version = "0.45.0"
|
version = "0.46.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ef056cd1ca61584e7db9e3a025676f880be5a67101aee54f295b8770100eeb53"
|
checksum = "910f889d786d8b7ef40d50da4f2a4da01adf1c63c2f4a3b74324f6313eee8c59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"deno_ast",
|
"deno_ast",
|
||||||
|
|
|
@ -49,7 +49,7 @@ winres = "=0.1.12"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_ast = { version = "0.19.0", features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "transpiling", "typescript", "view", "visit"] }
|
deno_ast = { version = "0.19.0", features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "transpiling", "typescript", "view", "visit"] }
|
||||||
deno_core = { version = "0.151.0", path = "../core" }
|
deno_core = { version = "0.151.0", path = "../core" }
|
||||||
deno_doc = "0.45.0"
|
deno_doc = "0.46.0"
|
||||||
deno_emit = "0.9.0"
|
deno_emit = "0.9.0"
|
||||||
deno_graph = "0.34.0"
|
deno_graph = "0.34.0"
|
||||||
deno_lint = { version = "0.33.0", features = ["docs"] }
|
deno_lint = { version = "0.33.0", features = ["docs"] }
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
use util::assert_contains;
|
||||||
|
|
||||||
use crate::itest;
|
use crate::itest;
|
||||||
|
|
||||||
itest!(deno_doc_builtin {
|
itest!(deno_doc_builtin {
|
||||||
|
@ -7,10 +11,28 @@ itest!(deno_doc_builtin {
|
||||||
output: "deno_doc_builtin.out",
|
output: "deno_doc_builtin.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(deno_doc {
|
#[test]
|
||||||
args: "doc deno_doc.ts",
|
fn deno_doc() {
|
||||||
output: "deno_doc.out",
|
let dir = TempDir::new();
|
||||||
});
|
// try this twice to ensure it works with the cache
|
||||||
|
for _ in 0..2 {
|
||||||
|
let output = util::deno_cmd_with_deno_dir(&dir)
|
||||||
|
.current_dir(util::testdata_path())
|
||||||
|
.arg("doc")
|
||||||
|
.arg("deno_doc.ts")
|
||||||
|
.env("NO_COLOR", "1")
|
||||||
|
.stdout(std::process::Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
.unwrap()
|
||||||
|
.wait_with_output()
|
||||||
|
.unwrap();
|
||||||
|
assert!(output.status.success());
|
||||||
|
assert_contains!(
|
||||||
|
std::str::from_utf8(&output.stdout).unwrap(),
|
||||||
|
"function foo"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
itest!(deno_doc_import_map {
|
itest!(deno_doc_import_map {
|
||||||
args: "doc --unstable --import-map=doc/import_map.json doc/use_import_map.js",
|
args: "doc --unstable --import-map=doc/import_map.json doc/use_import_map.js",
|
||||||
|
|
2
cli/tests/testdata/deno_doc.out
vendored
2
cli/tests/testdata/deno_doc.out
vendored
|
@ -1,2 +0,0 @@
|
||||||
[WILDCARD]
|
|
||||||
function foo[WILDCARD]
|
|
|
@ -53,7 +53,11 @@ pub async fn print_docs(
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
let doc_parser = doc::DocParser::new(graph, doc_flags.private, &analyzer);
|
let doc_parser = doc::DocParser::new(
|
||||||
|
graph,
|
||||||
|
doc_flags.private,
|
||||||
|
analyzer.as_capturing_parser(),
|
||||||
|
);
|
||||||
doc_parser.parse_module(&source_file_specifier)?.definitions
|
doc_parser.parse_module(&source_file_specifier)?.definitions
|
||||||
} else {
|
} else {
|
||||||
let module_specifier = resolve_url_or_path(&source_file)?;
|
let module_specifier = resolve_url_or_path(&source_file)?;
|
||||||
|
@ -76,8 +80,11 @@ pub async fn print_docs(
|
||||||
let graph = ps
|
let graph = ps
|
||||||
.create_graph(vec![(root_specifier.clone(), ModuleKind::Esm)])
|
.create_graph(vec![(root_specifier.clone(), ModuleKind::Esm)])
|
||||||
.await?;
|
.await?;
|
||||||
let store = ps.parsed_source_cache.as_store();
|
let doc_parser = doc::DocParser::new(
|
||||||
let doc_parser = doc::DocParser::new(graph, doc_flags.private, &*store);
|
graph,
|
||||||
|
doc_flags.private,
|
||||||
|
ps.parsed_source_cache.as_capturing_parser(),
|
||||||
|
);
|
||||||
doc_parser.parse_with_reexports(&root_specifier)?
|
doc_parser.parse_with_reexports(&root_specifier)?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue