docs/ironcalc.dev/build-docs.sh
Rama main · réplica de lectura del repositorio original.
#!/bin/bash
#
# Builds the static site deployed at https://ironcalc.dev into docs/ironcalc.dev/dist:
#
# dist/index.html landing page for developing / scripting IronCalc
# dist/rust/ rust API docs (cargo doc) for the ironcalc and ironcalc_base crates
# dist/python/ python bindings docs (sphinx)
# dist/wasm/ wasm bindings docs (TODO)
# dist/nodejs/ nodejs bindings docs (TODO)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
DIST_DIR="$SCRIPT_DIR/dist"
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
# Landing page
cp "$SCRIPT_DIR/index.html" "$DIST_DIR/index.html"
cp "$SCRIPT_DIR/styles.css" "$DIST_DIR/styles.css"
cp "$SCRIPT_DIR/fonts.css" "$DIST_DIR/fonts.css"
cp -r "$SCRIPT_DIR/fonts" "$DIST_DIR/fonts"
cp -r "$SCRIPT_DIR/images" "$DIST_DIR/images"
cp "$ROOT_DIR/assets/favicon.ico" "$DIST_DIR/images/favicon.ico"
cp "$ROOT_DIR/assets/favicon-16x16.png" "$DIST_DIR/images/favicon-16x16.png"
cp "$ROOT_DIR/assets/favicon-32x32.png" "$DIST_DIR/images/favicon-32x32.png"
cp "$ROOT_DIR/assets/apple-touch-icon.png" "$DIST_DIR/images/apple-touch-icon.png"
cp "$ROOT_DIR/assets/icon/ironcalc_icon.svg" "$DIST_DIR/images/icon.svg"
cp "$ROOT_DIR/assets/logo/svg/orange+black.svg" "$DIST_DIR/images/logo.svg"
# Rust documentation (https://ironcalc.dev/rust)
echo "Building rust docs..."
# remove docs of stale crates from previous builds
rm -rf "$ROOT_DIR/target/doc"
(cd "$ROOT_DIR" && cargo doc --no-deps --lib -p ironcalc -p ironcalc_base)
cp -r "$ROOT_DIR/target/doc" "$DIST_DIR/rust"
# cargo doc does not generate a top level index.html, redirect to the main crate
cat > "$DIST_DIR/rust/index.html" <<EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="refresh" content="0; url=ironcalc/index.html" />
<title>IronCalc rust documentation</title>
</head>
<body>
<a href="ironcalc/index.html">Redirecting to the ironcalc crate documentation...</a>
</body>
</html>
EOF
# Python bindings documentation (https://ironcalc.dev/python)
echo "Building python docs..."
cd "$ROOT_DIR/bindings/python"
if [ ! -d venv ]; then
python3 -m venv venv
fi
source venv/bin/activate
pip install --quiet patchelf maturin sphinx furo
maturin develop
cp "$ROOT_DIR/assets/logo/svg/orange+black.svg" docs/_static/logo-light.svg
cp "$ROOT_DIR/assets/logo/svg/orange+white.svg" docs/_static/logo-dark.svg
rm -rf html
sphinx-build -M html docs html
deactivate
cp -r "$ROOT_DIR/bindings/python/html/html" "$DIST_DIR/python"
# Wasm bindings documentation (https://ironcalc.dev/wasm)
echo "Building wasm docs..."
cd "$ROOT_DIR/bindings/wasm"
pnpm install --frozen-lockfile --silent
# pkg/wasm.d.ts is generated by wasm-pack and not committed
if [ ! -f pkg/wasm.d.ts ]; then
make
fi
pnpm exec typedoc --out "$DIST_DIR/wasm"
# Nodejs bindings documentation (https://ironcalc.dev/nodejs)
echo "Building nodejs docs..."
cd "$ROOT_DIR/bindings/nodejs"
pnpm install --frozen-lockfile --silent
pnpm exec typedoc --out "$DIST_DIR/nodejs"
echo "Site generated in $DIST_DIR"
echo "Preview it with: python3 -m http.server --directory $DIST_DIR"