Skip to content

Commit 128e421

Browse files
Regenerate dynamic API docs on every build
OpenAPI spec, Python API reference, and C API reference are derived from code and regenerated by fern/generate_api_docs.py on every docs build. RST→MDX conversion is still gone; hand-edited MDX pages are not touched. - Restore fern/extract_python_api.py and fern/extract_c_api.py - Add fern/generate_api_docs.py (orchestrates the three dynamic outputs) - Restore fern/requirements-docs.txt (fastapi, pydantic, pyyaml) - build.sh docs: run generate_api_docs.py before fern check - CI: install Python deps, run generate_api_docs.py, then fern check - Re-add C++/Python source paths to CI triggers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5694197 commit 128e421

7 files changed

Lines changed: 1283 additions & 0 deletions

File tree

.github/workflows/fern-docs.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ on:
66
- main
77
paths:
88
- "fern/**"
9+
- "cpp/**/*.h"
10+
- "cpp/**/*.hpp"
11+
- "python/cuopt/cuopt/**"
12+
- "python/cuopt_server/**"
913
- ".github/workflows/fern-docs.yml"
1014
pull_request:
1115
paths:
1216
- "fern/**"
17+
- "cpp/**/*.h"
18+
- "cpp/**/*.hpp"
19+
- "python/cuopt/cuopt/**"
20+
- "python/cuopt_server/**"
1321
workflow_dispatch:
1422
# Stage 2: triggered after a PR build completes.
1523
# Runs in base-branch context so FERN_TOKEN secret is accessible.
@@ -24,6 +32,19 @@ jobs:
2432
steps:
2533
- uses: actions/checkout@v4
2634

35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: "3.11"
39+
40+
- name: Install Python dependencies
41+
run: |
42+
pip install -r fern/requirements-docs.txt
43+
pip install -e python/cuopt_server --no-deps
44+
45+
- name: Regenerate dynamic API docs
46+
run: python fern/generate_api_docs.py
47+
2748
- name: Install Fern CLI
2849
run: npm install -g fern-api@$(jq -r .version fern/fern.config.json)
2950

build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,21 @@ if hasArg docs; then
457457
npm install -g "fern-api@${FERN_VERSION}"
458458
fi
459459

460+
# Regenerate dynamic API reference pages (OpenAPI spec, Python API, C API)
461+
if command -v python3 &>/dev/null || command -v python &>/dev/null; then
462+
PY=${PYTHON:-python3}
463+
pip install --quiet -r "${REPODIR}/fern/requirements-docs.txt"
464+
if pip install --quiet -e "${REPODIR}/python/cuopt_server" --no-deps 2>/dev/null; then
465+
${PY} "${REPODIR}/fern/generate_api_docs.py"
466+
else
467+
echo " [WARN] cuopt_server not installable; skipping OpenAPI spec regeneration."
468+
echo " Python API and C API docs will still be regenerated."
469+
${PY} "${REPODIR}/fern/generate_api_docs.py"
470+
fi
471+
else
472+
echo " [WARN] Python not found; skipping API doc generation."
473+
fi
474+
460475
echo "Running fern check..."
461476
fern check
462477

dependencies.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,9 @@ dependencies:
788788
packages:
789789
- jq
790790
- nodejs # provides npm; used to install fern-api CLI
791+
- *pyyaml
792+
- fastapi
793+
- pydantic
791794

792795
notebooks:
793796
common:

0 commit comments

Comments
 (0)