From 0c1c99ac70c7e320992a0706a010503c8ead786e Mon Sep 17 00:00:00 2001 From: 4DBug Date: Sun, 1 Nov 2026 01:54:49 -0500 Subject: [PATCH] docs/STYLE.md: the comment policy (specs only) --- docs/STYLE.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/STYLE.md b/docs/STYLE.md index 437190f..b1a40f4 100644 --- a/docs/STYLE.md +++ b/docs/STYLE.md @@ -77,6 +77,30 @@ The first comment line starts with the module path (`core/Bytes:`, `image/png:`, the root). A format's `init.luau` header says what is supported and what is not, and where it came from (spec, port, absorbed repo). +### Comments +Comments carry specifications, not documentation. Usage lives in `docs/API.md` and `docs/guide`, and the code says what +it does. Keep: +- the file header, 1-3 lines (above); +- spec citations: section numbers, field and bit layouts, magic values, where a table comes from; +- one-line notes where the code deliberately matches a reference tool's quirk or follows a non-obvious spec rule; +- units and layouts on type fields (`pts: number, -- seconds`, `data: buffer, -- u16 LE per cell`); +- licence / provenance lines and the `--!` directives. + +Remove signature and docstring comments, comments that restate the code, narrative and history ("we tried X"), +usage examples, and divider banners other than the CONTRACT section markers. +```luau +-- keep +-- CRC-32/MPEG-2 (poly 0x04C11DB7, init 0xFFFFFFFF, MSB first, no final xor): a section including its CRC sums to 0 +break -- no end-of-archive blocks: accepted, as GNU tar does (with a warning) +-- LuaJIT keeps t[0] in the array part, so check it + +-- remove +-- expect(ctx, i, ch) -> next position after ch (skipping blanks), or nil +-- UTF-8 of a code point +-- ---------------------------------------------------------------------------------------------- helpers +``` +`python3 -I tools/comment_diff.py ` checks that a comment-only change leaves every file's token stream unchanged. + ### Section order (CONTRACT) Section markers are `-- ` + 96 dashes + ` `; in a format's `init.luau` they appear in this order (requires and contract are mandatory, the rest as needed):