Skip to content

Commit

Permalink
Don't filter on workspace members when scraping doc examples
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 30, 2023
1 parent 95a27cd commit 689d9a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ fn prepare_rustdoc(cx: &Context<'_, '_>, unit: &Unit) -> CargoResult<ProcessBuil
.arg(scrape_output_path(cx, unit)?);

// Only scrape example for items from crates in the workspace, to reduce generated file size
for pkg in cx.bcx.ws.members() {
for pkg in cx.bcx.packages.packages() {
let names = pkg
.targets()
.iter()
Expand Down
7 changes: 3 additions & 4 deletions tests/testsuite/docscrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ fn basic() {
assert!(p.build_dir().join("doc/src/ex/ex.rs.html").exists());
}

// This test ensures that if there is no `[workspace]` in the top-level `Cargo.toml` file, the
// dependencies will not get their examples scraped and that they appear in the generated
// documentation.
// This test ensures that even if there is no `[workspace]` in the top-level `Cargo.toml` file, the
// dependencies will get their examples scraped and that they appear in the generated documentation.
#[cargo_test(nightly, reason = "-Zrustdoc-scrape-examples is unstable")]
fn scrape_examples_for_non_workspace_reexports() {
let p = project()
Expand Down Expand Up @@ -124,7 +123,7 @@ impl Foo {
.run();

let doc_html = p.read_file("target/doc/foo/struct.Foo.html");
assert!(!doc_html.contains("Examples found in repository"));
assert!(doc_html.contains("Examples found in repository"));
}

#[cargo_test(nightly, reason = "rustdoc scrape examples flags are unstable")]
Expand Down

0 comments on commit 689d9a7

Please sign in to comment.