1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(doc): deno doc should parse modules if they haven't been parsed before (#15941)

This commit is contained in:
David Sherret 2022-09-18 12:59:33 -05:00 committed by David Sherret
parent 391108f16f
commit ff2f128d56
5 changed files with 39 additions and 12 deletions

4
Cargo.lock generated
View file

@ -978,9 +978,9 @@ dependencies = [
[[package]]
name = "deno_doc"
version = "0.45.0"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef056cd1ca61584e7db9e3a025676f880be5a67101aee54f295b8770100eeb53"
checksum = "910f889d786d8b7ef40d50da4f2a4da01adf1c63c2f4a3b74324f6313eee8c59"
dependencies = [
"cfg-if",
"deno_ast",

View file

@ -49,7 +49,7 @@ winres = "=0.1.12"
[dependencies]
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_doc = "0.45.0"
deno_doc = "0.46.0"
deno_emit = "0.9.0"
deno_graph = "0.34.0"
deno_lint = { version = "0.33.0", features = ["docs"] }

View file

@ -1,5 +1,9 @@
// 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;
itest!(deno_doc_builtin {
@ -7,10 +11,28 @@ itest!(deno_doc_builtin {
output: "deno_doc_builtin.out",
});
itest!(deno_doc {
args: "doc deno_doc.ts",
output: "deno_doc.out",
});
#[test]
fn deno_doc() {
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 {
args: "doc --unstable --import-map=doc/import_map.json doc/use_import_map.js",

View file

@ -1,2 +0,0 @@
[WILDCARD]
function foo[WILDCARD]

View file

@ -53,7 +53,11 @@ pub async fn print_docs(
None,
)
.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
} else {
let module_specifier = resolve_url_or_path(&source_file)?;
@ -76,8 +80,11 @@ pub async fn print_docs(
let graph = ps
.create_graph(vec![(root_specifier.clone(), ModuleKind::Esm)])
.await?;
let store = ps.parsed_source_cache.as_store();
let doc_parser = doc::DocParser::new(graph, doc_flags.private, &*store);
let doc_parser = doc::DocParser::new(
graph,
doc_flags.private,
ps.parsed_source_cache.as_capturing_parser(),
);
doc_parser.parse_with_reexports(&root_specifier)?
};