docs: the fork's documentation as a website, tth-pub.pages.rfa.cz/meshcore-tth

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-12-02 00:54:10 +01:00
1 parent 713b2f8815
commit c935ddf930
6 files changed
+251

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# The docs website of this fork (https://tth-pub.pages.rfa.cz/meshcore-tth/):
# mkdocs (theme mkdocs-terminal) over docs/, in English: the English half of
# the fork's README is the home page, the Czech half one page (cs.md); the
# fork's own docs first, upstream's below.
#
# Usage: .github/docs-site.sh <out dir> (run from the repo root)
# Needs mkdocs-terminal and markdown-callouts, e.g.
# uvx --with mkdocs-terminal --with markdown-callouts mkdocs --version
# The script stages a copy of docs/ (README split into index.md / cs.md,
# links that leave docs/ pointed at the repo) and builds it with
# mkdocs.tth.yml. Upstream's mkdocs.yml (Material) stays as it is (no
# conflicts in upstream-sync merges).
# Build only from the PUBLIC tree (tth-pub): the export leaves our operations
# docs out, a build of the private repo would publish them.
set -euo pipefail
case "${1:-}" in -h | --help | "")
sed -n '2,/^[^#]/{/^#/s/^# \{0,1\}//p}' "$0"
[ -n "${1:-}" ] || exit 2
exit 0
;;
esac
out=$(realpath -m "$1")
repo=https://git.rfa.cz/tth-pub/meshcore-tth
src="$repo/src/branch/main"
stage=$(mktemp -d)
trap 'rm -rf "$stage"' EXIT
cp -r docs "$stage/docs"
# upstream's own introduction gets a page of its own; ours is the home page
mv "$stage/docs/index.md" "$stage/docs/meshcore.md"
rm -f "$stage/docs/docs.md" # how to build upstream's site, not for readers
# README of the fork: "## O tomto forku" .. "## About this fork" = Czech,
# from there to "## About MeshCore" = English. One heading level up, links
# into docs/ made site-relative, any other repo path absolute.
readme_part() {
sed -n "/^## $1/,/^## $2/p" README.md | sed '$d' |
sed -E 's/^#(#+) /\1 /' |
sed -E 's#\]\((\./)?docs/([^)]+)\)#](\2)#g' |
sed -E "s#\\]\\((\\./)?([a-zA-Z][^):]*)\\)#](${src//#/\\#}/\\2)#g"
}
readme_part 'About this fork' 'About MeshCore' >"$stage/docs/index.md"
readme_part 'O tomto forku' 'About this fork' >"$stage/docs/cs.md"
if ! grep -q . "$stage/docs/index.md" || ! grep -q . "$stage/docs/cs.md"; then
echo "docs-site: README sections not found (headings changed?)" >&2
exit 1
fi
# the two languages link to each other by anchor, and "above"/"below"
# is a separate page here
sed -i -E 's#Česká verze \[výše\]#[Česká verze]#' "$stage/docs/index.md"
sed -i -E 's#English version \[below\]#[English version]#' "$stage/docs/cs.md"
sed -i -E 's#\]\(\#about-this-fork[^)]*\)#](index.md)#g' "$stage/docs/cs.md"
sed -i -E 's#\]\(\#o-tomto-forku[^)]*\)#](cs.md)#g' "$stage/docs/index.md"
# GFM (Gitea) needs `\|` for a pipe in code inside a table cell; Python-
# Markdown keeps the backslash and does not split cells on a pipe in code
perl -0pi -e 's/(`[^`\n]*`)/ (my $c = $1) =~ s#\\\|#|#g; $c /ge' "$stage"/docs/*.md
# our docs link back to ../README.md
sed -i -E 's#\]\(\.\./README\.md#](index.md#g' "$stage"/docs/*.md
cp mkdocs.tth.yml "$stage/"
cd "$stage"
mkdocs build --strict -f mkdocs.tth.yml -d "$out"
+3
View File
@@ -11,6 +11,9 @@ permissions:
jobs:
github-pages:
# CUSTOM (TeTeHacko): upstream's site only; this fork publishes its own
# (tth-docs.yml), and here the job only filled an unread gh-pages branch
if: github.repository == 'meshcore-dev/MeshCore'
runs-on: ubuntu-latest
steps:
+82
View File
@@ -0,0 +1,82 @@
# Docs website of this fork: https://tth-pub.pages.rfa.cz/meshcore-tth/
#
# Runs only in the published repo (tth-pub/meshcore-tth), after a push to main
# that touches the docs: .github/docs-site.sh builds the site (mkdocs, theme
# mkdocs-terminal, mkdocs.tth.yml) from the public tree -- the export leaves
# our operations docs out, so nothing private can end up on it -- and the
# result is force-pushed as the only commit of the branch `pages`. A webhook
# of the repo (push, branch filter `pages`) tells git-pages on pages.rfa.cz,
# which clones the branch anonymously: no token outside this repo's own.
# git-pages: roles/git_pages in the proxmox.rfa.cz repo.
name: tth-docs
"on":
push:
branches: [main]
paths:
- "docs/**"
- "README.md"
- "mkdocs.tth.yml"
- ".github/docs-site.sh"
- ".github/workflows/tth-docs.yml"
workflow_dispatch:
concurrency:
group: tth-docs
cancel-in-progress: true
permissions:
contents: write
env:
MKDOCS_VERSION: "1.6.1"
MKDOCS_TERMINAL_VERSION: "4.8.0"
MARKDOWN_CALLOUTS_VERSION: "0.4.0"
PYMDOWN_EXTENSIONS_VERSION: "13.1.2"
jobs:
site:
if: github.repository == 'tth-pub/meshcore-tth'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# No actions/setup-python: its builds need x86-64-v3, the runner has v2
# (see tth-tools-lint.yml). mkdocs goes into a venv of the image's python3.
- name: Install mkdocs
run: |
set -euo pipefail
SUDO="$(command -v sudo || true)"
if ! python3 -m venv "$RUNNER_TEMP/docs"; then
$SUDO apt-get update -qq
$SUDO apt-get install -y -qq python3 python3-venv
python3 -m venv --clear "$RUNNER_TEMP/docs"
fi
"$RUNNER_TEMP/docs/bin/pip" install --quiet \
"mkdocs==$MKDOCS_VERSION" "mkdocs-terminal==$MKDOCS_TERMINAL_VERSION" \
"markdown-callouts==$MARKDOWN_CALLOUTS_VERSION" \
"pymdown-extensions==$PYMDOWN_EXTENSIONS_VERSION"
echo "$RUNNER_TEMP/docs/bin" >>"$GITHUB_PATH"
- name: Build
env:
NO_MKDOCS_2_WARNING: "1"
run: bash .github/docs-site.sh "$RUNNER_TEMP/site"
# A worktree shares the checkout's credentials (github.token); the
# branch keeps one commit, the site of the newest main.
- name: Publish to the pages branch
run: |
set -euo pipefail
git config --global user.name "tth-docs"
git config --global user.email "tth-docs@localhost"
wt="$RUNNER_TEMP/pages"
git worktree add -q --detach "$wt"
cd "$wt"
git checkout -q --orphan pages-build
git rm -rqf .
cp -r "$RUNNER_TEMP/site/." .
git add -A
git commit -q -m "docs site from main ${GITHUB_SHA:0:8}"
git push -q -f origin HEAD:refs/heads/pages
echo "published ${GITHUB_SHA:0:8} to pages"