diff --git a/.github/scripts/index_template.html b/.github/scripts/index_template.html new file mode 100644 index 0000000..0bde8a5 --- /dev/null +++ b/.github/scripts/index_template.html @@ -0,0 +1,16 @@ + + + + rtfm docs + + +

Documentation Versions

+ + + \ No newline at end of file diff --git a/.github/scripts/requirements.txt b/.github/scripts/requirements.txt new file mode 100644 index 0000000..518bb28 --- /dev/null +++ b/.github/scripts/requirements.txt @@ -0,0 +1 @@ +Jinja2==3.1.5 \ No newline at end of file diff --git a/.github/scripts/update_index.py b/.github/scripts/update_index.py new file mode 100644 index 0000000..28c8840 --- /dev/null +++ b/.github/scripts/update_index.py @@ -0,0 +1,31 @@ +from pathlib import Path +import os +import re +import jinja2 + +VERSION_RE = re.compile( + r"(?P[0-9]+)\.(?P[0-9]+)\.(?P[0-9]+)(?:(?P[ab])(?P[0-9]*))?" +) + + +def main(): + scripts_dir = Path(os.path.dirname(__file__)) + root_dir = Path(*scripts_dir.parts[:-2]) + + index_fp = root_dir / "index.html" + + versions = [ + folder.name + for folder in root_dir.glob("*") + if folder.is_dir and VERSION_RE.fullmatch(folder.name) + ] + + env = jinja2.Environment(loader=jinja2.PackageLoader("update_index", "")) + template = env.get_template("index_template.html") + + with index_fp.open("w", encoding="UTF-8") as f: + f.write(template.render(versions=versions)) + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/update_index.yml b/.github/workflows/update_index.yml new file mode 100644 index 0000000..99ea27b --- /dev/null +++ b/.github/workflows/update_index.yml @@ -0,0 +1,34 @@ +name: Update Root Index + +on: + push: + branches: + - gh-pages + +jobs: + update_index: + runs-on: ubuntu-latest + permissions: + contents: write + env: + python_ver: 3.13 + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ env.python_ver }} + uses: actions/setup-python@v2 + with: + python-version: ${{ env.python_ver }} + + - name: Goto scripts dir + run: | + cd .github + cd scripts + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Update Index + run: | + python update_index.py \ No newline at end of file