Merge rust-bitcoin/rust-bitcoin#2830: Fix Rustdocs warnings in `just check-api`

a09c3c5225 Check API: remove false positives on rustdoc (Jose Storopoli)

Pull request description:

  Fixes the rustdocs build warnings.
  This PR is composed by two commits:

  - Updates `contrib/check-for-api-changes.sh` to ignore
    `rustdoc::broken_intra_doc_links` due to the features being turned on and off
    (see rationale below); and
  - Adds a `just doc` quick check that will check for all missing rustdoc broken links
    to counterbalance the allow flag above.

  As jyap808 has pointed out in #2800,
  we might not have a simple fix for these rustdoc build warnings inside the `just check-api`.
  This can be mitigated by adding a simple allow flag to `RUSTDOCFLAGS` in `contrib/check-for-api-changes.sh`.

  > Took a quick look at this. Not sure if there's anything obvious to fix.
  >
  > A few warnings mentioning [`ordered::ArbitraryOrd`] which is only enabled when the "--features ordered" flag is used. No warning when the flag is enabled. Generated docs look OK.
  >
  > jyap808 in #2800

  Closes #2800.

  I don't know if this is the intended solution, or if we want to add more CI checks for the docs.
  Note that these docs checks are already covered in `rust-bitcoin/rust-bitcoin-maintainer-tools`: 3494ceec52/ci/run_task.sh (L275-L278)

  Any feedback will be appreciated.

ACKs for top commit:
  apoelstra:
    ACK a09c3c5225
  tcharding:
    ACK a09c3c5225

Tree-SHA512: d8a4a14a220d907a072fb283075c168e8264d01e73bf6b600f9c562337836ff6ea47cd0ab326bebd997522d5fdf32ae5a9b82c6951741595ec41c13ad49bc2ce
This commit is contained in:
Andrew Poelstra 2024-06-07 16:24:45 +00:00
commit f260b097f4
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 20 additions and 9 deletions

View File

@ -10,7 +10,8 @@ REPO_DIR=$(git rev-parse --show-toplevel)
API_DIR="$REPO_DIR/api"
NIGHTLY=$(cat nightly-version)
CARGO="cargo +$NIGHTLY public-api --simplified"
# Our docs have broken intra doc links if all features are not enabled.
RUSTDOCFLAGS="-A rustdoc::broken_intra_doc_links"
# `sort -n -u` doesn't work for some reason.
SORT="sort --numeric-sort"
@ -33,13 +34,23 @@ main() {
check_for_changes
}
# Run cargo with all features enabled.
run_cargo_all_features() {
cargo +"$NIGHTLY" public-api --simplified --all-features
}
# Run cargo when --all-features is not used.
run_cargo() {
RUSTDOCFLAGS="$RUSTDOCFLAGS" cargo +"$NIGHTLY" public-api --simplified "$@"
}
generate_api_files_bitcoin() {
local crate="bitcoin"
pushd "$REPO_DIR/$crate" > /dev/null
$CARGO | $SORT | uniq > "$API_DIR/$crate/default-features.txt"
$CARGO --no-default-features | $SORT | uniq > "$API_DIR/$crate/no-features.txt"
$CARGO --all-features | $SORT | uniq > "$API_DIR/$crate/all-features.txt"
run_cargo | $SORT | uniq > "$API_DIR/$crate/default-features.txt"
run_cargo --no-default-features | $SORT | uniq > "$API_DIR/$crate/no-features.txt"
run_cargo_all_features | $SORT | uniq > "$API_DIR/$crate/all-features.txt"
popd > /dev/null
}
@ -48,8 +59,8 @@ generate_api_files_base58() {
local crate="base58"
pushd "$REPO_DIR/$crate" > /dev/null
$CARGO | $SORT | uniq > "$API_DIR/$crate/default-features.txt"
$CARGO --no-default-features | $SORT | uniq > "$API_DIR/$crate/no-features.txt"
run_cargo | $SORT | uniq > "$API_DIR/$crate/default-features.txt"
run_cargo --no-default-features | $SORT | uniq > "$API_DIR/$crate/no-features.txt"
popd > /dev/null
}
@ -65,9 +76,9 @@ generate_api_files() {
local crate=$1
pushd "$REPO_DIR/$crate" > /dev/null
$CARGO --no-default-features | $SORT | uniq > "$API_DIR/$crate/no-features.txt"
$CARGO --no-default-features --features=alloc | $SORT | uniq > "$API_DIR/$crate/alloc-only.txt"
$CARGO --all-features | $SORT | uniq > "$API_DIR/$crate/all-features.txt"
run_cargo --no-default-features | $SORT | uniq > "$API_DIR/$crate/no-features.txt"
run_cargo --no-default-features --features=alloc | $SORT | uniq > "$API_DIR/$crate/alloc-only.txt"
run_cargo_all_features | $SORT | uniq > "$API_DIR/$crate/all-features.txt"
popd > /dev/null
}