You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #11499 - willcrichton:example-analyzer, r=weihanglo
Don't scrape examples from library targets by default
### What does this PR try to resolve?
Based on some [early feedback](https://www.reddit.com/r/rust/comments/zosle6/feedback_requested_rustdocs_scraped_examples/) about the scrape-examples feature, both documentation authors and consumers did not consider examples useful if they are scraped from a library's internals, at least in the common case. Therefore this PR changes the default behavior of `-Zrustdoc-scrape-examples` to *only* scrape from example targets, although library targets can still be configured for scraping.
### How should we test and review this PR?
I have updated the `docscrape` tests to reflect this new policy, as well as the Unstable Options page in the Cargo book.
r? `@weihanglo`
let doc_html = p.read_file("target/doc/foo/fn.foo.html");
233
240
assert!(doc_html.contains("Examples found in repository"));
234
-
assert!(doc_html.contains("More examples"));
235
241
}
236
242
237
243
#[cargo_test(nightly, reason = "rustdoc scrape examples flags are unstable")]
@@ -342,21 +348,17 @@ fn no_fail_bad_lib() {
342
348
"\
343
349
[CHECKING] foo v0.0.1 ([CWD])
344
350
[SCRAPING] foo v0.0.1 ([CWD])
345
-
warning: failed to scan lib in package `foo` for example code usage
346
-
Try running with `--verbose` to see the error message.
347
-
If an example or library should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` or `[lib]` definition in Cargo.toml
348
-
warning: `foo` (lib) generated 1 warning
349
351
warning: failed to check lib in package `foo` as a prerequisite for scraping examples from: example \"ex\", example \"ex2\"
350
352
Try running with `--verbose` to see the error message.
351
-
If an example or library should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` or `[lib]` definition in Cargo.toml
353
+
If an example should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` definition in Cargo.toml
352
354
warning: `foo` (lib) generated 1 warning
353
355
warning: failed to scan example \"ex\" in package `foo` for example code usage
354
356
Try running with `--verbose` to see the error message.
355
-
If an example or library should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` or `[lib]` definition in Cargo.toml
357
+
If an example should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` definition in Cargo.toml
warning: failed to scan example \"ex2\" in package `foo` for example code usage
358
360
Try running with `--verbose` to see the error message.
359
-
If an example or library should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` or `[lib]` definition in Cargo.toml
361
+
If an example should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` definition in Cargo.toml
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
@@ -389,7 +391,7 @@ fn no_fail_bad_example() {
389
391
[SCRAPING] foo v0.0.1 ([CWD])
390
392
warning: failed to scan example \"ex1\" in package `foo` for example code usage
391
393
Try running with `--verbose` to see the error message.
392
-
If an example or library should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` or `[lib]` definition in Cargo.toml
394
+
If an example should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` definition in Cargo.toml
0 commit comments