-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change rustdoc-scrape-examples to be a target-level configuration #10343
Conversation
Somehow I feel like it'd be better to structure the configuration as something like:
rather than putting |
I think the issue with this is (a) it's not consistent with existing ways to configure targets, and (b) it doesn't allow target configuration at a higher granularity. For instance, the proposed method allows you to individually enable/disable specific examples and tests, while a list of target strings can't do so. |
This all looks pretty reasonable to me, but I'd like to confirm my understanding. The intention is that once stabilized this is enabled for all projects by default? So all projects with libraries and examples, when using If that's the case I think it might be good to flesh out the failing tests for now. I think there may need to be some trickery around not running doc-scrape with stable Rust as-is today since Cargo tests its CI with all three channels of Rust. Otherwise though that seems pretty reasonable to me and the PR otherwise looks pretty good.
Personally the choice made here I think is fine. This seems like something we can alter over time if necessary as well.
At least from Cargo's perspective this probably won't have much impact, but I don't have much of an opinion on this otherwise. As a random bikeshedding point seeing |
I thought this feature would be disabled by default? |
My understanding is that it would be disabled by default while unstable, and then enabled by default once stabilized. The vast majority of people will not use this feature if it is hidden behind a flag. |
Sorry, I definitely didn't understand it like this. In this case, we'll need to update the display quite a lot because it takes a lot of space by default. What about collapsing the section by default with a title like "see usage in examples" or something among the line? If you prefer we can discuss it on zulip. |
The discussion about scraping-by-default-or-not has been pulled onto Zulip: https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Enabling.20scrape.20examples.20by.20default |
78045d4
to
64ffa4f
Compare
☔ The latest upstream changes (presumably #9992) made this pull request unmergeable. Please resolve the merge conflicts. |
64ffa4f
to
d20ab08
Compare
e74509e
to
8ea5efa
Compare
@willcrichton The |
Ah thanks @lqd , got caught up in the rebase. I'll squash everything in a bit. |
☔ The latest upstream changes (presumably #10533) made this pull request unmergeable. Please resolve the merge conflicts. |
836e9f1
to
1daaf68
Compare
This PR is ready for review, although it needs a new Cargo reviewer since Alex has stepped back (is there a way to nominate a new reviewer?) As a reminder, this PR will enable the scrape examples feature by default, although only when run with a nightly rustc. Now that rust-lang/rust#93217 has landed, I think this feature is ready to be rolled out at least on docs.rs. Rustdoc maintainers, please let me know if you have any remaining concerns about this feature. cc @jsha @camelid @GuillaumeGomez @rustbot ready |
It seems like only @ehuss is on reviewer rotation for Cargo right now, so I will add him. Sorry for all the extra work Eric :( r? @ehuss |
@bors retry |
☀️ Test successful - checks-actions |
5 commits in ba607b23db8398723d659249d9abf5536bc322e5..e027c4b5d25af2119b1956fac42863b9b3242744 2022-11-22 20:52:39 +0000 to 2022-11-25 19:44:46 +0000 - fix: Move off atty to resolve soundness issue (rust-lang/cargo#11420) - add newline char to `cargo install .` error message for easier reading. (rust-lang/cargo#11401) - chore: Upgrade to env_logger (rust-lang/cargo#11417) - Change rustdoc-scrape-examples to be a target-level configuration (rust-lang/cargo#10343) - temporarily disable test `lto::test_profile` (rust-lang/cargo#11419)
Update cargo 5 commits in ba607b23db8398723d659249d9abf5536bc322e5..e027c4b5d25af2119b1956fac42863b9b3242744 2022-11-22 20:52:39 +0000 to 2022-11-25 19:44:46 +0000 - fix: Move off atty to resolve soundness issue (rust-lang/cargo#11420) - add newline char to `cargo install .` error message for easier reading. (rust-lang/cargo#11401) - chore: Upgrade to env_logger (rust-lang/cargo#11417) - Change rustdoc-scrape-examples to be a target-level configuration (rust-lang/cargo#10343) - temporarily disable test `lto::test_profile` (rust-lang/cargo#11419) r+ `@ghost`
5 commits in ba607b23db8398723d659249d9abf5536bc322e5..e027c4b5d25af2119b1956fac42863b9b3242744 2022-11-22 20:52:39 +0000 to 2022-11-25 19:44:46 +0000 - fix: Move off atty to resolve soundness issue (rust-lang/cargo#11420) - add newline char to `cargo install .` error message for easier reading. (rust-lang/cargo#11401) - chore: Upgrade to env_logger (rust-lang/cargo#11417) - Change rustdoc-scrape-examples to be a target-level configuration (rust-lang/cargo#10343) - temporarily disable test `lto::test_profile` (rust-lang/cargo#11419)
Update cargo 5 commits in ba607b23db8398723d659249d9abf5536bc322e5..e027c4b5d25af2119b1956fac42863b9b3242744 2022-11-22 20:52:39 +0000 to 2022-11-25 19:44:46 +0000 - fix: Move off atty to resolve soundness issue (rust-lang/cargo#11420) - add newline char to `cargo install .` error message for easier reading. (rust-lang/cargo#11401) - chore: Upgrade to env_logger (rust-lang/cargo#11417) - Change rustdoc-scrape-examples to be a target-level configuration (rust-lang/cargo#10343) - temporarily disable test `lto::test_profile` (rust-lang/cargo#11419) r+ `@ghost`
We were broken by rust-lang/cargo#10343. See rust-lang/cargo#11425 Fixes #4519
Improve strategy for selecting targets to be scraped for examples ### What does this PR try to resolve? After #10343, we have identified a clear set of conditions for whether a particular target should be considered by `-Zrustdoc-scrape-examples`. These conditions are described more clearly in #11425. However, after some testing with complex Cargo workspaces (e.g. [wasmtime](https://github.com/bytecodealliance/wasmtime/)), I realized that the current approach of modifying the `CompileFilter` did not correctly implement this new specification. For example, a target with `doc = false` should not be scraped by default since it is not a documented unit, but the current approach would potentially include such a target for scraping. This PR provides a new approach which I believe correctly implements the specification: 1. `generate_targets` is called with the same parameters except the `mode` which becomes `CompileMode::Docscrape` instead of `CompileMode::Doc`. `filter_default_targets` generates the same targets for `Docscrape` as for `Doc`. 2. Inside `generate_targets`, an initial set of `Proposal`s are created. This set of proposals is extended with further proposals based on targets identified as `doc-scrape-examples = true`, or Example targets where possible. This PR subsumes #11423, and also fixes #10571. ### How should we test and review this PR? I have added another test `docscrape::only_scrape_documented_targets` to verify that only documented or explicitly-enabled targets are included for scraping. r? `@weihanglo`
Update cargo 5 commits in ba607b23db8398723d659249d9abf5536bc322e5..e027c4b5d25af2119b1956fac42863b9b3242744 2022-11-22 20:52:39 +0000 to 2022-11-25 19:44:46 +0000 - fix: Move off atty to resolve soundness issue (rust-lang/cargo#11420) - add newline char to `cargo install .` error message for easier reading. (rust-lang/cargo#11401) - chore: Upgrade to env_logger (rust-lang/cargo#11417) - Change rustdoc-scrape-examples to be a target-level configuration (rust-lang/cargo#10343) - temporarily disable test `lto::test_profile` (rust-lang/cargo#11419) r+ `@ghost`
Enable triagebot's relabel functionality ### What does this PR try to resolve? This fixes the following failure that rustbot currently posts whenever someone tries to use "<b>`@</b><b>rustbot</b>` label" in this repository. > **Error**: The feature `relabel` is not enabled in this repository. > To enable it add its section in the `triagebot.toml` in the root of the repository. Unauthenticated relabel has been enabled in rust-lang/rust for nearly 4 years. People overwhelmingly use it in good faith. <br> ### How should we test and review this PR? Compare against https://github.com/rust-lang/rust/blob/1.66.0/triagebot.toml. Also skim through the 7 pages of labels on https://github.com/rust-lang/cargo/labels, whether it makes sense the ones I decided to allow arbitrary GitHub users to apply. <br> ### Additional information Attempted uses of "<b>`@</b><b>rustbot</b>` label", that failed, but this PR would allow: - #10343 (comment) - #10243 (comment) - #9982 (comment) - #9128 (comment) - #9067 (comment) - #8441 (comment) - #11432 (comment) - #8841 (comment) - #10820 (comment) - #10572 (comment) - #9114 (comment) - #8980 (comment) - #9064 (comment) - #8726 (comment) - #8089 (comment)
This PR addresses issues raised in #9525. Specifically:
#[test]
functions, by passing additional flags to Rustdoc to ensure that these functions aren't ignored by rustc.arg
from-Z rustdoc-scrape-examples={arg}
into a target-level configuration that can be added to Cargo.toml.The added test
scrape_examples_configure_target
shows a concrete example. In short, examples will be default scraped from Example and Lib targets. Then the user can enable or disable scraping like so: