diff options
Diffstat (limited to 'cli/flags.rs')
-rw-r--r-- | cli/flags.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 313d8ff1a..80e856581 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -23,6 +23,7 @@ pub enum DenoSubcommand { buf: Box<[u8]>, }, Doc { + private: bool, json: bool, source_file: Option<String>, filter: Option<String>, @@ -598,12 +599,14 @@ fn doc_parse(flags: &mut Flags, matches: &clap::ArgMatches) { unstable_arg_parse(flags, matches); let source_file = matches.value_of("source_file").map(String::from); + let private = matches.is_present("private"); let json = matches.is_present("json"); let filter = matches.value_of("filter").map(String::from); flags.subcommand = DenoSubcommand::Doc { source_file, json, filter, + private, }; } @@ -915,6 +918,9 @@ fn doc_subcommand<'a, 'b>() -> App<'a, 'b> { Output documentation to standard output: deno doc ./path/to/module.ts +Output private documentation to standard output: + deno doc --private ./path/to/module.ts + Output documentation in JSON format: deno doc --json ./path/to/module.ts @@ -932,6 +938,12 @@ Show documentation for runtime built-ins: .help("Output documentation in JSON format.") .takes_value(false), ) + .arg( + Arg::with_name("private") + .long("private") + .help("Output private documentation") + .takes_value(false), + ) // TODO(nayeemrmn): Make `--builtin` a proper option. Blocked by // https://github.com/clap-rs/clap/issues/1794. Currently `--builtin` is // just a possible value of `source_file` so leading hyphens must be @@ -2910,6 +2922,7 @@ mod tests { r.unwrap(), Flags { subcommand: DenoSubcommand::Doc { + private: false, json: true, source_file: Some("path/to/module.ts".to_string()), filter: None, @@ -2928,6 +2941,7 @@ mod tests { r.unwrap(), Flags { subcommand: DenoSubcommand::Doc { + private: false, json: false, source_file: Some("path/to/module.ts".to_string()), filter: Some("SomeClass.someField".to_string()), @@ -2941,6 +2955,7 @@ mod tests { r.unwrap(), Flags { subcommand: DenoSubcommand::Doc { + private: false, json: false, source_file: None, filter: None, @@ -2955,6 +2970,7 @@ mod tests { r.unwrap(), Flags { subcommand: DenoSubcommand::Doc { + private: false, json: false, source_file: Some("--builtin".to_string()), filter: Some("Deno.Listener".to_string()), @@ -2962,6 +2978,25 @@ mod tests { ..Flags::default() } ); + + let r = flags_from_vec_safe(svec![ + "deno", + "doc", + "--private", + "path/to/module.js" + ]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Doc { + private: true, + json: false, + source_file: Some("path/to/module.js".to_string()), + filter: None, + }, + ..Flags::default() + } + ); } #[test] |