Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .github/actions/setup-pandoc/action.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def path(self, root=ROOT):
frozenset(
{
"modsim quality",
"modsim docs",
"docs",
"modsim tox (3.10)",
"modsim tox (3.14)",
"modpoll snapshot replay",
Expand All @@ -91,6 +91,7 @@ def path(self, root=ROOT):
"modpoll-wot package",
"consumer (modpoll)",
"consumer (modsim)",
"docs",
INTEGRATION,
}
),
Expand Down
117 changes: 117 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: docs

# The documentation site of all three packages (DOC-02). Pull requests and v2 build it with warnings as errors
# and check its links. A package release, or a manual run, builds it from the release tag and publishes it to
# /v2/ on gh-pages; the 1.x site at the root and /1.x/ is left alone. A modpoll-wot release also publishes the
# vocabulary at /vocab/wot-modbus/ from the same checkout. .nojekyll at the root of gh-pages keeps the _static
# directories served.
on:
push:
branches: [v2]
paths: &paths
- docs/**
- packages/**
- pyproject.toml
- uv.lock
- .github/workflows/docs.yml
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths: *paths
workflow_dispatch:
inputs:
tag:
description: Release tag to build and publish, such as modpoll-v2.0.0a13
type: string
required: true
workflow_call:
inputs:
tag:
type: string
required: true

permissions:
contents: read

jobs:
# The release guard (.github/scripts/release.py) requires this check on every release commit.
docs:
if: ${{ !inputs.tag }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
with:
version: 0.11.19
python-version: "3.14"
enable-cache: true
cache-dependency-glob: uv.lock
- run: uv sync --locked --only-group docs
- run: uv run --no-sync sphinx-build -W --keep-going -b html -d "$RUNNER_TEMP/doctrees" docs "$RUNNER_TEMP/html"

links:
name: docs links
if: ${{ !inputs.tag }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
with:
version: 0.11.19
python-version: "3.14"
enable-cache: true
cache-dependency-glob: uv.lock
- run: uv sync --locked --only-group docs
- run: uv run --no-sync sphinx-build -b linkcheck -d "$RUNNER_TEMP/doctrees" docs "$RUNNER_TEMP/linkcheck"

publish:
name: docs publish
if: ${{ inputs.tag }}
runs-on: ubuntu-latest
permissions:
contents: write
env:
TAG: ${{ inputs.tag }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ inputs.tag }}
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
with:
version: 0.11.19
python-version: "3.14"
enable-cache: true
cache-dependency-glob: uv.lock
- run: uv sync --locked --only-group docs
- run: uv run --no-sync sphinx-build -W --keep-going -b html -d "$RUNNER_TEMP/doctrees" docs "$RUNNER_TEMP/html"
# The vocabulary is a machine identifier outside the version tree. Files of earlier contract versions are
# never removed.
- name: Collect the vocabulary
if: ${{ startsWith(inputs.tag, 'modpoll-wot-v') }}
run: |
vocab="$RUNNER_TEMP/vocab"
cp -r packages/modpoll-wot/vocab/wot-modbus "$vocab"
cp packages/modpoll-wot/modpoll_wot/schemas/acquisition-0.2.json "$vocab/"
cp packages/modpoll-wot/profile.md "$vocab/contract-0.2.txt"
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: gh-pages
path: pages
# Replaces /v2/ only. The packages of one release batch publish at the same time, so a rejected push is
# retried on top of the other one.
- name: Publish to gh-pages
working-directory: pages
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
for attempt in 1 2 3 4 5; do
git fetch -q origin gh-pages
git reset -q --hard origin/gh-pages
rsync -a --delete "$RUNNER_TEMP/html/" v2/
if [ -d "$RUNNER_TEMP/vocab" ]; then rsync -a "$RUNNER_TEMP/vocab/" vocab/wot-modbus/; fi
git add -A v2 vocab
if git diff --cached --quiet; then exit 0; fi
git commit -q -m "docs: publish from $TAG"
if git push -q origin HEAD:gh-pages; then exit 0; fi
sleep $((attempt * 5))
done
exit 1
39 changes: 3 additions & 36 deletions .github/workflows/modpoll-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,44 +148,11 @@ jobs:
name: modpoll release docs
needs: [candidate, publish]
if: ${{ !cancelled() && needs.candidate.result == 'success' && needs.candidate.outputs.git-tag != '' && (needs.publish.result == 'success' || (github.ref_name == 'v2' && needs.publish.result == 'skipped')) }}
runs-on: ubuntu-latest
concurrency:
group: modpoll-pages
cancel-in-progress: false
permissions:
contents: write
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ needs.candidate.outputs.git-tag }}
- uses: ./.github/actions/setup-uv
with:
package: modpoll
- uses: ./.github/actions/setup-pandoc
- name: Build preview documentation
run: make docs
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: gh-pages
path: packages/modpoll/.pages
- name: Assemble both versions while preserving the vocabulary
run: |
mkdir .site
rsync -a --exclude=.git .pages/ .site/
test -f .site/1.x/index.html
test -f .site/vocab/wot-modbus/acquisition-0.1.json
test -f .site/vocab/wot-modbus/contract-0.1.txt
wot_version=$(uv run --locked --no-sync python -c 'import importlib.metadata as m; print(m.version("modpoll-wot"))')
# modpoll-wot is released from this repository since TOOL-01, under packages/modpoll-wot.
wot_source="https://raw.githubusercontent.com/top-maker/modpoll/modpoll-wot-v$wot_version/packages/modpoll-wot"
curl -fsSL "$wot_source/modpoll_wot/schemas/acquisition-0.2.json" -o vocab/wot-modbus/acquisition-0.2.json
curl -fsSL "$wot_source/profile.md" -o vocab/wot-modbus/contract-0.2.txt
python .github/scripts/assemble-docs.py docs/_build/html .site v2 --vocab vocab
printf '%s\n' "$(git rev-parse HEAD)" > .site/v2/source-sha.txt
- uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4
with:
github_token: ${{ github.token }}
publish_dir: packages/modpoll/.site
uses: ./.github/workflows/docs.yml
with:
tag: ${{ needs.candidate.outputs.git-tag }}
acceptance:
name: modpoll release acceptance
needs: [candidate, publish, image, docs]
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/modpoll-wot-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,12 @@ jobs:
run: |
gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 ||
gh release create "$GITHUB_REF_NAME" dist/* --verify-tag --prerelease --title "modpoll-wot $VERSION" --notes "See packages/modpoll-wot/CONTRACT.md and profile.md at this tag."

docs:
name: modpoll-wot release docs
needs: publish
permissions:
contents: write
uses: ./.github/workflows/docs.yml
with:
tag: ${{ github.ref_name }}
19 changes: 0 additions & 19 deletions .github/workflows/modpoll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,6 @@ jobs:
- name: Test with tox
run: uv run --locked --no-sync tox -e ${{ matrix.tox-env }}

docs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4

- name: Set up uv
uses: ./.github/actions/setup-uv
with:
package: modpoll

- name: Set up pandoc
uses: ./.github/actions/setup-pandoc

- name: Build documentation
run: make docs

# Unchanged by TOOL-01: the interop checks keep their pinned 1.x baseline and simulator fixture.
modsim-equivalence:
runs-on: ubuntu-latest
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/modsim-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,14 @@ jobs:
# The image installs from the workspace lock, so it builds from the repository root.
run: docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile -t "$REGISTRY/$USERNAME/modsim:${GIT_TAG#modsim-v}" --push ../..

# The modsim documentation site is not published from this repository yet (TOOL-01 decision 7); the
# release still proves that the preview documentation builds.
docs:
name: modsim release docs
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ github.ref }}
- uses: ./.github/actions/setup-uv
with:
package: modsim
- run: uv run --locked --no-sync --group docs mkdocs build -s -f mkdocs-preview.yml --site-dir "$RUNNER_TEMP/site"
permissions:
contents: write
uses: ./.github/workflows/docs.yml
with:
tag: ${{ github.ref_name }}

acceptance:
name: modsim release acceptance
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/modsim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
- name: Run checks
run: make check

- name: Check the generated ADAM-6024 TD
run: uv run --locked --no-sync python tools/generate-td.py --check

tox:
name: modsim tox (${{ matrix.python-version }})
runs-on: ubuntu-latest
Expand Down Expand Up @@ -102,14 +105,3 @@ jobs:
env:
MODSIM_TEST_MODPOLL_PYTHON: ${{ runner.temp }}/modpoll/bin/python
run: uv run --locked pytest tests/test_snapshot_replay.py -v

docs:
name: modsim docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: ./.github/actions/setup-uv
with:
package: modsim
- run: uv run --locked --no-sync --group docs mkdocs build -s
- run: uv run --locked --no-sync python tools/generate-td.py --check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/docs/_build/
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# modpoll, modsim and modpoll-wot

**Documentation:** <https://top-maker.github.io/modpoll/v2/>

This branch (`v2`) holds three tools that read, simulate and describe Modbus devices with W3C WoT Thing Models.
They are released separately to PyPI and share one uv workspace and one lock file.

Expand All @@ -23,3 +25,15 @@ Each package keeps its own `Makefile`, tests and release notes. `integration/` r
modpoll against each other with modpoll-wot's conformance model, over Modbus TCP and RTU on a virtual serial
port (`uv run pytest integration` after the sync above). A release is a tag named after the package,
for example `modsim-v2.0.0a13`, which runs that package's release workflow.

The documentation site for all three packages is built from `docs/` with Sphinx, MyST and Furo. Its dependency
group needs Python 3.13 or later:

```bash
uv sync --only-group docs --python 3.14
uv run --no-sync sphinx-build -W -b html docs docs/_build/html
uv run --no-sync sphinx-autobuild docs docs/_build/html
```

Pull requests build it with warnings as errors and check its links. Each package release publishes it from the
release tag to `/v2/`; a modpoll-wot release also publishes `/vocab/wot-modbus/`.
45 changes: 45 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Sphinx configuration for the modpoll, modsim and modpoll-wot documentation site (DOC-02)."""

project = "modpoll"
author = "Ying Shaodong"
copyright = "2021-2026, Ying Shaodong"

extensions = ["myst_parser", "sphinxarg.ext", "sphinx_reredirects"]
myst_enable_extensions = ["colon_fence", "deflist"]
myst_heading_anchors = 3

exclude_patterns = ["_build"]
# Command-line help keeps its literal "--option" text.
smartquotes = False

# Pages of the earlier /v2/ site, linked from published release notes.
redirects = {
"installation": "guide/installation.html",
"quickstart": "guide/quickstart.html",
"usage": "guide/read-a-device.html",
"configure": "reference/modpoll/configuration.html",
"csv-migration": "guide/migrate-from-v1-csv.html",
"v1-compatibility": "reference/modpoll/v1-compatibility.html",
"changelog": "reference/modpoll/changelog.html",
}

html_theme = "furo"
html_title = "modpoll, modsim and modpoll-wot"
html_copy_source = False
html_baseurl = "https://top-maker.github.io/modpoll/v2/"
html_theme_options = {
"source_repository": "https://github.com/top-maker/modpoll/",
"source_branch": "v2",
"source_directory": "docs/",
"announcement": (
"This is the 2.x preview of modpoll, modsim and modpoll-wot. "
'Stable modpoll 1.x (CSV configurations) is documented at <a href="/modpoll/1.x/">1.x</a>.'
),
}

linkcheck_ignore = [
# Placeholders and local addresses in examples.
r"https?://(127\.0\.0\.1|localhost)",
# Historical modsim changelog entries compare against tags that were never created.
r"https://github\.com/top-maker/modsim/compare/v0\.(3\.4|4\.0)\.\.\.",
]
Loading
Loading