2016-10-03 00:29:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
#
|
|
|
|
# Builds the rustdocs for all of the libraries.
|
|
|
|
#
|
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
# Brings in: PROJECT_ROOT, EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, CONTRIB_DIR, DOC_DIR
|
2016-10-03 00:29:59 +00:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2017-07-29 04:34:59 +00:00
|
|
|
source "${SCRIPT_DIR}/config.sh"
|
2016-10-03 00:29:59 +00:00
|
|
|
|
2018-10-10 11:20:50 +00:00
|
|
|
if [ "${1}" != "-d" ]; then
|
|
|
|
# We need to clean-up beforehand so we don't get all of the dependencies.
|
|
|
|
echo ":::: Cleaning up before documenting..."
|
|
|
|
cargo clean
|
|
|
|
cargo update
|
|
|
|
fi
|
2016-10-03 00:51:35 +00:00
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
# Generate the rustdocs for all of the crates.
|
2024-02-21 04:45:46 +00:00
|
|
|
echo ":::: Generating docs (${DOC_VERSION})..."
|
2018-10-07 04:16:02 +00:00
|
|
|
pushd "${PROJECT_ROOT}" > /dev/null 2>&1
|
2021-05-25 01:58:05 +00:00
|
|
|
# Set the crate version and fill in missing doc URLs with docs.rs links.
|
2023-09-21 00:17:22 +00:00
|
|
|
RUSTDOCFLAGS="-Zunstable-options --crate-version ${DOC_VERSION} --extern-html-root-url rocket=https://api.rocket.rs/rocket/" \
|
|
|
|
cargo doc -Zrustdoc-map --no-deps --all-features \
|
|
|
|
-p rocket \
|
|
|
|
-p rocket_db_pools \
|
|
|
|
-p rocket_sync_db_pools \
|
|
|
|
-p rocket_dyn_templates \
|
|
|
|
-p rocket_ws
|
2018-10-07 04:16:02 +00:00
|
|
|
popd > /dev/null 2>&1
|
2016-12-22 06:56:58 +00:00
|
|
|
|
2024-02-21 04:45:46 +00:00
|
|
|
# Generating redirection list: from to.
|
|
|
|
echo ":::: Generating redirects..."
|
|
|
|
REDIRECTS="
|
|
|
|
/ /v0.5/rocket/ 302!
|
|
|
|
/v0.4 https://docs.rs/rocket/0.4/rocket/
|
|
|
|
/v0.4/:crate/* https://docs.rs/:crate/0.4/:crate/:splat
|
|
|
|
/:v /:v/rocket/
|
|
|
|
/v0.5/* https://v0-5--rocket-docs.netlify.app/:splat 200
|
|
|
|
/:v/* https://:v--rocket-docs.netlify.app/:splat 200
|
|
|
|
"
|
|
|
|
|
|
|
|
if [ "${GIT_BRANCH}" = "master" ]; then
|
|
|
|
echo "${REDIRECTS}" | tee "${DOC_DIR}/_redirects"
|
|
|
|
else
|
|
|
|
echo "-> '${GIT_BRANCH}' branch does not require redirects"
|
|
|
|
fi
|