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.
This commit is contained in:
parent
9da4644d56
commit
235dccef2b
6 changed files with 218 additions and 61 deletions
|
|
@ -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> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue