diff --git a/Cargo.lock b/Cargo.lock index 10cbaf841f..f602d3af2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 91a9b6ab28..fa7284d54c 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -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"] } diff --git a/cli/tests/integration/doc_tests.rs b/cli/tests/integration/doc_tests.rs index 95bc2a3358..f225eeb2c9 100644 --- a/cli/tests/integration/doc_tests.rs +++ b/cli/tests/integration/doc_tests.rs @@ -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", diff --git a/cli/tests/testdata/deno_doc.out b/cli/tests/testdata/deno_doc.out deleted file mode 100644 index 86a77a9cc1..0000000000 --- a/cli/tests/testdata/deno_doc.out +++ /dev/null @@ -1,2 +0,0 @@ -[WILDCARD] -function foo[WILDCARD] \ No newline at end of file diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 106cacb85e..4524254515 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -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)? };