Skip to content
Closed
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
45 changes: 44 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,50 @@ jobs:
# Exact versions only: a loose match would resolve a moving release.
version-type: strict
install-hex: true
rebar3-version: '3.28.0'

- name: Cache pinned Rebar3
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/libtmux-docs-tools/rebar3/rebar3
key: rebar3-${{ runner.os }}-${{ runner.arch }}-3.28.0-5a28b1cca082d3b023ec0f5df9d9f9d52557036c6f2a21c1ffa11b93a984dd42

- name: Install pinned Rebar3
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
rebar_dir="$RUNNER_TEMP/libtmux-docs-tools/rebar3"
rebar_file="$rebar_dir/rebar3"
rebar_sha=5a28b1cca082d3b023ec0f5df9d9f9d52557036c6f2a21c1ffa11b93a984dd42
rebar_download=''
rebar_install_dir=''
rebar_ready=false
cleanup_rebar() {
if [[ -n "$rebar_download" ]]; then
rm -f -- "$rebar_download"
fi
if [[ "$rebar_ready" != true && -n "$rebar_install_dir" ]]; then
rm -rf -- "$rebar_install_dir"
fi
}
trap cleanup_rebar EXIT
mkdir -p "$rebar_dir"
if [[ ! -f "$rebar_file" ]] || ! printf '%s %s\n' "$rebar_sha" "$rebar_file" | sha256sum --check --status; then
rebar_download=$(mktemp "$rebar_dir/.rebar3.XXXXXXXX")
gh api -H 'Accept: application/octet-stream' \
repos/erlang/rebar3/releases/assets/664140441 > "$rebar_download"
printf '%s %s\n' "$rebar_sha" "$rebar_download" | sha256sum --check --strict
mv "$rebar_download" "$rebar_file"
fi
rebar_install_dir=$(mktemp -d "$RUNNER_TEMP/libtmux-docs-rebar3.XXXXXXXX")
install -m 755 "$rebar_file" "$rebar_install_dir/rebar3"
printf '%s %s\n' "$rebar_sha" "$rebar_install_dir/rebar3" | sha256sum --check --strict
rebar_version=$(REBAR_GLOBAL_CONFIG_DIR="$RUNNER_TEMP/rebar3-empty-config" \
REBAR_CONFIG="$RUNNER_TEMP/rebar3-empty.config" "$rebar_install_dir/rebar3" version)
printf '%s\n' "$rebar_version"
[[ "$rebar_version" == 'rebar 3.28.0 '* ]]
printf '%s\n' "$rebar_install_dir" >> "$GITHUB_PATH"
rebar_ready=true

- name: Stage integrated source guides
env:
Expand Down
30 changes: 26 additions & 4 deletions notes/adding-a-port.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ In the new worktree, on `docs-site`:

### Erlang compiler artifact

The Erlang exporter builds a clean source checkout with its selected Rebar3,
then reads EEP-48 Markdown and abstract code from the compiled application.
The Erlang exporter builds a clean source checkout with its selected Rebar3
in a temporary build directory, then reads EEP-48 Markdown and abstract code.
Use the source project's OTP 29 and Rebar3 toolchain on `PATH`. With the
Erlang source checkout beside this docs worktree, export its core API:

Expand All @@ -167,18 +167,40 @@ $ escript packages/api-model/scripts/export-erlang.escript \
../libtmux-erlang/_build/docs/api.json
```

The artifact records the source commit, tracked input hashes, OTP version and
exporter source digest.
The version-3 artifact records the source commit, tracked input hashes, OTP
version and exporter source digest.
It retains native module, function, type and callback documentation, typespecs,
nominal types, supporting non-exported types and exported native records.
Source locations follow included headers. Opaque declarations expose their
name and parameters. Hidden modules and members stay out. Dirty sources,
missing compiler chunks and ambiguous source paths fail the export.

The exporter parses formatted declarations to identify type and native-record
references, including their arities and UTF-16 ranges. It checks that formatting
preserves the syntax tree. OTP destinations require a compiler-known builtin or
an entry in that module's documentation; unknown types remain unresolved.
The exporter observes compiler file calls inside the temporary Rebar VM and
uses an identity parse transform to capture the actual compiler options before
OTP's deterministic build removes preprocessing context. OTP's preprocessor recovers
full paths in that same VM, preserving its library paths, environment and
working directory. The resulting forms must match the compiled
forms. This rejects external public headers even when their basenames and
declarations match tracked headers. Private OTP headers may supply implementation
records, but every documented declaration must resolve to a regular tracked
source file. Tracked source symlinks are rejected; temporary Rebar build links
back to those regular files are permitted.
An unreproducible preprocessing context fails the export. Explicit `-file`
source remapping is unsupported. Temporary compiler
context and build output are removed on completion or an export error.

`extractErlang` maps the artifact to the shared API model. The compiler supplies
callable parameters, return types, overload clauses and quoted atom spellings.
The model retains native arities, supporting types and distinct type/callback
identities. Native `m:`, `t:` and `c:` references resolve within their module.
API signatures and their Markdown copies retain Erlang syntax and use the
compiler's reference ranges for links. The site checks the 60-column display
limit after native formatting. The `libtmux_erlang_workspace` application maps
to the workspace product; the core application maps to core.
Erlang has no shared site routes or package destinations until the port's
delivery checks are complete. The compiler fixture runs in the outer test loop; it
requires OTP 29 and Rebar3 on CI and skips locally when that toolchain is absent.
Expand Down
Loading
Loading