-
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
Allow using reverse-dependencies for -Zrustdoc-scrape-examples
, not just examples
#10041
Comments
Yeah this is definitely a good idea to have. I think the key question is imagining the Cargo workflow. First thought is something like
So we'd need a new command specifically for generating the |
@willcrichton hmm, is there a reason this would be a separate command for each crate? I was imagining that you could use |
Oh |
Oh hmm - I do see it running |
I think it can use basically the same approach, have cargo run rustdoc in reverse order on all the dependencies (and pass |
I think you're running into #10035 because
Wait when you say "dependencies" are you talking about reverse-dependencies or actual dependencies? Like if we're documenting A where A depends on B and C depends on A (and both B and C are in different workspaces). Is your goal that examples of B in A show up in the documentation for B, or that examples of A in C show up in the documentation for A? |
If I read your example right, it's |
Ok that makes sense. Then the issue is specifying which reverse-dependencies to pull in, assuming you don't want all of them. Maybe a Cargo.toml configuration like this? [package]
scrape-examples-from = ["crate_a", "crate_b", "etc"] |
Oh uhh I was actually expecting cargo would pull in all of them 😅 my worry is that if we make it opt-in then people won't actually configure it; a lot of the benefit comes from it working 'automagically' with only a single opt-in from the end user. |
The current implementation of scrape-examples now allows for scraping reverse-dependencies in your current workspace, so this can be closed. (@weihanglo) |
Problem
Many repositories don't have examples written, or the examples are not very long and don't show what the call looks like in context.
Proposed Solution
However, almost any library will have people actually using it. What cargo could do is instead of running rustdoc like this:
Scrape the examples from the other crates in the workspace as well:
This can be extended to all the dependencies in the whole tree if desired. This does have the drawback that it will take about twice as long to run rustdoc, but since it's opt-in I think the tradeoff is worth it.
Notes
Here's a proof of concept which runs those commands by hand on
cargo-deadlinks
:The text was updated successfully, but these errors were encountered: