-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Scrape code examples from examples/ directory for Rustdoc #9525
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest LGTM but this should have a reviewer from t-cargo.
☔ The latest upstream changes (presumably #9730) made this pull request unmergeable. Please resolve the merge conflicts. |
c937e21
to
bd3372a
Compare
☔ The latest upstream changes (presumably #9943) made this pull request unmergeable. Please resolve the merge conflicts. |
…ame metadata hash
Ok everything looks green and we've got good sign-off so I'm gonna r+, thanks @willcrichton for being patient with this! |
Oh actually I recall that I wanted to test this out before merging. I'm testing this out on the wasmtime repository but currently what I get is:
I think that's coming from the Cargo integration here? This project is also slightly wonky where the crate that I'm interested in is |
* Docscrape unit not having dev-dependencies included * Sources for reverse-dependencies generated to the wrong directory * Incorrect features being selected for Docscrape units * Panics from Docscrape-dependent packages not being available
Good call @alexcrichton!! I fixed no fewer than 5 different bugs when testing on the wasmtime repo, including an upstream fix to rustc at rust-lang/rust#90349. See my latest commit for what changed + a summary of changes. This extension now works correctly on the wasmtime repo, e.g. |
Nice! Could you add some tests to Cargo for the bugs you found here as well? I think it's fine to add one "interesting" test instead of lots of little tests as well if you'd prefer. Also wow this is really nice. The generated docs I think look really good and having everything automatically slurped up is very appealing. FWIW I ran The only other issue I noticed was that there was a precipitious "cliff" in the execution of I think we can probably do better here in the long run because crates like |
root units. Only attach Docscrape unit dependencies to workspace Doc units. Add test for scraping examples with complex reverse dependencies.
Ok I added a test. Also re: your concerns, I changed it so:
|
I think that's pretty reasonable, yeah, a workspace sounds like a good unit for "scrape examples for all crates within here". It looks like there's some more failing tests though? |
Ah missed those, just some changed stderr output. Fixed the issue and we should be good now! |
@bors: r+ 👍 |
📌 Commit 33718c7 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 3 commits in 6c1bc24b8b49d4bc965f67d7037906dc199c72b7..94ca096afbf25f670e76e07dca754fcfe27134be 2021-10-24 17:51:41 +0000 to 2021-10-29 14:45:06 +0000 - Chore: prefer `HashMap::from` rather than collecting `Vec` of tuples (rust-lang/cargo#10018) - Change --scrape-examples flag to -Z rustdoc-scrape-examples (rust-lang/cargo#10017) - Scrape code examples from examples/ directory for Rustdoc (rust-lang/cargo#9525)
Change rustdoc-scrape-examples to be a target-level configuration This PR addresses issues raised in #9525. Specifically: 1. It enables examples to be scraped from `#[test]` functions, by passing additional flags to Rustdoc to ensure that these functions aren't ignored by rustc. 2. It moves the `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: ```toml [lib] doc-scrape-examples = false [[test]] name = "my_test" doc-scrape-examples = true ```
Change rustdoc-scrape-examples to be a target-level configuration This PR addresses issues raised in #9525. Specifically: 1. It enables examples to be scraped from `#[test]` functions, by passing additional flags to Rustdoc to ensure that these functions aren't ignored by rustc. 2. It moves the `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: ```toml [lib] doc-scrape-examples = false [[test]] name = "my_test" doc-scrape-examples = true ```
Change rustdoc-scrape-examples to be a target-level configuration This PR addresses issues raised in #9525. Specifically: 1. It enables examples to be scraped from `#[test]` functions, by passing additional flags to Rustdoc to ensure that these functions aren't ignored by rustc. 2. It moves the `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: ```toml [lib] doc-scrape-examples = false [[test]] name = "my_test" doc-scrape-examples = true ```
Adds support for the functionality described in rust-lang/rfcs#3123
Matching changes to rustdoc are here: rust-lang/rust#85833