diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-10-30 23:58:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 23:58:57 +0100 |
commit | 48c5c3a3fb2f43716528db8915b36e55c411d94f (patch) | |
tree | 557d833f997ab96652ef4a64dfd59348d5e4017e /cli/tools/doc.rs | |
parent | b75f3b5ca0952db8b50cf417c107f3f14fe582d5 (diff) |
feat(doc): support multiple file entry (#21018)
This commit adds support for multiple entry points to `deno doc`.
Unfortunately to achieve that, I had to change the semantics of the
command to explicitly require `--filter` parameter for filtering
symbols, instead of treating second free argument as the filter argument.
`deno doc --builtin` is still supported, but cannot be mixed with
actual entrypoints.
Diffstat (limited to 'cli/tools/doc.rs')
-rw-r--r-- | cli/tools/doc.rs | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 1a770b2d3..5e87e7917 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -33,7 +33,7 @@ pub async fn print_docs( let capturing_parser = CapturingModuleParser::new(Some(&source_parser), &store); - let mut doc_nodes = match doc_flags.source_file { + let mut doc_nodes = match doc_flags.source_files { DocSourceFileFlag::Builtin => { let source_file_specifier = ModuleSpecifier::parse("internal://lib.deno.d.ts").unwrap(); @@ -64,18 +64,23 @@ pub async fn print_docs( doc::DocParser::new(&graph, doc_flags.private, capturing_parser)?; doc_parser.parse_module(&source_file_specifier)?.definitions } - DocSourceFileFlag::Path(source_file) => { + DocSourceFileFlag::Paths(source_files) => { let module_graph_builder = factory.module_graph_builder().await?; let maybe_lockfile = factory.maybe_lockfile(); - let module_specifier = - resolve_url_or_path(&source_file, cli_options.initial_cwd())?; - + let module_specifiers: Result<Vec<ModuleSpecifier>, AnyError> = + source_files + .iter() + .map(|source_file| { + Ok(resolve_url_or_path(source_file, cli_options.initial_cwd())?) + }) + .collect(); + let module_specifiers = module_specifiers?; let mut loader = module_graph_builder.create_graph_loader(); let graph = module_graph_builder .create_graph_with_options(CreateGraphOptions { graph_kind: GraphKind::TypesOnly, - roots: vec![module_specifier.clone()], + roots: module_specifiers.clone(), loader: &mut loader, analyzer: &analyzer, }) @@ -85,8 +90,17 @@ pub async fn print_docs( graph_lock_or_exit(&graph, &mut lockfile.lock()); } - doc::DocParser::new(&graph, doc_flags.private, capturing_parser)? - .parse_with_reexports(&module_specifier)? + let doc_parser = + doc::DocParser::new(&graph, doc_flags.private, capturing_parser)?; + + let mut doc_nodes = vec![]; + + for module_specifier in module_specifiers { + let nodes = doc_parser.parse_with_reexports(&module_specifier)?; + doc_nodes.extend_from_slice(&nodes); + } + + doc_nodes } }; |