-
Notifications
You must be signed in to change notification settings - Fork 0
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
Scraping examples: works locally but not on docs.rs #1
Comments
Bevy's crate is part of a workspace, where the main crate contains all the examples but is just a facade reexporting a bunch of So in this repo, the layout is
|
Experiment one: Prove that there are no scraped examples by default. This is version Result: No examples scraped. Locally: Examples scraped! |
Experiment two: Add config described in rustdoc docs to top level crate. This is version Result: No examples scraped. Locally: Examples scraped! |
Experiment three: Add config described in rustdoc docs also to the two sub-crates. This is version Result: No examples scraped. Locally: Examples scraped! |
Experiment four: Add explicit config for examples [[example]]
name = "status"
doc-scrape-examples = true This is version Result: No examples scraped. Locally: Examples scraped! Bonus: The build log says [INFO] [stderr] Scraping test_61a7cd7f28e0 v0.1.2-withdocsrssettings (/opt/rustwide/workdir)
[INFO] [stderr] Documenting test_61a7cd7f28e0 v0.1.2-withdocsrssettings (/opt/rustwide/workdir)
[INFO] [stderr] Finished dev [unoptimized + debuginfo] target(s) in 0.45s |
To check that it doesn't work locally for sure, I ran this
which is the sanitized build command from https://docs.rs/crate/test_61a7cd7f28e0/0.1.2-withdocsrssettings/builds/938672 |
The main difference I can think of between docs.rs and local is that docs.rs get |
Two more tests:
|
Experiment five, after talking to @rust-lang/docs-rs team: Use crates.io deps only This is version Result: [No examples scraped.](https://docs.rs/test_61a7cd7f28e0/0.1.2-withdocsrssettings/test_61a7cd7f28e0/struct.Foo.html Locally: No examples scraped! Finally. |
Do you have the final working index d192fd6..22706ba 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,8 +7,8 @@ description = "testing scraping examples"
license = "MIT"
[dependencies]
-test_40a48f47864a = { version = "0.1.1-withdocsrssettings" }
-test_7018a98a70c0 = { version = "0.1.1-withdocsrssettings" }
+test_40a48f47864a = { path = "crates/test_40a48f47864a", version = "0.1.1-withdocsrssettings" }
+test_7018a98a70c0 = { path = "crates/test_7018a98a70c0", version = "0.1.1-withdocsrssettings" } |
Anything up to and including this commit worked for me locally: dfb942c Let me try again with a newer nightly… Yup, still true with |
I have the following [package]
name = "test_61a7cd7f28e0"
version = "0.1.3-withoutpathdeps"
edition = "2021"
authors = ["Pascal Hertleif"]
description = "testing scraping examples"
license = "MIT"
[dependencies]
test_40a48f47864a = { path = "crates/test_40a48f47864a", version = "0.1.1-withdocsrssettings" }
test_7018a98a70c0 = { path = "crates/test_7018a98a70c0", version = "0.1.1-withdocsrssettings" }
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
[[example]]
name = "one"
doc-scrape-examples = true
[[example]]
name = "two"
doc-scrape-examples = true I have this version: $ cargo --version
cargo 1.75.0-nightly (8eb8acbb1 2023-10-17) But when generating docs with What am I missing? ^^' |
Aha, I see now: You're missing the workspace definition! [workspace]
members = ["crates/*"] Another interesting discovery :D |
Bingo! That's a lot of requirements. ^^' |
Noting for myself: I came back to this: with the |
I did some debugging on this. Mind creating an issue against cargo? When scraping examples from a package, cargo only asks for examples that use APIs from specific crates, presumably for performance reasons // Only scrape example for items from crates in the workspace, to reduce generated file size
for pkg in cx.bcx.ws.members() {
let names = pkg
.targets()
.iter()
.map(|target| target.crate_name())
.collect::<HashSet<_>>();
for name in names {
rustdoc.arg("--scrape-examples-target-crate").arg(name);
}
} This is filtered to workspace members. Really what is needed is filtering for public dependencies which has recently been revived (rust-lang/rfcs#3516). Path forward
|
Doing it with the extra information you provided. |
I tried to add scraped examples to bevy's API docs in bevyengine/bevy#9154 but it did not work on docs.rs.
If you run
cargo +nightly doc -Zunstable-options -Zrustdoc-scrape-examples --open
locally and search forjust_pressed
, you'll see scraped examples.This repo is about finding out what's happening.
The text was updated successfully, but these errors were encountered: