Skip to content

Commit 2c55a55

Browse files
committed
[build] Add build check to ensure CLI docs are up to date #457
1 parent 9d0af3c commit 2c55a55

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

.github/workflows/check-docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Checks that the CLI docs are up-to-date. If this fails on your PR, there may be some changes
2+
# to the command-line docs that were not updated. Run `python docs/generate_cli_docs.py` from
3+
# the root PySceneDetect source folder and commit the changes to resolve the issue.
4+
name: Check Documentation
5+
6+
on:
7+
schedule:
8+
- cron: '0 0 * * *'
9+
pull_request:
10+
paths:
11+
- docs/**
12+
- scenedetect/**
13+
push:
14+
paths:
15+
- docs/**
16+
- scenedetect/**
17+
branches:
18+
- main
19+
- 'releases/**'
20+
tags:
21+
- v*-release
22+
workflow_dispatch:
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Set up Python 3.12
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.12'
35+
cache: 'pip'
36+
37+
- name: Install Dependencies
38+
run: |
39+
python -m pip install --upgrade pip build wheel virtualenv
40+
pip install -r docs/requirements.txt
41+
pip install -r dist/requirements_windows.txt
42+
43+
44+
- name: Check CLI Documentation
45+
shell: bash
46+
run: |
47+
if [[ `git status --porcelain=1 | wc -l` -ne 0 ]]; then
48+
echo "CLI documentation is of date: docs/cli.rst does not match output after running docs/generate_cli_docs.py!"
49+
echo "Re-run `python docs/generate_cli_docs.py` to update and commit the result."
50+
exit 1
51+
fi

.github/workflows/generate-docs.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ jobs:
5151
git config --global user.name github-actions
5252
git config --global user.email github-actions@github.com
5353
54+
- name: Check CLI Documentation
55+
shell: bash
56+
run: |
57+
if [[ `git status --porcelain=1 | wc -l` -ne 0 ]]; then
58+
echo "CLI documentation is of date: docs/cli.rst does not match output after running docs/generate_cli_docs.py!"
59+
echo "Re-run `python docs/generate_cli_docs.py` to update and commit the result."
60+
exit 1
61+
fi
62+
5463
- name: Generate Docs
5564
run: |
5665
sphinx-build -b html docs build

docs/cli.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.. NOTE: This file is auto-generated by docs/generate_cli_docs.py and should not be modified.
12
23
************************************************************************
34
``scenedetect`` 🎬 Command

docs/generate_cli_docs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def create_help() -> ty.Tuple[str, ty.List[str]]:
267267
def main():
268268
help, commands = create_help()
269269
help = patch_help(help, commands)
270+
help = ".. NOTE: This file is auto-generated by docs/generate_cli_docs.py and should not be modified.\n" + help
270271
with open("docs/cli.rst", "wb") as f:
271272
f.write(help.encode())
272273

0 commit comments

Comments
 (0)