Skip to content

Commit 877be7c

Browse files
authored
Merge pull request #139 from agentgateway/adb-api-docs
[docs] update ref docs workflow
2 parents 73d1d62 + 2f680fd commit 877be7c

3 files changed

Lines changed: 546 additions & 5 deletions

File tree

.github/workflows/reference-docs.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ jobs:
118118
--source-path="$PWD/../kgateway/api/v1alpha1/agentgateway/" \
119119
--renderer=markdown \
120120
--output-path ./ \
121+
--max-depth=100 \
121122
--config=scripts/crd-ref-docs-config.yaml
122123
123124
if [ ! -f "./out.md" ]; then
@@ -147,13 +148,31 @@ jobs:
147148
148149
popd || exit 1
149150
151+
- name: Generate shared types documentation
152+
run: |
153+
API_FILE="${{ needs.setup.outputs.api_file }}"
154+
TARGET_FILE="website/assets/agw-docs/pages/reference/api/${API_FILE}"
155+
SHARED_DIR="kgateway/api/v1alpha1/shared"
156+
AGENTGATEWAY_SOURCE_DIR="kgateway/api/v1alpha1/agentgateway"
157+
if [ -f "$TARGET_FILE" ]; then
158+
echo "Generating shared types documentation for ${API_FILE}..."
159+
python3 website/scripts/generate-shared-types.py \
160+
"$SHARED_DIR" \
161+
"$TARGET_FILE" \
162+
"$AGENTGATEWAY_SOURCE_DIR"
163+
else
164+
echo "API doc file not found - skipping shared types"
165+
fi
166+
150167
- name: Generate Helm and metrics docs
151168
run: |
152169
DOC_VERSION="${{ needs.setup.outputs.doc_version }}" \
153170
WEBSITE_DIR="website" \
154171
KGATEWAY_DIR="kgateway" \
155172
python3 website/scripts/generate-ref-docs.py
156173
174+
# Create PR: needs "Allow GitHub Actions to create and approve pull requests" (Settings → Actions)
175+
# or a repo secret CREATE_PR_TOKEN (PAT with pull_requests: write).
157176
- name: Create PR for website repo
158177
uses: peter-evans/create-pull-request@v7
159178
id: create-pr
@@ -164,17 +183,17 @@ jobs:
164183
Generate reference documentation for agentgateway (${{ needs.setup.outputs.api_file }}).
165184
166185
Source: kgateway-dev/kgateway at `${{ needs.setup.outputs.ref }}`.
167-
Updates API reference, Helm (agentgateway + agentgateway-crds), and control plane metrics for the ${{ needs.setup.outputs.directory }} version.
186+
Updates API reference (including shared types such as CEL expression), Helm (agentgateway + agentgateway-crds), and control plane metrics for the ${{ needs.setup.outputs.directory }} version.
168187
169188
This PR was created automatically by the reference-docs workflow.
170189
171190
Workflow run: https://github.com/agentgateway/website/actions/runs/${{ github.run_id }}
172191
branch: ref-docs-${{ needs.setup.outputs.doc_version }}
173-
commit-message: 'docs: update API, Helm, and metrics docs from kgateway ${{ needs.setup.outputs.ref }}'
192+
commit-message: 'docs: update API (incl. shared types), Helm, and metrics docs from kgateway ${{ needs.setup.outputs.ref }}'
174193
committer: GitHub Action <action@github.com>
175194
delete-branch: true
176195
title: '[Automated] Update reference docs (${{ needs.setup.outputs.doc_version }}) from kgateway ${{ needs.setup.outputs.ref }}'
177-
token: ${{ secrets.GITHUB_TOKEN }}
196+
token: ${{ secrets.CREATE_PR_TOKEN || secrets.GITHUB_TOKEN }}
178197

179198
- name: Output PR URL
180199
run: |

scripts/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ The workflow and `generate-ref-docs.py` read this file to decide which ref to us
2121

2222
Configuration for [crd-ref-docs](https://github.com/elastic/crd-ref-docs). Used when generating Kubernetes API reference docs from kgateway’s `api/v1alpha1/agentgateway` types. The workflow passes this as `--config` to `go run github.com/elastic/crd-ref-docs@latest`.
2323

24+
### `generate-shared-types.py`
25+
26+
Python script that appends **shared types** documentation (e.g. CEL expression) to the generated API reference markdown. It parses Go source in kgateway’s shared and agentgateway packages, finds broken type links in the API doc, and appends markdown for those types so crd-ref-docs output is complete. The workflow runs it after writing the API doc:
27+
28+
- **Arguments:** `generate-shared-types.py <shared_dir> <doc_file> [source_dir...]`
29+
- **shared_dir** – e.g. `kgateway/api/v1alpha1/shared`
30+
- **doc_file** – e.g. `website/assets/agw-docs/pages/reference/api/api-22x.md`
31+
- **source_dir** (optional) – e.g. `kgateway/api/v1alpha1/agentgateway`
32+
33+
If the doc file is missing, the script is skipped. If `shared_dir` does not exist, the script still runs and uses any provided source dirs.
34+
2435
### `generate-ref-docs.py`
2536

2637
Python script that generates **Helm** and **metrics** reference docs only (API docs are generated in the workflow). It expects:
@@ -40,7 +51,8 @@ Requires Go (for helm-docs and findmetrics). No cloning; the workflow checks out
4051

4152
1. **Setup job** – Checks out the website, reads `scripts/versions.json`, resolves the kgateway ref for the chosen doc version, and verifies that branch exists.
4253
2. **API docs step** – Checks out kgateway at that ref, runs crd-ref-docs with `scripts/crd-ref-docs-config.yaml`, and writes API markdown to `assets/agw-docs/pages/reference/api/{apiFile}`.
43-
3. **Helm and metrics step** – Runs `scripts/generate-ref-docs.py` with `DOC_VERSION`, `WEBSITE_DIR=website`, and `KGATEWAY_DIR=kgateway` so the script generates Helm and metrics into the website tree.
44-
4. **Create PR** – Commits all changes under the website path and opens a PR.
54+
3. **Shared types step** – Runs `scripts/generate-shared-types.py` with kgateway’s shared and agentgateway API dirs and the API doc file, appending documentation for shared types (e.g. CEL) that crd-ref-docs does not emit.
55+
4. **Helm and metrics step** – Runs `scripts/generate-ref-docs.py` with `DOC_VERSION`, `WEBSITE_DIR=website`, and `KGATEWAY_DIR=kgateway` so the script generates Helm and metrics into the website tree.
56+
5. **Create PR** – Commits all changes under the website path and opens a PR.
4557

4658
To add a new doc version (e.g. 2.4.x), add an entry to `versions.json` with the appropriate `apiFile`, `kgatewayRef`, and `metricsSnippet`, then run the workflow with that version.

0 commit comments

Comments
 (0)