summaryrefslogtreecommitdiff
path: root/cli/main.rs
diff options
context:
space:
mode:
authorValentin Anger <syrupthinker@gryphno.de>2020-07-12 14:16:33 +0200
committerGitHub <noreply@github.com>2020-07-12 14:16:33 +0200
commit3374c73fba3a96df22d0c04e6c17078ca8cce45b (patch)
tree91d996554a2e276724a86ecb3bff19ea5411238b /cli/main.rs
parent871f9255e37b4d2e63439c84da8e9bed6b388034 (diff)
feat(doc): Improve terminal printer (#6594)
- Add more support for generics - Add the --private flag - displays documentation for not exported and private nodes - Display more attributes like abstract, static and readonly - Display type aliases - Refactor module to use the Display trait - Use a bit more color
Diffstat (limited to 'cli/main.rs')
-rw-r--r--cli/main.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 9669d0938..088d65ecd 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -521,6 +521,7 @@ async fn doc_command(
source_file: Option<String>,
json: bool,
maybe_filter: Option<String>,
+ private: bool,
) -> Result<(), ErrBox> {
let global_state = GlobalState::new(flags.clone())?;
let source_file = source_file.unwrap_or_else(|| "--builtin".to_string());
@@ -546,7 +547,7 @@ async fn doc_command(
}
let loader = Box::new(global_state.file_fetcher.clone());
- let doc_parser = doc::DocParser::new(loader);
+ let doc_parser = doc::DocParser::new(loader, private);
let parse_result = if source_file == "--builtin" {
doc_parser.parse_source("lib.deno.d.ts", get_types(flags.unstable).as_str())
@@ -576,13 +577,9 @@ async fn doc_command(
eprintln!("Node {} was not found!", filter);
std::process::exit(1);
}
- let mut details = String::new();
- for node in nodes {
- details.push_str(doc::printer::format_details(node).as_str());
- }
- details
+ format!("{}", doc::DocPrinter::new(&nodes, true, private))
} else {
- doc::printer::format(doc_nodes)
+ format!("{}", doc::DocPrinter::new(&doc_nodes, false, private))
};
write_to_stdout_ignore_sigpipe(details.as_bytes()).map_err(ErrBox::from)
@@ -720,7 +717,8 @@ pub fn main() {
source_file,
json,
filter,
- } => doc_command(flags, source_file, json, filter).boxed_local(),
+ private,
+ } => doc_command(flags, source_file, json, filter, private).boxed_local(),
DenoSubcommand::Eval {
print,
code,