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:
1 parent
713b2f8815
commit
c935ddf930
6 files changed
+251
No files matched your search
@@ -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"
|
||||
Reference in new issue
Block a user