From 5949172735fa2cfdb3cf23c6512b748c876d8a48 Mon Sep 17 00:00:00 2001 From: ROllerozxa Date: Mon, 18 Sep 2023 18:17:18 +0200 Subject: [PATCH] Build MkDocs Lua API docs using GitHub CI, deploy to api.minetest.net (#13675) * Build MkDocs Lua API documentation using GitHub CI and Pages instead * Remove Lua highlight hack as codeblocks are correctly marked as Lua now * fix line endings --- .github/workflows/lua_api_deploy.yml | 48 ++++++++++++++++++++++++++++ CNAME | 1 + doc/mkdocs/build.sh | 4 --- doc/mkdocs/lua_highlight.patch | 9 ------ doc/mkdocs/requirements.txt | 4 +-- 5 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/lua_api_deploy.yml create mode 100644 CNAME delete mode 100644 doc/mkdocs/lua_highlight.patch diff --git a/.github/workflows/lua_api_deploy.yml b/.github/workflows/lua_api_deploy.yml new file mode 100644 index 000000000..574e3ba3e --- /dev/null +++ b/.github/workflows/lua_api_deploy.yml @@ -0,0 +1,48 @@ +name: lua_api_deploy + +permissions: + contents: read + pages: write + id-token: write + +on: + push: + paths: + - '.github/workflows/lua_api_deploy.yml' + - 'doc/lua_api.md' + - 'doc/mkdocs/' + branches: + - master + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install mkdocs + run: | + pip install -U -r doc/mkdocs/requirements.txt + + - name: Build documentation + run: | + cd doc/mkdocs/ + ./build.sh + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: 'public/' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/CNAME b/CNAME new file mode 100644 index 000000000..c8f58d469 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +api.minetest.net diff --git a/doc/mkdocs/build.sh b/doc/mkdocs/build.sh index 33e28acee..12266441c 100755 --- a/doc/mkdocs/build.sh +++ b/doc/mkdocs/build.sh @@ -1,9 +1,5 @@ #!/bin/sh -e -# Patch Python-Markdown -MARKDOWN_FILE=$(pip show markdown | awk '/Location/ { print $2 }')/markdown/extensions/codehilite.py -patch -N -r - $MARKDOWN_FILE lua_highlight.patch || true - # Split lua_api.md on top level headings cat ../lua_api.md | csplit -sz -f docs/section - '/^=/-1' '{*}' diff --git a/doc/mkdocs/lua_highlight.patch b/doc/mkdocs/lua_highlight.patch deleted file mode 100644 index e231081d6..000000000 --- a/doc/mkdocs/lua_highlight.patch +++ /dev/null @@ -1,9 +0,0 @@ -@@ -75,7 +75,7 @@ - css_class="codehilite", lang=None, style='default', - noclasses=False, tab_length=4, hl_lines=None, use_pygments=True): - self.src = src -- self.lang = lang -+ self.lang = "lua" - self.linenums = linenums - self.guess_lang = guess_lang - self.css_class = css_class diff --git a/doc/mkdocs/requirements.txt b/doc/mkdocs/requirements.txt index e16265312..522de3aa7 100644 --- a/doc/mkdocs/requirements.txt +++ b/doc/mkdocs/requirements.txt @@ -1,2 +1,2 @@ -mkdocs~=1.3.0 -pygments~=2.12.0 +mkdocs~=1.4.3 +pygments~=2.15.1