Add a ci step that checks that documentation md files are mentioned in docs/SUMMARY.md (#8439)

This commit is contained in:
Raymond Dodge 2025-12-05 04:20:23 -05:00 committed by GitHub
parent b5f27b5668
commit fc25d943a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 79 additions and 0 deletions

64
.github/docs_validate/inclusive_summary.py vendored Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/python3
"""
Checks that all documentation pages that should be mentioned in
`docs/SUMMARY.md` are mentioned the file
"""
import glob
import re
import os
from pathlib import Path
errorLines = []
if not os.path.exists("Makefile"):
errorLines.append("Please run this script from your root folder.")
summaryFile = Path("docs/SUMMARY.md")
if not errorLines:
if not summaryFile.is_file():
errorLines.append("docs/SUMMARY.md missing")
summaryContents = []
if not errorLines:
with open(summaryFile, 'r', encoding='UTF-8') as file:
entry_pattern = re.compile(r" *\- \[[^\]]*\]\(([^\)]*)\)\n")
lineNo = 0
while line:=file.readline():
lineNo = lineNo + 1
if line == "# Summary\n" or line == "\n":
pass
elif match:=entry_pattern.match(line):
if "" != match.group(1):
summaryContents.append(Path(match.group(1)))
else:
if not errorLines:
errorLines.append("## Unexpected lines in docs/SUMMARY.md")
errorLines.append(f"- {lineNo}: {line.strip()}")
if not errorLines:
for pathName in glob.glob("**/*.md", root_dir="docs", recursive=True):
path = Path(pathName)
if path == Path("SUMMARY.md"):
pass
elif path == Path("changelogs/template.md"):
pass
elif path in summaryContents:
pass
else:
if not errorLines:
errorLines.append("## `docs/**/*.md` files present but not mentioned in `docs/SUMMARY.md`")
errorLines.append("- " + str(path))
if errorLines:
for line in errorLines:
print(line)
if 'GITHUB_STEP_SUMMARY' in os.environ:
with open(os.environ['GITHUB_STEP_SUMMARY'], 'w', encoding='UTF-8') as file:
for line in errorLines:
file.write(line)
file.write('\n')
quit(1)

View File

@ -43,6 +43,18 @@ jobs:
TEST: 1 TEST: 1
run: | run: |
make -j${nproc} check make -j${nproc} check
docs_validate:
if: github.actor != 'allcontributors[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check that SUMMARY.md includes markdown doc files
run: |
.github/docs_validate/inclusive_summary.py
allcontributors: allcontributors:
if: github.actor == 'allcontributors[bot]' if: github.actor == 'allcontributors[bot]'
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -7,6 +7,7 @@
- [Linux]() - [Linux]()
- [ARCH_LINUX](./install/linux/ARCH_LINUX.md) - [ARCH_LINUX](./install/linux/ARCH_LINUX.md)
- [DEBIAN](./install/linux/DEBIAN.md) - [DEBIAN](./install/linux/DEBIAN.md)
- [FEDORA](./install/linux/FEDORA.md)
- [NIXOS](./install/linux/NIXOS.md) - [NIXOS](./install/linux/NIXOS.md)
- [OTHERS](./install/linux/OTHERS.md) - [OTHERS](./install/linux/OTHERS.md)
- [UBUNTU](./install/linux/UBUNTU.md) - [UBUNTU](./install/linux/UBUNTU.md)
@ -37,6 +38,8 @@
- [How to use Follower NPCs](tutorials/how_to_follower_npc.md) - [How to use Follower NPCs](tutorials/how_to_follower_npc.md)
- [Time-Based Encounters](tutorials/how_to_time_of_day_encounters.md) - [Time-Based Encounters](tutorials/how_to_time_of_day_encounters.md)
- [How to use Trainer Party Pools](tutorials/how_to_trainer_party_pool.md) - [How to use Trainer Party Pools](tutorials/how_to_trainer_party_pool.md)
- [How to Apricorn Tree](tutorials/how_to_apricorn_tree.md)
- [How to Namebox](tutorials/how_to_namebox.md)
- [Vs. Seeker](tutorials/vs_seeker.md) - [Vs. Seeker](tutorials/vs_seeker.md)
- [Changelog](./CHANGELOG.md) - [Changelog](./CHANGELOG.md)
- [1.14.x]() - [1.14.x]()