Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Generate Reference
on:
pull_request:
push:
branches: [master, main, 'v?[0-9]+.[0-9]+**']
jobs:
docgen:
name: Run generator script
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install deps
run: |
pip install -r docs/requirements.txt
- name: Run script
run: python docs/generate_reference.py ${{ github.head_ref || github.ref_name }}
- name: commit changes
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: Update docs/reference.md [no ci]
file_pattern: docs/reference.md
5 changes: 4 additions & 1 deletion docs/generate_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from pathlib import Path
import re
import sys
from typing import Any, Hashable, override

from jinja2 import Environment, FileSystemLoader
Expand Down Expand Up @@ -52,13 +53,15 @@ def main():
schemas = components["schemas"]

sha = "master"
if len(sys.argv) >= 2:
sha = sys.argv[1]

markdown = j2_env.get_template("reference_template.md").render(
schemas=schemas,
sha=sha,
)

with Path("reference.md").open("w") as stream:
with SCRIPT_DIR.joinpath("reference.md").open("w") as stream:
_ = stream.write(markdown)


Expand Down
Loading