Skip to content

Commit

Permalink
fix dependency workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
SpecificProtagonist committed Feb 15, 2025
1 parent 36515a4 commit 7c0d526
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 26 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ jobs:
# This does the following:
# - Replaces the docs icon with one that clearly denotes it's not the released package on crates.io
# - Adds a meta tag that forces Google not to index any page on the site.
# - compiles our rustdoc wrapper
- name: Pre-docs-build
run: |
sed -i.bak "s/icon.png/icon-docs-dev.png/" src/lib.rs
echo "<meta name=\"robots\" content=\"noindex\">" > header.html
cargo build --release --package rustdoc-wrapper
- name: Build docs
env:
Expand All @@ -76,7 +74,7 @@ jobs:
--exclude build-wasm-example \
--exclude build-templated-pages \
--exclude example-showcase \
--config "build.rustdoc = \"target/release/rustdoc-wrapper\""
--config "build.rustdoc = \"tools/rustdoc-wrapper/rustdoc.sh\""
# This adds the following:
# - A top level redirect to the bevy crate documentation
Expand Down
2 changes: 1 addition & 1 deletion tools/rustdoc-wrapper/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/target
target/
11 changes: 6 additions & 5 deletions tools/rustdoc-wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ which types are `Component`s, `Plugin`s etc. To do so, this
tool wraps rustdoc and modifies its output by adding relevant tags
to the top of a type's doc page.

On docs.rs and dev-docs.bevyengine.org the wrapper is invoked via
Note that the format of rustdoc's html output is (and always will be) unstable. These customizations may therefor break at time, at which point they should be enabled until fixed.

```bash
cargo doc --config "build.rustdoc = \"tools/rustdoc-wrapper/rustdoc.sh\""
On docs.rs and dev-docs.bevyengine.org the wrapper is invoked by passing the following flag:

```
--config "build.rustdoc = \"tools/rustdoc-wrapper/rustdoc.sh\""
```

If you want to build Bevy's documentation with these customizations
applied yourself and are not on Unix or want to run the wrapper in release mode,
first compile it:
applied yourself, first compile it:

```bash
cargo build --release --package rustdoc-wrapper
Expand Down
9 changes: 3 additions & 6 deletions tools/rustdoc-wrapper/rustdoc.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/bin/env sh

# Gets clobbered, so make a backup.
export SET_CARGO_MANIFEST_PATH="$CARGO_MANIFEST_PATH"
export SET_CARGO_MANIFEST_DIR="$CARGO_MANIFEST_DIR"
# Use a different target directory because the workspace-level one will be locked.
cargo build --release --target-dir tools/rustdoc-wrapper/target
# Pass on all arguments to our rustdoc wrapper.
# Use a different target directory because the workspace-level one
# will be locked.
cargo run --package rustdoc-wrapper --target-dir tools/rustdoc-wrapper/target --color always -- "$@"
tools/rustdoc-wrapper/target/release/rustdoc-wrapper "$@"
12 changes: 1 addition & 11 deletions tools/rustdoc-wrapper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,7 @@ use walkdir::WalkDir;

fn main() {
// Generate HTML as normal
let mut rustdoc = Command::new("rustdoc");
if let Ok(manifest_path) = std::env::var("SET_CARGO_MANIFEST_PATH") {
// Restore clobbered env var if invoked through `cargo run`.
// This is required by our derive macros.
rustdoc.env("CARGO_MANIFEST_PATH", manifest_path);
rustdoc.env(
"CARGO_MANIFEST_DIR",
std::env::var("SET_CARGO_MANIFEST_DIR").unwrap(),
);
}
assert!(rustdoc
assert!(Command::new("rustdoc")
.args(std::env::args().skip(1))
.status()
.unwrap()
Expand Down

0 comments on commit 7c0d526

Please sign in to comment.