Skip to content

Commit c6e9d82

Browse files
committed
change names of flags in response to comments
1 parent eef6670 commit c6e9d82

File tree

2 files changed

+46
-29
lines changed

2 files changed

+46
-29
lines changed

src/librustdoc/config.rs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ impl Options {
506506
Err(err) => dcx.fatal(err),
507507
};
508508

509-
let parts_paths = match parse_fetch_parts(matches) {
509+
let parts_paths = match parse_include_info_json(matches) {
510510
Ok(ex) => ex,
511511
Err(err) => dcx.fatal(err),
512512
};
@@ -751,13 +751,11 @@ impl Options {
751751
let extern_html_root_takes_precedence =
752752
matches.opt_present("extern-html-root-takes-precedence");
753753
let html_no_source = matches.opt_present("html-no-source");
754-
let Ok(read_rendered_cci) = matches.opt_get_default("read-rendered-cci", true) else {
755-
dcx.fatal(format!("read-rendered-cci only accepts true and false"))
754+
let MergeResult { read_rendered_cci, write_rendered_cci } = match parse_merge(matches) {
755+
Ok(result) => result,
756+
Err(e) => dcx.fatal(format!("could not parse --merge: {e}")),
756757
};
757-
let Ok(write_rendered_cci) = matches.opt_get_default("write-rendered-cci", true) else {
758-
dcx.fatal(format!("write-rendered-cci only accepts true and false"))
759-
};
760-
let parts_out_dir = matches.opt_str("parts-out-dir").map(PathBuf::from).map(PathToParts::from_doc_root);
758+
let parts_out_dir = matches.opt_str("write-info-json").map(|p| PathToParts::from_doc_root(PathBuf::from(p)));
761759

762760
if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
763761
dcx.fatal(
@@ -943,17 +941,35 @@ impl PathToParts {
943941
}
944942
}
945943

946-
/// Extracts `--fetch-parts` arguments from `matches` and returns a map of crate names to
947-
/// the given locations. If an `--fetch-parts` argument was ill-formed, returns an error
944+
/// Extracts `--include-info-json` arguments from `matches` and returns a map of crate names to
945+
/// the given locations. If an `--include-info-json` argument was ill-formed, returns an error
948946
/// describing the issue.
949-
fn parse_fetch_parts(
947+
fn parse_include_info_json(
950948
matches: &getopts::Matches,
951949
) -> Result<FxHashMap<String, PathToParts>, &'static str> {
952950
let mut externs = FxHashMap::default();
953-
for arg in &matches.opt_strs("fetch-parts") {
951+
for arg in &matches.opt_strs("include-info-json") {
954952
let (name, path) =
955-
arg.split_once('=').ok_or("--fetch-parts must be of the form name=path")?;
953+
arg.split_once('=').ok_or("--include-info-json must be of the form NAME=PATH")?;
956954
externs.insert(name.to_string(), PathToParts::from_doc_root(PathBuf::from(path)));
957955
}
958956
Ok(externs)
959957
}
958+
959+
struct MergeResult {
960+
read_rendered_cci: bool,
961+
write_rendered_cci: bool,
962+
}
963+
964+
/// Extracts read_rendered_cci and write_rendered_cci from command line arguments, or
965+
/// reports an error.
966+
fn parse_merge(matches: &getopts::Matches) -> Result<MergeResult, &'static str> {
967+
match matches.opt_str("merge").as_deref() {
968+
// default = auto
969+
None => Ok(MergeResult { read_rendered_cci: true, write_rendered_cci: true }),
970+
Some("auto") => Ok(MergeResult { read_rendered_cci: true, write_rendered_cci: true }),
971+
Some("none") => Ok(MergeResult { read_rendered_cci: false, write_rendered_cci: false }),
972+
Some("write-only") => Ok(MergeResult { read_rendered_cci: false, write_rendered_cci: true }),
973+
Some(_) => Err("argument to --merge must be `auto`, `none`, or `write-only`"),
974+
}
975+
}

src/librustdoc/lib.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -603,32 +603,33 @@ fn opts() -> Vec<RustcOptGroup> {
603603
"path to function call information (for displaying examples in the documentation)",
604604
)
605605
}),
606-
unstable("write-rendered-cci", |o| {
606+
unstable("merge", |o| {
607607
o.optopt(
608608
"",
609-
"write-rendered-cci",
610-
"Writes merged cross-crate information to the doc root. \
611-
Defaults to true.",
612-
"[true|false]",
609+
"merge",
610+
"Controls how rustdoc handles files from previously documented crates in the doc root.
611+
auto = append (default)
612+
none = do not write new versions of these files
613+
write-only = overwrite these files without reading previous content",
614+
"auto|none|write-only",
613615
)
614616
}),
615-
unstable("read-rendered-cci", |o| {
616-
o.optopt(
617+
unstable("include-info-json", |o| {
618+
o.optmulti(
617619
"",
618-
"read-rendered-cci",
619-
"Reads partial cross-crate information from the doc root. \
620-
Defaults to true.",
621-
"[true|false]",
620+
"include-info-json",
621+
"Includes trait implementations and other crate info from PATH/CRATE/crate-info.json",
622+
"CRATE=PATH",
622623
)
623624
}),
624-
unstable("fetch-parts", |o| {
625-
o.optmulti(
625+
unstable("write-info-json", |o| {
626+
o.optopt(
626627
"",
627-
"fetch-parts",
628-
"appends cross-crate information fetched from PATH to the output",
629-
"NAME=PATH")
628+
"write-info-json",
629+
"Writes trait implementations and other info for the current crate to PATH/<crate name>/crate-info.json",
630+
"PATH",
631+
)
630632
}),
631-
unstable("parts-out-dir", |o| o.optopt("", "parts-out-dir", "which directory to place the cross-crate information doc parts", "PATH")),
632633
// deprecated / removed options
633634
unstable("disable-minification", |o| o.optflagmulti("", "disable-minification", "removed")),
634635
stable("plugin-path", |o| {

0 commit comments

Comments
 (0)