Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion .github/workflows/check-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ on:
- scenedetect/**
- scenedetect.cfg
- website/**
- pyproject.toml
- .github/workflows/check-docs.yml
push:
paths:
- docs/**
- scenedetect/**
- scenedetect.cfg
- website/**
- pyproject.toml
- .github/workflows/check-docs.yml
branches:
- main
- 'releases/**'
Expand All @@ -28,6 +32,8 @@ jobs:
# workflow author, who then gets emailed when a fork's nightly build fails.
if: github.repository_owner == 'Breakthrough' || github.event_name != 'schedule'
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v7.0.1
Expand Down Expand Up @@ -61,7 +67,7 @@ jobs:
- name: Build Website (--strict)
shell: bash
run: |
python website/build.py --strict
python website/build.py --strict --sphinx-dir docs/_build/html

- name: Check Responsive Layout & Capture Screenshots
shell: bash
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
workflow_dispatch:

concurrency:
group: gh-pages
group: gh-pages-docs
cancel-in-progress: false

jobs:
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
DOCS_DEST: ${{ env.scenedetect_docs_dest }}
run: |
git fetch origin gh-pages
git checkout gh-pages
git checkout -B gh-pages origin/gh-pages
git clean -ffdx
git rm "docs/${DOCS_DEST}" -r -f --ignore-unmatch
mkdir -p "docs/${DOCS_DEST}"
Expand Down Expand Up @@ -121,5 +121,17 @@ jobs:
git commit -a -m "[docs] @${TRIGGER_ACTOR}: Generate Documentation" \
-m "Source: ${GITHUB_REF_NAME} (${GITHUB_SHA})" \
-m "Destination: ${DOCS_DEST}"
git push
for attempt in 1 2 3 4 5; do
if git push origin gh-pages; then
break
fi
if [[ "${attempt}" -eq 5 ]]; then
echo "Failed to push to gh-pages after ${attempt} attempts." >&2
exit 1
fi
echo "Push failed (attempt ${attempt}/5); rebasing onto origin/gh-pages and retrying..."
sleep $((attempt * 2))
git fetch origin gh-pages
git pull --rebase origin gh-pages
done
fi
18 changes: 15 additions & 3 deletions .github/workflows/generate-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
- clear-staging

concurrency:
group: gh-pages
group: gh-pages-website
cancel-in-progress: false

jobs:
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
shell: bash
run: |
git fetch origin gh-pages
git checkout gh-pages
git checkout -B gh-pages origin/gh-pages
git clean -ffdx

if [[ "${DEPLOY_TARGET}" == "production" ]]; then
Expand Down Expand Up @@ -126,7 +126,19 @@ jobs:
git commit -a -m "[docs] @${TRIGGER_ACTOR}: Generate Website (${DEPLOY_TARGET})" \
-m "Source: ${GITHUB_REF_NAME} (${GITHUB_SHA})" \
-m "Target: ${DEPLOY_TARGET}"
git push
for attempt in 1 2 3 4 5; do
if git push origin gh-pages; then
break
fi
if [[ "${attempt}" -eq 5 ]]; then
echo "Failed to push to gh-pages after ${attempt} attempts." >&2
exit 1
fi
echo "Push failed (attempt ${attempt}/5); rebasing onto origin/gh-pages and retrying..."
sleep $((attempt * 2))
git fetch origin gh-pages
git pull --rebase origin gh-pages
done
fi
env:
DEPLOY_TARGET: ${{ env.deploy_target }}
Expand Down
73 changes: 48 additions & 25 deletions docs/_ext/doc_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,69 @@ def _entry(slug: str, label: str, group: str) -> dict[str, Any]:
def load_doc_versions(
repo_dir: Path, fallback_version: str = ""
) -> tuple[str, list[dict[str, Any]]]:
"""Load (latest_version, version_entries) from docs/LATEST_VERSION and website/pages/docs.md."""
"""Load (latest_version, version_entries) from docs/LATEST_VERSION and website/pages/docs.md.

Raises:
ValueError: If LATEST_VERSION cannot be resolved, website/pages/docs.md is missing or
yields no stable/legacy version entries, or LATEST_VERSION is not listed under
the Stable section of website/pages/docs.md.
"""
latest_file = repo_dir / "docs" / "LATEST_VERSION"
latest_ver = (
latest_file.read_text(encoding="utf-8").strip().lstrip("v")
if latest_file.is_file()
else fallback_version.lstrip("v")
else fallback_version.strip().lstrip("v")
)
if not latest_ver:
raise ValueError(
f"Could not determine latest documentation version from {latest_file} "
"(and no fallback_version was provided)."
)

docs_md = repo_dir / "website" / "pages" / "docs.md"
if not docs_md.is_file():
raise ValueError(f"Missing documentation version index: {docs_md}")

stable_slugs: list[str] = []
legacy_slugs: list[str] = []
docs_md = repo_dir / "website" / "pages" / "docs.md"
if docs_md.is_file():
section = ""
for raw_line in docs_md.read_text(encoding="utf-8").splitlines():
line = raw_line.strip()
if line.startswith("## "):
section = line[3:].strip().lower()
continue
match = _DOC_LINK_RE.match(line)
if not match:
continue
slug = match.group(2).strip()
if slug in {"latest", "head"}:
continue
if section == "legacy":
legacy_slugs.append(slug)
else:
stable_slugs.append(slug)
section = ""
for raw_line in docs_md.read_text(encoding="utf-8").splitlines():
line = raw_line.strip()
if line.startswith("## "):
section = line[3:].strip().lower()
continue
match = _DOC_LINK_RE.match(line)
if not match:
continue
slug = match.group(2).strip()
if slug in {"latest", "head"}:
continue
if section == "legacy":
legacy_slugs.append(slug)
elif section == "stable":
stable_slugs.append(slug)

if not stable_slugs and latest_ver:
stable_slugs = [latest_ver, "0.7"]
if not stable_slugs:
raise ValueError(
f"No stable version links found under '## Stable' in {docs_md}; "
"expected '- [vX.Y.Z](/docs/X.Y.Z/)' list items."
)
if not legacy_slugs:
legacy_slugs = ["0.6.7"]
raise ValueError(
f"No legacy version links found under '## Legacy' in {docs_md}; "
"expected '- [vX.Y.Z](/docs/X.Y.Z/)' list items."
)
if latest_ver not in stable_slugs:
raise ValueError(
f"LATEST_VERSION '{latest_ver}' is not listed under '## Stable' in {docs_md} "
f"(found: {', '.join(stable_slugs)})."
)

entries = [
_entry("latest", f"v{latest_ver} (latest)", "channel"),
_entry("head", "dev (head)", "channel"),
]
# Avoid duplicating `latest` as a separate row when it is the current stable release.
entries += [_entry(slug, f"v{slug}", "release") for slug in stable_slugs if slug != latest_ver]
if legacy_slugs:
entries.append(_entry(legacy_slugs[0], f"v{legacy_slugs[0]} (legacy)", "legacy"))
entries.append(_entry(legacy_slugs[0], f"v{legacy_slugs[0]} (legacy)", "legacy"))
return latest_ver, entries
4 changes: 0 additions & 4 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
</script>
{%- endif %}
<script type="module">
if (!Object.hasOwn(HTMLElement.prototype, "popover")) {
import("https://unpkg.com/@oddbird/popover-polyfill@0.6.1/dist/popover.min.js").catch(() => {});
}

(() => {
const meta = document.querySelector('meta[name="color-scheme"]');
if (meta) {
Expand Down
Loading
Loading