Skip to content

Commit 8980b4c

Browse files
pfeerickclaude
andauthored
chore: convert 2.5 docs from GitBook to MkDocs (#24)
Replace the GitBook tree with the MkDocs source the published 2.5 site is already built from: the page content (converted by tools/import_legacy_gitbook.py on edgetx_2.12) in website/md-docs/, a mkdocs.yml for this version, and the uv project files. The branch now builds itself: the publish workflow deploys it as "2.5" on push, and pull requests get a Cloudflare preview. "Edit this page" is enabled and opens this branch. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 85fc21a commit 8980b4c

426 files changed

Lines changed: 5347 additions & 1066 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/preview-docs.yml‎

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Builds a preview of the docs for each pull request and uploads it to
2+
# Cloudflare as a Worker *version* with a preview alias. Production keeps
3+
# serving the deployed version; the preview is only reachable at
4+
# https://pr-<number>-edgetx-lua-reference-guide.edgetx.workers.dev/
5+
#
6+
# The PR is built as the version its base branch publishes (main -> "dev",
7+
# edgetx_<x.y> -> "<x.y>", plus "latest" for the latest release branch) on
8+
# top of the current gh-pages tree, so the preview is the whole site with
9+
# that one version replaced. Nothing is pushed to gh-pages.
10+
#
11+
# Only runs for PRs from branches in this repo: fork PRs don't get the
12+
# Cloudflare secrets, and building untrusted code with them available
13+
# would be unsafe anyway.
14+
name: Preview Docs
15+
16+
on:
17+
pull_request:
18+
branches:
19+
- main
20+
- "edgetx_*"
21+
22+
permissions:
23+
contents: read
24+
pull-requests: write
25+
26+
concurrency:
27+
group: preview-docs-${{ github.event.pull_request.number }}
28+
cancel-in-progress: true
29+
30+
jobs:
31+
preview:
32+
if: github.event.pull_request.head.repo.full_name == github.repository
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- name: Check out source
37+
uses: actions/checkout@v7
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Resolve version metadata
42+
id: version
43+
shell: bash
44+
env:
45+
LATEST_BRANCH: ${{ vars.DOCS_LATEST_BRANCH || 'edgetx_2.12' }}
46+
run: |
47+
case "${GITHUB_BASE_REF}" in
48+
main)
49+
version_id="dev"
50+
title="Dev"
51+
;;
52+
edgetx_[0-9]*.[0-9]*)
53+
version_id="${GITHUB_BASE_REF#edgetx_}"
54+
title="${version_id}"
55+
;;
56+
*)
57+
echo "Unsupported base branch: ${GITHUB_BASE_REF}" >&2
58+
exit 1
59+
;;
60+
esac
61+
62+
if [[ "${GITHUB_BASE_REF}" == "${LATEST_BRANCH}" ]]; then
63+
aliases="${version_id} latest"
64+
else
65+
aliases="${version_id}"
66+
fi
67+
68+
{
69+
echo "version_id=${version_id}"
70+
echo "title=${title}"
71+
echo "aliases=${aliases}"
72+
echo "alias=pr-${{ github.event.pull_request.number }}"
73+
} >> "${GITHUB_OUTPUT}"
74+
75+
- name: Install uv
76+
uses: astral-sh/setup-uv@v10.3.2
77+
78+
- name: Set up Python
79+
uses: actions/setup-python@v7
80+
with:
81+
python-version: "3.11"
82+
83+
- name: Sync docs dependencies
84+
run: uv sync
85+
86+
- name: Configure git author
87+
run: |
88+
git config user.name "github-actions[bot]"
89+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
90+
91+
- name: Build preview into local gh-pages
92+
env:
93+
DOCS_EDIT_URI: edit/${{ github.head_ref }}/website/md-docs/
94+
run: |
95+
git branch -f gh-pages origin/gh-pages
96+
uv run mike deploy --update-aliases --title "${{ steps.version.outputs.title }}" ${{ steps.version.outputs.aliases }}
97+
98+
- name: Export gh-pages tree for Cloudflare
99+
run: |
100+
rm -rf .site-publish
101+
mkdir .site-publish
102+
git archive gh-pages | tar -x -C .site-publish
103+
104+
- name: Upload preview version to Cloudflare Workers
105+
uses: cloudflare/wrangler-action@v4
106+
with:
107+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
108+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
109+
command: versions upload --preview-alias ${{ steps.version.outputs.alias }} --message "PR #${{ github.event.pull_request.number }} @ ${{ github.event.pull_request.head.sha }}"
110+
111+
- name: Comment preview link on the PR
112+
env:
113+
GH_TOKEN: ${{ github.token }}
114+
PR_NUMBER: ${{ github.event.pull_request.number }}
115+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
116+
run: |
117+
url="https://${{ steps.version.outputs.alias }}-edgetx-lua-reference-guide.edgetx.workers.dev/${{ steps.version.outputs.version_id }}/"
118+
body="📖 **Docs preview:** ${url}
119+
120+
Built from ${HEAD_SHA::7} as the \`${{ steps.version.outputs.version_id }}\` version, on top of the currently published site."
121+
gh pr comment "${PR_NUMBER}" --edit-last --create-if-none --body "${body}"
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Publishes each docs branch via `mike deploy` on every push:
2+
# main -> "dev"
3+
# edgetx_<x.y> -> "<x.y>", plus "latest" for the latest release branch
4+
#
5+
# Every branch carries its own MkDocs site (mkdocs.yml + website/md-docs/)
6+
# and an identical copy of this workflow, so a push builds the branch it
7+
# came from. The latest release branch comes from the DOCS_LATEST_BRANCH
8+
# repository variable (falling back to edgetx_2.12), so moving "latest" to
9+
# a new release is a settings change rather than an edit on every branch.
10+
#
11+
# mike keeps the accumulated versioned site on the gh-pages branch; after
12+
# each deploy, the full gh-pages tree is published to Cloudflare Workers
13+
# (static assets, see wrangler.jsonc). Requires the CLOUDFLARE_API_TOKEN and
14+
# CLOUDFLARE_ACCOUNT_ID repository secrets.
15+
name: Publish Versioned Docs
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
- "edgetx_*"
22+
workflow_dispatch:
23+
24+
permissions:
25+
contents: write
26+
27+
# Every run rewrites gh-pages and then uploads the whole tree, so run them
28+
# one at a time to avoid racing mike or publishing a stale snapshot.
29+
concurrency:
30+
group: publish-versioned-docs
31+
cancel-in-progress: false
32+
33+
jobs:
34+
publish:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Check out source
39+
uses: actions/checkout@v7
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v10.3.2
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v7
48+
with:
49+
python-version: "3.11"
50+
51+
- name: Resolve version metadata
52+
id: version
53+
shell: bash
54+
env:
55+
LATEST_BRANCH: ${{ vars.DOCS_LATEST_BRANCH || 'edgetx_2.12' }}
56+
run: |
57+
branch="${GITHUB_REF_NAME}"
58+
59+
case "${branch}" in
60+
main)
61+
version_id="dev"
62+
title="Dev"
63+
;;
64+
edgetx_[0-9]*.[0-9]*)
65+
version_id="${branch#edgetx_}"
66+
title="${version_id}"
67+
;;
68+
*)
69+
echo "Unsupported branch: ${branch}" >&2
70+
exit 1
71+
;;
72+
esac
73+
74+
if [[ "${branch}" == "${LATEST_BRANCH}" ]]; then
75+
aliases="${version_id} latest"
76+
is_latest="true"
77+
else
78+
aliases="${version_id}"
79+
is_latest="false"
80+
fi
81+
82+
{
83+
echo "version_id=${version_id}"
84+
echo "title=${title}"
85+
echo "aliases=${aliases}"
86+
echo "is_latest=${is_latest}"
87+
} >> "${GITHUB_OUTPUT}"
88+
89+
- name: Sync docs dependencies
90+
run: uv sync
91+
92+
- name: Configure git author
93+
run: |
94+
git config user.name "github-actions[bot]"
95+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
96+
97+
- name: Publish docs with mike
98+
env:
99+
# "Edit this page" should open the branch this version is built from.
100+
DOCS_EDIT_URI: edit/${{ github.ref_name }}/website/md-docs/
101+
run: uv run mike deploy --push --update-aliases --title "${{ steps.version.outputs.title }}" ${{ steps.version.outputs.aliases }}
102+
103+
- name: Set default docs version
104+
if: steps.version.outputs.is_latest == 'true'
105+
run: uv run mike set-default --push latest
106+
107+
- name: Export gh-pages tree for Cloudflare
108+
run: |
109+
rm -rf .site-publish
110+
mkdir .site-publish
111+
git archive gh-pages | tar -x -C .site-publish
112+
113+
- name: Deploy to Cloudflare Workers
114+
uses: cloudflare/wrangler-action@v4
115+
with:
116+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
117+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
118+
command: deploy

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
/_book/
22
/node_modules/
33
/book.pdf
4+
/site/
5+
/.site-legacy-generated/
6+
/site-legacy/
7+
.tmp/
8+
.venv/
9+
__pycache__/
10+
/.site-publish/

‎Bitmap/getSize.md‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎Bitmap/open.md‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎README.md‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
# EdgeTX 2.5 Lua Reference Guide
22

3-
[Join the chat on Discord](https://discord.gg/CZCwVx2)
3+
Source for the EdgeTX 2.5 version of the Lua Reference Guide, published at
4+
<https://luadoc.edgetx.org/2.5/>.
45

5-
The latest version of this guide will always be available [here](https://luadoc.edgetx.org). At the top of the left sidebar there is a version option if you are running an older version of EdgeTX or OpenTX and need the docs for that specific version.
6+
This content was converted from the original GitBook branch to MkDocs. It is
7+
kept for reference, so it may not include corrections made in later versions.
8+
The page content lives in `website/md-docs/`; edit it there.
69

7-
Please feel free to make suggestions or corrections to the documentation on GitHub, but the prefered method of editing is to use [GitBook](https://www.gitbook.com/), so all changes will need to be made by someone who is authorized as a writer there.&#x20;
10+
## Local preview
811

9-
This guide covers the development of user-written scripts for R/C transmitters running the EdgeTX 2.5 operating system with Lua support. Readers should be familiar with EdgeTX/OpenTX, the OpenTX Companion, and know how to transfer files the SD card in the transmitter.
12+
```sh
13+
uv run mkdocs serve -a 127.0.0.1:8014
14+
```
1015

11-
If you are new to Lua programming, you may also find the [Lua Reference Manual](https://www.lua.org/manual/5.2/) of assistance
12-
13-
Part I is an overview of the different script types, along with basic examples of each.
14-
15-
Part II is a programming guide that introduces the types of EdgeTX Lua scripts and how to use them.
16-
17-
Part III is the EdgeTX Lua API Reference
18-
19-
Part IV covers advanced topics with examples
16+
Pushes to `edgetx_2.5` are published automatically by
17+
`.github/workflows/publish-versioned-docs.yml`, and pull requests get a
18+
preview deployment from `.github/workflows/preview-docs.yml`.

‎RadioSpecialFunctions.png‎

-106 KB
Binary file not shown.

0 commit comments

Comments
 (0)