infra: cleanup docs build (#21134)

Refactors the docs build in order to:
- run the same `make build` command in both vercel and local build
- incrementally build artifacts in 2 distinct steps, instead of building
all docs in-place (in vercel) or in a _dist dir (locally)

Highlights:
- introduces `make build` in order to build the docs
- collects and generates all files for the build in
`docs/build/intermediate`
- renders those jupyter notebook + markdown files into
`docs/build/outputs`

And now the outputs to host are in `docs/build/outputs`, which will need
a vercel settings change.

Todo:
- [ ] figure out how to point the right directory (right now deleting
and moving docs dir in vercel_build.sh isn't great)
This commit is contained in:
Erick Friis
2024-05-01 17:34:05 -07:00
committed by GitHub
parent 6fa8626e2f
commit cd4c54282a
12 changed files with 141 additions and 185 deletions

View File

@@ -2,39 +2,9 @@
set -e
yum -y update
yum install gcc bzip2-devel libffi-devel zlib-devel wget tar gzip -y
make install-vercel-deps
# install quarto
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.3.450/quarto-1.3.450-linux-amd64.tar.gz
tar -xzf quarto-1.3.450-linux-amd64.tar.gz
export PATH=$PATH:$(pwd)/quarto-1.3.450/bin/
QUARTO_CMD="./quarto-1.3.450/bin/quarto" make build
# setup python env
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade uv
python3 -m uv pip install -r vercel_requirements.txt
python3 -m uv pip install -e $(ls ../libs/partners | grep -vE "airbyte|ibm|.md" | xargs -I {} echo "../libs/partners/{}")
# autogenerate integrations tables
python3 scripts/model_feat_table.py
# copy in external files
mkdir docs/templates
cp ../templates/docs/INDEX.md docs/templates/index.md
python3 scripts/copy_templates.py
cp ../cookbook/README.md src/pages/cookbook.mdx
wget -q https://raw.githubusercontent.com/langchain-ai/langserve/main/README.md -O docs/langserve.md
python3 scripts/resolve_local_links.py docs/langserve.md https://github.com/langchain-ai/langserve/tree/main/
wget -q https://raw.githubusercontent.com/langchain-ai/langgraph/main/README.md -O docs/langgraph.md
python3 scripts/resolve_local_links.py docs/langgraph.md https://github.com/langchain-ai/langgraph/tree/main/
# render
quarto render docs/
python3 scripts/generate_api_reference_links.py --docs_dir docs
rm -rf docs
mv build/output/docs ./