docs/STYLE.md: the comment policy (specs only)
This commit is contained in:
1 parent
a905f48575
commit
0c1c99ac70
1 file changed
+24
@@ -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 <base>` checks that a comment-only change leaves every file's token stream unchanged.
|
||||
|
||||
### Section order (CONTRACT)
|
||||
Section markers are `-- ` + 96 dashes + ` <name>`; in a format's `init.luau` they appear in this order (requires and
|
||||
contract are mandatory, the rest as needed):
|
||||
|
||||
Reference in new issue
Block a user