From bfaf027a3be3b0328756f4edb41360b9749f83aa Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sun, 29 Mar 2026 19:06:43 -0700 Subject: [PATCH] rustdoc: include index-page in dep-info --- src/librustdoc/config.rs | 10 ++++++---- tests/run-make/rustdoc-dep-info/index-page.md | 3 +++ tests/run-make/rustdoc-dep-info/rmake.rs | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 tests/run-make/rustdoc-dep-info/index-page.md diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index d721034c2d71..67d1105a5fa2 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -744,10 +744,12 @@ fn println_condition(condition: Condition) { } let index_page = matches.opt_str("index-page").map(|s| PathBuf::from(&s)); - if let Some(ref index_page) = index_page - && !index_page.is_file() - { - dcx.fatal("option `--index-page` argument must be a file"); + if let Some(ref index_page) = index_page { + if index_page.is_file() { + loaded_paths.push(index_page.clone()); + } else { + dcx.fatal("option `--index-page` argument must be a file"); + } } let target = parse_target_triple(early_dcx, matches); diff --git a/tests/run-make/rustdoc-dep-info/index-page.md b/tests/run-make/rustdoc-dep-info/index-page.md new file mode 100644 index 000000000000..95fa11ed0b76 --- /dev/null +++ b/tests/run-make/rustdoc-dep-info/index-page.md @@ -0,0 +1,3 @@ +% Index page + +Index page diff --git a/tests/run-make/rustdoc-dep-info/rmake.rs b/tests/run-make/rustdoc-dep-info/rmake.rs index 1e3d46bd4328..233225fde869 100644 --- a/tests/run-make/rustdoc-dep-info/rmake.rs +++ b/tests/run-make/rustdoc-dep-info/rmake.rs @@ -19,6 +19,7 @@ fn main() { .arg("--markdown-after-content=after.md") .arg("--extend-css=extend.css") .arg("--theme=theme.css") + .arg("--index-page=index-page.md") .emit("dep-info") .run(); @@ -31,6 +32,7 @@ fn main() { assert_contains(&content, "before.html:"); assert_contains(&content, "extend.css:"); assert_contains(&content, "theme.css:"); + assert_contains(&content, "index-page.md:"); // Now we check that we can provide a file name to the `dep-info` argument. rustdoc().input("lib.rs").arg("-Zunstable-options").emit("dep-info=bla.d").run(); @@ -80,6 +82,7 @@ fn main() { .arg("--markdown-after-content=after.md") .arg("--extend-css=extend.css") .arg("--theme=theme.css") + .arg("--index-page=index-page.md") .emit("dep-info=example.d") .run(); let content = rfs::read_to_string("example.d"); @@ -92,4 +95,5 @@ fn main() { assert_contains(&content, "before.html:"); assert_contains(&content, "extend.css:"); assert_contains(&content, "theme.css:"); + assert_contains(&content, "index-page.md:"); }