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
50 changes: 50 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# SPDX-FileCopyrightText: (c) 2026 Ring Zero Desenvolvimento de Software LTDA
# SPDX-License-Identifier: MIT OR GPL-2.0-only
#

name: Build Docs
on:
pull_request:
push:
branches:
- master
release:
types:
- published
workflow_dispatch:
concurrency:
group: ${{ github.event_name == 'pull_request' && github.ref || 'gh-pages' }}
jobs:
build:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Checkout Lunatik's style
# the site takes the template, the stylesheet and the search of Lunatik's, whose master config.ld reads at .lunatik/
run: git clone --depth 1 https://github.com/luainkernel/lunatik.git .lunatik
- name: Setup dependencies
run: |
# LDoc runs on lua5.4, the newest Lua the archive builds it for, and discount, which the archive dropped, comes from luarocks for that Lua
bash harness/tools/retry.sh 5 90 sudo sh -c 'apt-get update && apt-get install -y lua5.5 lua5.4 lua-ldoc luarocks liblua5.4-dev libmarkdown2-dev'
bash harness/tools/retry.sh 5 90 sudo luarocks --lua-version=5.4 install discount DISCOUNT_INCDIR=/usr/include/$(gcc -print-multiarch) DISCOUNT_LIBDIR=/usr/lib/$(gcc -print-multiarch)
- name: Build docs
run: |
# the template reads the release a page belongs to and the releases the site serves; this site serves one, unlisted
: > doc/.tags
: > doc/.releases
ldoc .
cp .lunatik/doc/style/site.js site/
cp -r .lunatik/doc/style/fonts site/
lua5.5 .lunatik/doc/style/search.lua site
- name: Deploy
# the site shows the latest release, so a push to master builds it and deploys nothing
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/bytecode/
*.so
/site/
/.lunatik
55 changes: 55 additions & 0 deletions config.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
-- SPDX-FileCopyrightText: (c) 2026 Ring Zero Desenvolvimento de Software LTDA
-- SPDX-License-Identifier: MIT OR GPL-2.0-only

-- LDoc configuration of luaebpf's site, which takes Lunatik's style: the docs workflow checks Lunatik
-- out at .lunatik/, and `ldoc .` writes the site to site/
project = 'luaebpf'
description = 'Lua compiled to eBPF for Lunatik.'
title = 'luaebpf API Documentation'
sort_modules = true
file = {
'./init.lua',
'./lib/bpf/map.lua',
'./lib/bpf/tc.lua',
'./lib/bpf/vmlinux.lua',
'./lib/bpf/xdp.lua',
'./lib/lunatik.lua',
}
dir = 'site'
-- discount renders tables, which the built-in markdown leaves as text
format = 'discount'
-- LDoc writes a backticked name out as <code> before discount runs, so SmartyPants reaches inside it
local unsmart = {ndash = '--', mdash = '---', hellip = '...'}
postprocess_html = function(html)
return (html:gsub('<code>(.-)</code>', function(code)
return '<code>' .. code:gsub('&(%a+);', unsmart) .. '</code>'
end))
end
style = './.lunatik/doc/style'
template = './.lunatik/doc/style'
-- the template renders README.md as the home page and the other topics as the guide
topics = {
'README.md',
'./doc/guide/08-luaebpf.md',
'./doc/guide/09-luaebpf-by-example.md',
}
use_markdown_titles = true
manual_url 'https://www.lua.org/manual/5.5/manual.html'
boilerplate = true
merge = true
sort = true

-- what the site's template reads of this project
vars = {
github = 'https://github.com/luainkernel/luaebpf',
headline = {'XDP and TC programs', 'written in Lua'},
donate = 'https://luainkernel.github.io/lunatik/index.html#support',
areas = {
{'compiler', 'Compiler', 'Compiling a program file into a BPF object.',
{'^luaebpf$'},
'M8 6l-6 6 6 6M16 6l6 6-6 6'},
{'declarations', 'Program file', 'The modules a program file\'s body requires to declare what the object carries.',
{},
'M4 4h16v16H4zM8 9h8M8 13h8M8 17h5'},
},
}
6 changes: 3 additions & 3 deletions doc/design/luaebpf/compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ requires, installed as source".
### What the body requires

The order in which `require` finds a module in the body is in
[Program files](../../guide/02-running-scripts.md#program-files). `compile`, in `init.lua`, builds
[Program files](https://luainkernel.github.io/lunatik/topics/02-running-scripts.md.html#program-files). `compile`, in `init.lua`, builds
it: while the body runs, `package.path` is the compile-time modules in `bin/luaebpf/lib/` and
`package.cpath` is empty, a searcher `init.lua` adds finds the compiler's own `luaebpf.*` through
the host's path, and the last one, which `proto.lua` adds, loads a module under `/lib/modules/lua/`,
Expand Down Expand Up @@ -147,7 +147,7 @@ its line and its reason, and its count summed over the entries of the possible C
report reads the lines the kernel holds for the running program, not the object on disk, which a
`make install` or a `lunatik bpf -o` may have written again since the run. What
`run`, `stop` and `unload` do with these is in
[Compiled programs](../../guide/02-running-scripts.md#compiled-programs).
[Compiled programs](https://luainkernel.github.io/lunatik/topics/02-running-scripts.md.html#compiled-programs).

### Building and installing

Expand All @@ -156,7 +156,7 @@ puts `lunatic` beside `lunatik`, the compiler under the host's Lua path as `luae
loader under its C path, and then runs `lunatik bpf` over the program files of `examples/` and
`tests/`, but the `luaebpf` suite's, leaving each object at its script's path under
`/usr/local/lib/bpf/luaebpf/`, `LUAEBPF_OBJECTS_INSTALL_PATH`, where `lunatik run` looks for it
([Compiled programs](../../guide/02-running-scripts.md#compiled-programs)), once it has removed
([Compiled programs](https://luainkernel.github.io/lunatik/topics/02-running-scripts.md.html#compiled-programs)), once it has removed
what its previous run left under `examples/` and `tests/` there.

## The translator
Expand Down
4 changes: 2 additions & 2 deletions doc/guide/08-luaebpf.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ Each refusal reads `lunatik: <file>:<line>: <message>`.

A program file, `<name>.bpf.lua`, may declare several programs. Each is named by the `name` its
constructor takes, or after the file, and `lunatik run --dev` attaches every one of them, as
[Compiled programs](02-running-scripts.md#compiled-programs) describes.
[Compiled programs](https://luainkernel.github.io/lunatik/topics/02-running-scripts.md.html#compiled-programs) describes.

`lunatik bpf` compiles for the kernel `lunatik.config` names, which `make` writes from the kernel
tree Lunatik is built against. Three facts of that kernel change what compiles:
Expand All @@ -711,6 +711,6 @@ tree Lunatik is built against. Three facts of that kernel change what compiles:
The offsets of the context fields come from the kernel's BTF, `/sys/kernel/btf/vmlinux` unless
`--btf` names another file, so a program that reads its context, or the packet, compiles only
where that BTF is. Compiling for another kernel is in
[Program files](02-running-scripts.md#program-files). A TC program needs libbpf 1.3.0 or later on
[Program files](https://luainkernel.github.io/lunatik/topics/02-running-scripts.md.html#program-files). A TC program needs libbpf 1.3.0 or later on
the machine that loads it.

Loading