diff options
| author | Luca Palmieri <rust@lpalmieri.com> | 2022-09-14 13:49:05 +0200 |
|---|---|---|
| committer | Luca Palmieri <rust@lpalmieri.com> | 2022-09-17 21:58:34 +0200 |
| commit | 235dccef2b8012e7d9da87f4b6091912d802cff2 (patch) | |
| tree | 5bc6336a2eaba7770223d3e83a724656ef53c78f /src/bootstrap/flags.rs | |
| parent | 9da4644d5685aa0c4daa4aea6ddc9eb834ae51cc (diff) | |
| download | rust-235dccef2b8012e7d9da87f4b6091912d802cff2.tar.gz rust-235dccef2b8012e7d9da87f4b6091912d802cff2.zip | |
Add a new component, `rust-json-docs`, to distribute the JSON-formatted documentation for std crates in nightly toolchains.
We also add a new flag to `x doc`, `--json`, to render the JSON-formatted version alongside the HTML-formatted one.
Diffstat (limited to 'src/bootstrap/flags.rs')
| -rw-r--r-- | src/bootstrap/flags.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 789da748100..802b49d748a 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -107,6 +107,7 @@ pub enum Subcommand { Doc { paths: Vec<PathBuf>, open: bool, + json: bool, }, Test { paths: Vec<PathBuf>, @@ -325,6 +326,11 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`", } Kind::Doc => { opts.optflag("", "open", "open the docs in a browser"); + opts.optflag( + "", + "json", + "render the documentation in JSON format in addition to the usual HTML format", + ); } Kind::Clean => { opts.optflag("", "all", "clean all build artifacts"); @@ -493,6 +499,7 @@ Arguments: ./x.py doc src/doc/book ./x.py doc src/doc/nomicon ./x.py doc src/doc/book library/std + ./x.py doc library/std --json ./x.py doc library/std --open If no arguments are passed then everything is documented: @@ -581,7 +588,11 @@ Arguments: }, }, Kind::Bench => Subcommand::Bench { paths, test_args: matches.opt_strs("test-args") }, - Kind::Doc => Subcommand::Doc { paths, open: matches.opt_present("open") }, + Kind::Doc => Subcommand::Doc { + paths, + open: matches.opt_present("open"), + json: matches.opt_present("json"), + }, Kind::Clean => { if !paths.is_empty() { println!("\nclean does not take a path argument\n"); @@ -787,6 +798,13 @@ impl Subcommand { _ => false, } } + + pub fn json(&self) -> bool { + match *self { + Subcommand::Doc { json, .. } => json, + _ => false, + } + } } fn split(s: &[String]) -> Vec<String> { |
