Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965)

# Objective

- Fix issue #2611

## Solution

- Add `--generate-link-to-definition` to all the `rustdoc-args` arrays
in the `Cargo.toml`s (for docs.rs)
- Add `--generate-link-to-definition` to the `RUSTDOCFLAGS` environment
variable in the docs workflow (for dev-docs.bevyengine.org)
- Document all the workspace crates in the docs workflow (needed because
otherwise only the source code of the `bevy` package will be included,
making the argument useless)
- I think this also fixes #3662, since it fixes the bug on
dev-docs.bevyengine.org, while on docs.rs it has been fixed for a while
on their side.

---

## Changelog

- The source code viewer on docs.rs now includes links to the
definitions.
This commit is contained in:
Giacomo Stevanato 2024-07-30 01:10:16 +02:00 committed by GitHub
parent 29e9f0a7f9
commit 71c5f1e3e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 59 additions and 72 deletions

View file

@ -58,8 +58,19 @@ jobs:
- name: Build docs - name: Build docs
env: env:
# needs to be in sync with [package.metadata.docs.rs] # needs to be in sync with [package.metadata.docs.rs]
RUSTDOCFLAGS: -Zunstable-options --cfg=docsrs RUSTDOCFLAGS: -Zunstable-options --cfg=docsrs --generate-link-to-definition
run: cargo doc --all-features --no-deps -p bevy -Zunstable-options -Zrustdoc-scrape-examples run: cargo doc \
-Zunstable-options \
-Zrustdoc-scrape-examples \
--all-features \
--workspace \
--no-deps \
--exclude ci \
--exclude errors \
--exclude bevy_mobile_example \
--exclude build-wasm-example \
--exclude build-templated-pages \
--exclude example-showcase
# This adds the following: # This adds the following:
# - A top level redirect to the bevy crate documentation # - A top level redirect to the bevy crate documentation

View file

@ -3339,6 +3339,6 @@ lto = "fat"
panic = "abort" panic = "abort"
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -20,5 +20,5 @@ accesskit = "0.16"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -42,5 +42,5 @@ uuid = { version = "1.7", features = ["v4"] }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -38,5 +38,5 @@ console_error_panic_hook = "0.1.6"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -67,5 +67,5 @@ bevy_log = { path = "../bevy_log", version = "0.15.0-dev" }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -22,5 +22,5 @@ quote = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -52,5 +52,5 @@ android_shared_stdcxx = ["cpal/oboe-shared-stdcxx"]
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -28,5 +28,5 @@ serialize = ["serde"]
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -39,5 +39,5 @@ serde_test = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -45,5 +45,5 @@ thiserror = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -21,5 +21,5 @@ syn = { version = "2.0", features = ["full"] }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -46,5 +46,5 @@ ron = { version = "0.8.0", optional = true }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -39,5 +39,5 @@ sysinfo = { version = "0.30.0", optional = true, default-features = false }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -18,5 +18,5 @@ bevy_internal = { path = "../bevy_internal", version = "0.15.0-dev", default-fea
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -20,5 +20,5 @@ thiserror = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -53,5 +53,5 @@ path = "examples/change_detection.rs"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -19,5 +19,5 @@ proc-macro2 = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -19,5 +19,5 @@ encase_derive_impl = "0.8"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -24,5 +24,5 @@ thiserror = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -35,5 +35,5 @@ bytemuck = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -23,5 +23,5 @@ quote = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -67,5 +67,5 @@ bevy_log = { path = "../bevy_log", version = "0.15.0-dev" }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -31,5 +31,5 @@ smallvec = { version = "1.11", features = ["union", "const_generics"] }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -43,5 +43,5 @@ smol_str = "0.2"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -244,5 +244,5 @@ bevy_winit = { path = "../bevy_winit", optional = true, version = "0.15.0-dev" }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -40,5 +40,5 @@ tracing-wasm = "0.2.1"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -20,5 +20,5 @@ proc-macro2 = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -57,5 +57,5 @@ rand = ["dep:rand", "dep:rand_distr", "glam/rand"]
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -25,5 +25,5 @@ name = "generate"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -64,5 +64,5 @@ static_assertions = "1"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -14,5 +14,5 @@ keywords = ["bevy", "no_std"]
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -57,5 +57,5 @@ required-features = ["documentation"]
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -30,5 +30,5 @@ uuid = { version = "1.1", features = ["v4"] }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -130,5 +130,5 @@ send_wrapper = "0.6.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -22,5 +22,5 @@ quote = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -40,5 +40,5 @@ rmp-serde = "1.1"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -41,5 +41,5 @@ radsort = "0.1"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -30,5 +30,5 @@ web-time = { version = "1.1" }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -42,5 +42,5 @@ approx = "0.5.1"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -32,5 +32,5 @@ thiserror = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -52,5 +52,5 @@ serialize = ["dep:serde", "bevy_math/serialize"]
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -46,5 +46,5 @@ serialize = ["serde", "smallvec/serde"]
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -29,5 +29,5 @@ getrandom = { version = "0.2.0", features = ["js"] }
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -18,5 +18,5 @@ proc-macro2 = "1.0"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -32,5 +32,5 @@ smol_str = "0.2"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -56,5 +56,5 @@ crossbeam-channel = "0.5"
workspace = true workspace = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"] rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true all-features = true

View file

@ -10,7 +10,3 @@ bevy = { path = ".." }
[lints] [lints]
workspace = true workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"]
all-features = true

View file

@ -35,7 +35,3 @@ label = "Bevy Example"
[lints] [lints]
workspace = true workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"]
all-features = true

View file

@ -16,7 +16,3 @@ hashbrown = { version = "0.14", features = ["serde"] }
[lints] [lints]
workspace = true workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"]
all-features = true

View file

@ -12,7 +12,3 @@ clap = { version = "4.0", features = ["derive"] }
[lints] [lints]
workspace = true workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"]
all-features = true

View file

@ -12,7 +12,3 @@ bitflags = "2.3"
[lints] [lints]
workspace = true workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"]
all-features = true

View file

@ -17,7 +17,3 @@ regex = "1.10.5"
[lints] [lints]
workspace = true workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options"]
all-features = true