Skip to content

Commit

Permalink
Generate docs for the oak_abi crate
Browse files Browse the repository at this point in the history
Updates `check_docs` and `build_gh_pages` scripts to also check and generate docs
for `oak_abi`, now that it is a separate crate.
  • Loading branch information
rbehjati committed May 28, 2020
1 parent 0b133c0 commit a22d3d7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
37 changes: 25 additions & 12 deletions scripts/build_gh_pages
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readonly SCRIPTS_DIR="$(dirname "$0")"
# shellcheck source=scripts/common
source "$SCRIPTS_DIR/common"

readonly TARGET_DIR="${1:-}"
readonly TARGET_DIR="$(cd "${1:-}" && pwd)"

if [[ -z "${TARGET_DIR}" ]]; then
echo 'target dir not specified'
Expand All @@ -29,25 +29,38 @@ if [[ -n "$(ls "${TARGET_DIR}"/*)" ]]; then
exit 1
fi

# Generate docs directly in the target dir.
cargo doc --no-deps --target-dir="${TARGET_DIR}"
readonly CURRENT_DIR="$(pwd)"

# Remove non-doc artifacts from the target dir.
rm --recursive --force "${TARGET_DIR}/debug"
paths=("." "oak_abi" "oak_utils")
names=("oak" "oak_abi" "oak_utils")
titles=("SDK" "ABI" "Utils")

# Remove non-deterministic files.
rm "${TARGET_DIR}/.rustc_info.json"
for i in {0..2}; do
cd ${CURRENT_DIR}
target=""${TARGET_DIR}"/${names[$i]}"
mkdir -p target
cd ${paths[$i]}

# The docs generated from the Cargo workspace do not include a workspace-level index, so we generate
# one here and redirect to the Oak SDK documentation.
cat <<-END > "${TARGET_DIR}/index.html"
# Generate docs directly in the target dir.
cargo doc --no-deps --target-dir="${target}"

# Remove non-doc artifacts from the target dir.
rm --recursive --force "${target}/debug"

# Remove non-deterministic files.
rm "${target}/.rustc_info.json"

# The docs generated from the Cargo workspace do not include a workspace-level index, so we generate
# one here and redirect to the Oak SDK documentation.
cat <<-END > "${target}/index.html"
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Refresh" content="0; url=./doc/oak/index.html" />
<meta http-equiv="Refresh" content="0; url=./doc/${names[$i]}/index.html" />
</head>
<body>
<p><a href="./doc/oak/index.html">Oak SDK main page</a></p>
<p><a href="./doc/${names[$i]}/index.html">Oak ${titles[$i]} main page</a></p>
</body>
</html>
END
done
28 changes: 17 additions & 11 deletions scripts/check_docs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ source "$SCRIPTS_DIR/common"
# false positive warning removed (https://github.com/rust-lang/rust/pull/70789)
export RUSTDOCFLAGS="-A unused_braces"

DOCS_OUT="$(cargo doc --document-private-items --no-deps 2>&1)"
paths=("." "oak_abi" "../oak_utils")

# `cargo doc` produces warnings for incorrect paths. These warnings cannot be promoted to errors, so we use grep to detect them.
if grep --ignore-case --quiet --regexp='^warning' <<< "$DOCS_OUT"; then
echo "Warnings found when generating the docs."
exit 1
fi
for i in "${paths[@]}"
do
cd $i
DOCS_OUT="$(cargo doc --document-private-items --no-deps 2>&1)"

# Check for any deadlinks in the generated docs.
if ! cargo deadlinks --dir target/doc; then
echo "Found deadlinks in the generated docs."
exit 1
fi
# `cargo doc` produces warnings for incorrect paths. These warnings cannot be promoted to errors, so we use grep to detect them.
if grep --ignore-case --quiet --regexp='^warning' <<< "$DOCS_OUT"; then
echo "Warnings found when generating the docs."
exit 1
fi

# Check for any deadlinks in the generated docs.
if ! cargo deadlinks --dir target/doc; then
echo "Found deadlinks in the generated docs."
exit 1
fi
done

0 comments on commit a22d3d7

Please sign in to comment.