From e0b75768e4940a66f3a6ba94cec4d4d1369807b0 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Fri, 19 Aug 2022 14:30:54 +0100 Subject: [PATCH] netlify: add banner back to internal docs --- .github/workflows/gh-pages.yml | 4 ++++ .netlify/build.sh | 37 ++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 481a74f5..423c395f 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -39,6 +39,10 @@ jobs: TAG_NAME="${GITHUB_REF##*/}" echo "::set-output name=tag_name::${TAG_NAME}" + # Build some internal docs and inject a banner on top of it. + - name: Build the internal docs + run: cargo xtask doc --internal + - name: Clear the extra artefacts created earlier run: rm -rf target diff --git a/.netlify/build.sh b/.netlify/build.sh index b60a1fa3..524e4452 100755 --- a/.netlify/build.sh +++ b/.netlify/build.sh @@ -4,6 +4,24 @@ set -uex rustup default nightly +PYO3_VERSION=$(cargo search pyo3 --limit 1 | head -1 | tr -s ' ' | cut -d ' ' -f 3 | tr -d '"') +mkdir netlify_build + +## Configure netlify _redirects file + +# TODO: have some better system to automatically generate this on build rather +# than check this in to the repo +cp .netlify/_redirects netlify_build/ + +# Add latest redirect (proxy) +echo "/latest/* https://pyo3.rs/v${PYO3_VERSION}/:splat 200" >> netlify_build/_redirects + +## Add landing page redirect +echo "" > netlify_build/index.html + + +## Build guide + # Install latest mdbook. Netlify will cache the cargo bin dir, so this will # only build mdbook if needed. MDBOOK_VERSION=$(cargo search mdbook --limit 1 | head -1 | tr -s ' ' | cut -d ' ' -f 3 | tr -d '"') @@ -14,24 +32,21 @@ fi pip install nox nox -s build-guide -cargo xtask doc --internal - -mkdir -p netlify_build/internal -mv target/doc netlify_build/internal/ mv target/guide netlify_build/main/ +## Build public docs + cargo xtask doc mv target/doc netlify_build/main/doc/ -PYO3_VERSION=$(cargo search pyo3 --limit 1 | head -1 | tr -s ' ' | cut -d ' ' -f 3 | tr -d '"') -echo "" > netlify_build/index.html +## Build internal docs -# TODO: have some better system to automatically generate this on build rather -# than check this in to the repo -cp .netlify/_redirects netlify_build/ +echo "
⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here
" > netlify_build/banner.html +RUSTDOCFLAGS="--html-before-content netlify_build/banner.html" cargo xtask doc --internal +rm netlify_build/banner.html -# Add latest redirect -echo "/latest/* https://pyo3.rs/${PYO3_VERSION}/:splat 200" >> netlify_build/_redirects +mkdir -p netlify_build/internal +mv target/doc netlify_build/internal/ ls -l netlify_build/