1 use std::collections::BTreeMap;
2 use std::convert::TryFrom;
5 use std::path::PathBuf;
8 use rustc_data_structures::fx::FxHashMap;
9 use rustc_session::config::{
10 self, parse_crate_types_from_list, parse_externs, parse_target_triple, CrateType,
12 use rustc_session::config::{get_cmd_lint_options, nightly_options};
13 use rustc_session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, Externs};
14 use rustc_session::getopts;
15 use rustc_session::lint::Level;
16 use rustc_session::search_paths::SearchPath;
17 use rustc_span::edition::Edition;
18 use rustc_target::spec::TargetTriple;
20 use crate::core::new_handler;
21 use crate::externalfiles::ExternalHtml;
23 use crate::html::markdown::IdMap;
24 use crate::html::render::StylePath;
25 use crate::html::static_files;
27 use crate::passes::{self, Condition, DefaultPassOption};
30 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
31 crate enum OutputFormat {
36 impl Default for OutputFormat {
37 fn default() -> OutputFormat {
43 crate fn is_json(&self) -> bool {
44 matches!(self, OutputFormat::Json)
48 impl TryFrom<&str> for OutputFormat {
51 fn try_from(value: &str) -> Result<Self, Self::Error> {
53 "json" => Ok(OutputFormat::Json),
54 "html" => Ok(OutputFormat::Html),
55 _ => Err(format!("unknown output format `{}`", value)),
60 /// Configuration options for rustdoc.
62 crate struct Options {
63 // Basic options / Options passed directly to rustc
64 /// The crate root or Markdown file to load.
66 /// The name of the crate being documented.
67 crate crate_name: Option<String>,
68 /// Whether or not this is a proc-macro crate
69 crate proc_macro_crate: bool,
70 /// How to format errors and warnings.
71 crate error_format: ErrorOutputType,
72 /// Library search paths to hand to the compiler.
73 crate libs: Vec<SearchPath>,
74 /// Library search paths strings to hand to the compiler.
75 crate lib_strs: Vec<String>,
76 /// The list of external crates to link against.
77 crate externs: Externs,
78 /// The list of external crates strings to link against.
79 crate extern_strs: Vec<String>,
80 /// List of `cfg` flags to hand to the compiler. Always includes `rustdoc`.
81 crate cfgs: Vec<String>,
82 /// Codegen options to hand to the compiler.
83 crate codegen_options: CodegenOptions,
84 /// Codegen options strings to hand to the compiler.
85 crate codegen_options_strs: Vec<String>,
86 /// Debugging (`-Z`) options to pass to the compiler.
87 crate debugging_opts: DebuggingOptions,
88 /// Debugging (`-Z`) options strings to pass to the compiler.
89 crate debugging_opts_strs: Vec<String>,
90 /// The target used to compile the crate against.
91 crate target: TargetTriple,
92 /// Edition used when reading the crate. Defaults to "2015". Also used by default when
93 /// compiling doctests from the crate.
94 crate edition: Edition,
95 /// The path to the sysroot. Used during the compilation process.
96 crate maybe_sysroot: Option<PathBuf>,
97 /// Lint information passed over the command-line.
98 crate lint_opts: Vec<(String, Level)>,
99 /// Whether to ask rustc to describe the lints it knows.
100 crate describe_lints: bool,
101 /// What level to cap lints at.
102 crate lint_cap: Option<Level>,
104 // Options specific to running doctests
105 /// Whether we should run doctests instead of generating docs.
106 crate should_test: bool,
107 /// List of arguments to pass to the test harness, if running tests.
108 crate test_args: Vec<String>,
109 /// The working directory in which to run tests.
110 crate test_run_directory: Option<PathBuf>,
111 /// Optional path to persist the doctest executables to, defaults to a
112 /// temporary directory if not set.
113 crate persist_doctests: Option<PathBuf>,
114 /// Runtool to run doctests with
115 crate runtool: Option<String>,
116 /// Arguments to pass to the runtool
117 crate runtool_args: Vec<String>,
118 /// Whether to allow ignoring doctests on a per-target basis
119 /// For example, using ignore-foo to ignore running the doctest on any target that
120 /// contains "foo" as a substring
121 crate enable_per_target_ignores: bool,
122 /// Do not run doctests, compile them if should_test is active.
125 /// The path to a rustc-like binary to build tests with. If not set, we
126 /// default to loading from `$sysroot/bin/rustc`.
127 crate test_builder: Option<PathBuf>,
129 // Options that affect the documentation process
130 /// The selected default set of passes to use.
132 /// Be aware: This option can come both from the CLI and from crate attributes!
133 crate default_passes: DefaultPassOption,
134 /// Any passes manually selected by the user.
136 /// Be aware: This option can come both from the CLI and from crate attributes!
137 crate manual_passes: Vec<String>,
138 /// Whether to display warnings during doc generation or while gathering doctests. By default,
139 /// all non-rustdoc-specific lints are allowed when generating docs.
140 crate display_warnings: bool,
141 /// Whether to run the `calculate-doc-coverage` pass, which counts the number of public items
142 /// with and without documentation.
143 crate show_coverage: bool,
145 // Options that alter generated documentation pages
146 /// Crate version to note on the sidebar of generated docs.
147 crate crate_version: Option<String>,
148 /// Collected options specific to outputting final pages.
149 crate render_options: RenderOptions,
150 /// The format that we output when rendering.
152 /// Currently used only for the `--show-coverage` option.
153 crate output_format: OutputFormat,
154 /// If this option is set to `true`, rustdoc will only run checks and not generate
156 crate run_check: bool,
157 /// Whether doctests should emit unused externs
158 crate json_unused_externs: bool,
159 /// Whether to skip capturing stdout and stderr of tests.
160 crate nocapture: bool,
163 impl fmt::Debug for Options {
164 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
165 struct FmtExterns<'a>(&'a Externs);
167 impl<'a> fmt::Debug for FmtExterns<'a> {
168 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
169 f.debug_map().entries(self.0.iter()).finish()
173 f.debug_struct("Options")
174 .field("input", &self.input)
175 .field("crate_name", &self.crate_name)
176 .field("proc_macro_crate", &self.proc_macro_crate)
177 .field("error_format", &self.error_format)
178 .field("libs", &self.libs)
179 .field("externs", &FmtExterns(&self.externs))
180 .field("cfgs", &self.cfgs)
181 .field("codegen_options", &"...")
182 .field("debugging_options", &"...")
183 .field("target", &self.target)
184 .field("edition", &self.edition)
185 .field("maybe_sysroot", &self.maybe_sysroot)
186 .field("lint_opts", &self.lint_opts)
187 .field("describe_lints", &self.describe_lints)
188 .field("lint_cap", &self.lint_cap)
189 .field("should_test", &self.should_test)
190 .field("test_args", &self.test_args)
191 .field("test_run_directory", &self.test_run_directory)
192 .field("persist_doctests", &self.persist_doctests)
193 .field("default_passes", &self.default_passes)
194 .field("manual_passes", &self.manual_passes)
195 .field("display_warnings", &self.display_warnings)
196 .field("show_coverage", &self.show_coverage)
197 .field("crate_version", &self.crate_version)
198 .field("render_options", &self.render_options)
199 .field("runtool", &self.runtool)
200 .field("runtool_args", &self.runtool_args)
201 .field("enable-per-target-ignores", &self.enable_per_target_ignores)
202 .field("run_check", &self.run_check)
203 .field("no_run", &self.no_run)
204 .field("nocapture", &self.nocapture)
209 /// Configuration options for the HTML page-creation process.
210 #[derive(Clone, Debug)]
211 crate struct RenderOptions {
212 /// Output directory to generate docs into. Defaults to `doc`.
213 crate output: PathBuf,
214 /// External files to insert into generated pages.
215 crate external_html: ExternalHtml,
216 /// A pre-populated `IdMap` with the default headings and any headings added by Markdown files
217 /// processed by `external_html`.
219 /// If present, playground URL to use in the "Run" button added to code samples.
221 /// Be aware: This option can come both from the CLI and from crate attributes!
222 crate playground_url: Option<String>,
223 /// Whether to sort modules alphabetically on a module page instead of using declaration order.
224 /// `true` by default.
226 // FIXME(misdreavus): the flag name is `--sort-modules-by-appearance` but the meaning is
227 // inverted once read.
228 crate sort_modules_alphabetically: bool,
229 /// List of themes to extend the docs with. Original argument name is included to assist in
230 /// displaying errors if it fails a theme check.
231 crate themes: Vec<StylePath>,
232 /// If present, CSS file that contains rules to add to the default CSS.
233 crate extension_css: Option<PathBuf>,
234 /// A map of crate names to the URL to use instead of querying the crate's `html_root_url`.
235 crate extern_html_root_urls: BTreeMap<String, String>,
236 /// Whether to give precedence to `html_root_url` or `--exten-html-root-url`.
237 crate extern_html_root_takes_precedence: bool,
238 /// A map of the default settings (values are as for DOM storage API). Keys should lack the
239 /// `rustdoc-` prefix.
240 crate default_settings: FxHashMap<String, String>,
241 /// If present, suffix added to CSS/JavaScript files when referencing them in generated pages.
242 crate resource_suffix: String,
243 /// Whether to run the static CSS/JavaScript through a minifier when outputting them. `true` by
246 // FIXME(misdreavus): the flag name is `--disable-minification` but the meaning is inverted
248 crate enable_minification: bool,
249 /// Whether to create an index page in the root of the output directory. If this is true but
250 /// `enable_index_page` is None, generate a static listing of crates instead.
251 crate enable_index_page: bool,
252 /// A file to use as the index page at the root of the output directory. Overrides
253 /// `enable_index_page` to be true if set.
254 crate index_page: Option<PathBuf>,
255 /// An optional path to use as the location of static files. If not set, uses combinations of
256 /// `../` to reach the documentation root.
257 crate static_root_path: Option<String>,
259 // Options specific to reading standalone Markdown files
260 /// Whether to generate a table of contents on the output file when reading a standalone
262 crate markdown_no_toc: bool,
263 /// Additional CSS files to link in pages generated from standalone Markdown files.
264 crate markdown_css: Vec<String>,
265 /// If present, playground URL to use in the "Run" button added to code samples generated from
266 /// standalone Markdown files. If not present, `playground_url` is used.
267 crate markdown_playground_url: Option<String>,
268 /// If false, the `select` element to have search filtering by crates on rendered docs
269 /// won't be generated.
270 crate generate_search_filter: bool,
271 /// Document items that have lower than `pub` visibility.
272 crate document_private: bool,
273 /// Document items that have `doc(hidden)`.
274 crate document_hidden: bool,
275 /// If `true`, generate a JSON file in the crate folder instead of HTML redirection files.
276 crate generate_redirect_map: bool,
277 /// Show the memory layout of types in the docs.
278 crate show_type_layout: bool,
279 crate unstable_features: rustc_feature::UnstableFeatures,
280 crate emit: Vec<EmitType>,
281 /// If `true`, HTML source pages will generate links for items to their definition.
282 crate generate_link_to_definition: bool,
285 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
286 crate enum EmitType {
292 impl FromStr for EmitType {
295 fn from_str(s: &str) -> Result<Self, Self::Err> {
298 "unversioned-shared-resources" => Ok(Unversioned),
299 "toolchain-shared-resources" => Ok(Toolchain),
300 "invocation-specific" => Ok(InvocationSpecific),
307 crate fn should_emit_crate(&self) -> bool {
308 self.emit.is_empty() || self.emit.contains(&EmitType::InvocationSpecific)
313 /// Parses the given command-line for options. If an error message or other early-return has
314 /// been printed, returns `Err` with the exit code.
315 crate fn from_matches(matches: &getopts::Matches) -> Result<Options, i32> {
316 // Check for unstable options.
317 nightly_options::check_nightly_options(&matches, &opts());
319 if matches.opt_present("h") || matches.opt_present("help") {
320 crate::usage("rustdoc");
322 } else if matches.opt_present("version") {
323 rustc_driver::version("rustdoc", &matches);
327 if matches.opt_strs("passes") == ["list"] {
328 println!("Available passes for running rustdoc:");
329 for pass in passes::PASSES {
330 println!("{:>20} - {}", pass.name, pass.description);
332 println!("\nDefault passes for rustdoc:");
333 for p in passes::DEFAULT_PASSES {
334 print!("{:>20}", p.pass.name);
335 println_condition(p.condition);
338 if nightly_options::match_is_nightly_build(matches) {
339 println!("\nPasses run with `--show-coverage`:");
340 for p in passes::COVERAGE_PASSES {
341 print!("{:>20}", p.pass.name);
342 println_condition(p.condition);
346 fn println_condition(condition: Condition) {
349 Always => println!(),
350 WhenDocumentPrivate => println!(" (when --document-private-items)"),
351 WhenNotDocumentPrivate => println!(" (when not --document-private-items)"),
352 WhenNotDocumentHidden => println!(" (when not --document-hidden-items)"),
359 let color = config::parse_color(&matches);
360 let config::JsonConfig { json_rendered, json_unused_externs, .. } =
361 config::parse_json(&matches);
362 let error_format = config::parse_error_format(&matches, color, json_rendered);
364 let codegen_options = CodegenOptions::build(matches, error_format);
365 let debugging_opts = DebuggingOptions::build(matches, error_format);
367 let diag = new_handler(error_format, None, &debugging_opts);
369 // check for deprecated options
370 check_deprecated_options(&matches, &diag);
372 let mut emit = Vec::new();
373 for list in matches.opt_strs("emit") {
374 for kind in list.split(',') {
376 Ok(kind) => emit.push(kind),
378 diag.err(&format!("unrecognized emission type: {}", kind));
385 // check for `--output-format=json`
386 if !matches!(matches.opt_str("output-format").as_deref(), None | Some("html"))
387 && !matches.opt_present("show-coverage")
388 && !nightly_options::is_unstable_enabled(matches)
390 rustc_session::early_error(
392 "the -Z unstable-options flag must be passed to enable --output-format for documentation generation (see https://github.com/rust-lang/rust/issues/76578)",
396 let to_check = matches.opt_strs("check-theme");
397 if !to_check.is_empty() {
398 let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
401 println!("rustdoc: [check-theme] Starting tests! (Ignoring all other arguments)");
402 for theme_file in to_check.iter() {
403 print!(" - Checking \"{}\"...", theme_file);
404 let (success, differences) = theme::test_theme_against(theme_file, &paths, &diag);
405 if !differences.is_empty() || !success {
408 if !differences.is_empty() {
409 println!("{}", differences.join("\n"));
421 if matches.free.is_empty() {
422 diag.struct_err("missing file operand").emit();
425 if matches.free.len() > 1 {
426 diag.struct_err("too many file operands").emit();
429 let input = PathBuf::from(&matches.free[0]);
434 .map(|s| SearchPath::from_cli_opt(s, error_format))
436 let externs = parse_externs(&matches, &debugging_opts, error_format);
437 let extern_html_root_urls = match parse_extern_html_roots(&matches) {
440 diag.struct_err(err).emit();
445 let default_settings: Vec<Vec<(String, String)>> = vec![
447 .opt_str("default-theme")
451 ("use-system-theme".to_string(), "false".to_string()),
452 ("theme".to_string(), theme.to_string()),
458 .opt_strs("default-setting")
460 .map(|s| match s.split_once('=') {
461 None => (s.clone(), "true".to_string()),
462 Some((k, v)) => (k.to_string(), v.to_string()),
466 let default_settings = default_settings
470 // The keys here become part of `data-` attribute names in the generated HTML. The
471 // browser does a strange mapping when converting them into attributes on the
472 // `dataset` property on the DOM HTML Node:
473 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
475 // The original key values we have are the same as the DOM storage API keys and the
476 // command line options, so contain `-`. Our Javascript needs to be able to look
477 // these values up both in `dataset` and in the storage API, so it needs to be able
478 // to convert the names back and forth. Despite doing this kebab-case to
479 // StudlyCaps transformation automatically, the JS DOM API does not provide a
480 // mechanism for doing the just transformation on a string. So we want to avoid
481 // the StudlyCaps representation in the `dataset` property.
483 // We solve this by replacing all the `-`s with `_`s. We do that here, when we
484 // generate the `data-` attributes, and in the JS, when we look them up. (See
485 // `getSettingValue` in `storage.js.`) Converting `-` to `_` is simple in JS.
487 // The values will be HTML-escaped by the default Tera escaping.
488 |(k, v)| (k.replace('-', "_"), v),
492 let test_args = matches.opt_strs("test-args");
493 let test_args: Vec<String> =
494 test_args.iter().flat_map(|s| s.split_whitespace()).map(|s| s.to_string()).collect();
496 let should_test = matches.opt_present("test");
497 let no_run = matches.opt_present("no-run");
499 if !should_test && no_run {
500 diag.err("the `--test` flag must be passed to enable `--no-run`");
505 matches.opt_str("o").map(|s| PathBuf::from(&s)).unwrap_or_else(|| PathBuf::from("doc"));
506 let cfgs = matches.opt_strs("cfg");
508 let extension_css = matches.opt_str("e").map(|s| PathBuf::from(&s));
510 if let Some(ref p) = extension_css {
512 diag.struct_err("option --extend-css argument must be a file").emit();
517 let mut themes = Vec::new();
518 if matches.opt_present("theme") {
519 let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
521 for (theme_file, theme_s) in
522 matches.opt_strs("theme").iter().map(|s| (PathBuf::from(&s), s.to_owned()))
524 if !theme_file.is_file() {
525 diag.struct_err(&format!("invalid argument: \"{}\"", theme_s))
526 .help("arguments to --theme must be files")
530 if theme_file.extension() != Some(OsStr::new("css")) {
531 diag.struct_err(&format!("invalid argument: \"{}\"", theme_s))
532 .help("arguments to --theme must have a .css extension")
536 let (success, ret) = theme::test_theme_against(&theme_file, &paths, &diag);
538 diag.struct_err(&format!("error loading theme file: \"{}\"", theme_s)).emit();
540 } else if !ret.is_empty() {
541 diag.struct_warn(&format!(
542 "theme file \"{}\" is missing CSS rules from the default theme",
545 .warn("the theme may appear incorrect when loaded")
547 "to see what rules are missing, call `rustdoc --check-theme \"{}\"`",
552 themes.push(StylePath { path: theme_file, disabled: true });
556 let edition = config::parse_crate_edition(&matches);
558 let mut id_map = html::markdown::IdMap::new();
559 let external_html = match ExternalHtml::load(
560 &matches.opt_strs("html-in-header"),
561 &matches.opt_strs("html-before-content"),
562 &matches.opt_strs("html-after-content"),
563 &matches.opt_strs("markdown-before-content"),
564 &matches.opt_strs("markdown-after-content"),
565 nightly_options::match_is_nightly_build(&matches),
572 None => return Err(3),
575 match matches.opt_str("r").as_deref() {
576 Some("rust") | None => {}
578 diag.struct_err(&format!("unknown input format: {}", s)).emit();
583 let index_page = matches.opt_str("index-page").map(|s| PathBuf::from(&s));
584 if let Some(ref index_page) = index_page {
585 if !index_page.is_file() {
586 diag.struct_err("option `--index-page` argument must be a file").emit();
591 let target = parse_target_triple(matches, error_format);
593 let show_coverage = matches.opt_present("show-coverage");
595 let default_passes = if matches.opt_present("no-defaults") {
596 passes::DefaultPassOption::None
597 } else if show_coverage {
598 passes::DefaultPassOption::Coverage
600 passes::DefaultPassOption::Default
602 let manual_passes = matches.opt_strs("passes");
604 let crate_types = match parse_crate_types_from_list(matches.opt_strs("crate-type")) {
607 diag.struct_err(&format!("unknown crate type: {}", e)).emit();
612 let output_format = match matches.opt_str("output-format") {
613 Some(s) => match OutputFormat::try_from(s.as_str()) {
615 if !out_fmt.is_json() && show_coverage {
617 "html output format isn't supported for the --show-coverage option",
625 diag.struct_err(&e).emit();
629 None => OutputFormat::default(),
631 let crate_name = matches.opt_str("crate-name");
632 let proc_macro_crate = crate_types.contains(&CrateType::ProcMacro);
633 let playground_url = matches.opt_str("playground-url");
634 let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
635 let display_warnings = matches.opt_present("display-warnings");
636 let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance");
637 let resource_suffix = matches.opt_str("resource-suffix").unwrap_or_default();
638 let enable_minification = !matches.opt_present("disable-minification");
639 let markdown_no_toc = matches.opt_present("markdown-no-toc");
640 let markdown_css = matches.opt_strs("markdown-css");
641 let markdown_playground_url = matches.opt_str("markdown-playground-url");
642 let crate_version = matches.opt_str("crate-version");
643 let enable_index_page = matches.opt_present("enable-index-page") || index_page.is_some();
644 let static_root_path = matches.opt_str("static-root-path");
645 let generate_search_filter = !matches.opt_present("disable-per-crate-search");
646 let test_run_directory = matches.opt_str("test-run-directory").map(PathBuf::from);
647 let persist_doctests = matches.opt_str("persist-doctests").map(PathBuf::from);
648 let test_builder = matches.opt_str("test-builder").map(PathBuf::from);
649 let codegen_options_strs = matches.opt_strs("C");
650 let debugging_opts_strs = matches.opt_strs("Z");
651 let lib_strs = matches.opt_strs("L");
652 let extern_strs = matches.opt_strs("extern");
653 let runtool = matches.opt_str("runtool");
654 let runtool_args = matches.opt_strs("runtool-arg");
655 let enable_per_target_ignores = matches.opt_present("enable-per-target-ignores");
656 let document_private = matches.opt_present("document-private-items");
657 let document_hidden = matches.opt_present("document-hidden-items");
658 let run_check = matches.opt_present("check");
659 let generate_redirect_map = matches.opt_present("generate-redirect-map");
660 let show_type_layout = matches.opt_present("show-type-layout");
661 let nocapture = matches.opt_present("nocapture");
662 let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
663 let extern_html_root_takes_precedence =
664 matches.opt_present("extern-html-root-takes-precedence");
666 if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
668 "--generate-link-to-definition option can only be used with HTML output format",
674 let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
686 codegen_options_strs,
706 enable_per_target_ignores,
711 render_options: RenderOptions {
716 sort_modules_alphabetically,
719 extern_html_root_urls,
720 extern_html_root_takes_precedence,
729 markdown_playground_url,
730 generate_search_filter,
733 generate_redirect_map,
735 unstable_features: rustc_feature::UnstableFeatures::from_environment(
736 crate_name.as_deref(),
739 generate_link_to_definition,
747 /// Returns `true` if the file given as `self.input` is a Markdown file.
748 crate fn markdown_input(&self) -> bool {
749 self.input.extension().map_or(false, |e| e == "md" || e == "markdown")
753 /// Prints deprecation warnings for deprecated options
754 fn check_deprecated_options(matches: &getopts::Matches, diag: &rustc_errors::Handler) {
755 let deprecated_flags = ["input-format", "no-defaults", "passes"];
757 for flag in deprecated_flags.iter() {
758 if matches.opt_present(flag) {
759 let mut err = diag.struct_warn(&format!("the `{}` flag is deprecated", flag));
761 "see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \
762 for more information",
765 if *flag == "no-defaults" {
766 err.help("you may want to use --document-private-items");
773 let removed_flags = ["plugins", "plugin-path"];
775 for &flag in removed_flags.iter() {
776 if matches.opt_present(flag) {
777 diag.struct_warn(&format!("the '{}' flag no longer functions", flag))
778 .warn("see CVE-2018-1000622")
784 /// Extracts `--extern-html-root-url` arguments from `matches` and returns a map of crate names to
785 /// the given URLs. If an `--extern-html-root-url` argument was ill-formed, returns an error
786 /// describing the issue.
787 fn parse_extern_html_roots(
788 matches: &getopts::Matches,
789 ) -> Result<BTreeMap<String, String>, &'static str> {
790 let mut externs = BTreeMap::new();
791 for arg in &matches.opt_strs("extern-html-root-url") {
793 arg.split_once('=').ok_or("--extern-html-root-url must be of the form name=url")?;
794 externs.insert(name.to_string(), url.to_string());