Skip to content

Commit

Permalink
Support renaming re-exports, glob re-exports, and type aliases used a…
Browse files Browse the repository at this point in the history
…s renames. (#34)

* Implement `pub use` and glob re-exports.

* Reasonably handle import paths with cycles rather than crashing.

* Handle `pub type` uses equivalent to `pub use` as mere re-exports.

* Switch tests to nightly since that's where rustdoc v24 is.
  • Loading branch information
obi1kenobi committed Jan 27, 2023
1 parent 1ed7be7 commit d6246de
Show file tree
Hide file tree
Showing 50 changed files with 1,726 additions and 74 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
rust-tests:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: ["1.67"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -64,11 +67,15 @@ jobs:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: ${{ matrix.toolchain }}
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2

- name: Regenerate test data
run: ./scripts/regenerate_test_rustdocs.sh +${{ matrix.toolchain }}

- name: compile
run: cargo test --no-run

Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Generated by Cargo
# will have compiled files and executables
/target/
**/target/

# Local configuration for the project.
.cargo/

# These are backup files generated by rustfmt
**/*.rs.bk

# local-only data
localdata/

# lockfiles of test crates
test_crates/**/Cargo.lock
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ trustfall_core = "0.1.1"
rustdoc-types = "0.18.0"

[dev-dependencies]
anyhow = "1.0.58"
itertools = "0.10.5"
serde_json = "1.0.85"
serde = { version = "1.0.145", features = ["derive"] }
maplit = "1.0.2"
34 changes: 34 additions & 0 deletions scripts/regenerate_test_rustdocs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Fail on first error, on undefined variables, and on failures in pipelines.
set -euo pipefail

export CARGO_TARGET_DIR=/tmp/test_crates
RUSTDOC_OUTPUT_DIR="$CARGO_TARGET_DIR/doc"
TOPLEVEL="$(git rev-parse --show-toplevel)"
TARGET_DIR="$TOPLEVEL/localdata/test_data"

# Allow setting an explicit toolchain, like +nightly or +beta.
set +u
TOOLCHAIN="$1"
set -u
echo "Generating rustdoc with: $(cargo $TOOLCHAIN --version)"
RUSTDOC_CMD="cargo $TOOLCHAIN rustdoc"

# Run rustdoc on test_crates/*/
for crate_path in $(find "$TOPLEVEL/test_crates/" -maxdepth 1 -mindepth 1 -type d); do
# Removing path prefix, leaving only the directory name without forward slashes
crate=${crate_path#"$TOPLEVEL/test_crates/"}

if [[ -f "$TOPLEVEL/test_crates/$crate/Cargo.toml" ]]; then
echo "Generating: $crate"

pushd "$TOPLEVEL/test_crates/$crate"
RUSTC_BOOTSTRAP=1 $RUSTDOC_CMD -- -Zunstable-options --document-private-items --document-hidden-items --output-format=json
mkdir -p "$TARGET_DIR/$crate"
mv "$RUSTDOC_OUTPUT_DIR/$crate.json" "$TARGET_DIR/$crate/rustdoc.json"
popd
fi
done

unset CARGO_TARGET_DIR
Loading

0 comments on commit d6246de

Please sign in to comment.