src/rules/style/doc.bend checks
raw source on the hub · import bolt@1.48.0.0/src/rules/style/doc.bend as Doc
rule doc: every top-level def, type and law has a comment block right above
it: one or more column-0 # lines with no blank line between them and the
item, save a run of column-0 @ lines (attributes such as @unsafe) that
may sit between the block and the item. A block of bare # lines counts,
though its text is empty; a line that starts inside a multi-line string
literal is text, never a comment line. Helpers
(dotted names like show.go) ride on their parent's doc, main needs none,
PROOF.bend fills laws that LAWS.bend already documents, and a test (under
tests/) is documented by its header and its check names.
8 imports
import Base import ../../src.bend as Src import ../../finding.bend as F import ../../syntax/outline.bend as Outline import ../../lazy/lazy.bend as Lazy import ../../paths.bend as Paths import ../../role.bend as Role import ../../syntax/lex.bend as Lex
Types
type Cell source · line 87 · raw
Data
a line and whether a comment block ends right above it
Cell@line:U32 -> @ok:Bool -> Cell
type Flags source · line 91 · raw
Data
the flags, by the low bits of the line
FNoneFlags
FLeaf@cells:List<&2, Cell> -> Flags
FNode@lo:Flags -> @hi:Flags -> Flags
Definitions
def needs source · line 20 · raw
@kk:0x6bb0891959f774bd94f33b9c30f054d3/src/syntax/outline.ItemKind -> Bool
does an item of this kind need a comment?
def exempt source · line 32 · raw
@+name:String -> Bool
main, and helpers named x.go
def what source · line 36 · raw
@kk:0x6bb0891959f774bd94f33b9c30f054d3/src/syntax/outline.ItemKind -> String
an item's kind, for the message
def check.after source · line 48 · raw
@+hh:String -> @ok:Bool -> Bool
reading down, does a comment block end right above the next line? After a
comment line (its first char #) it does; an attribute line (@unsafe)
keeps what was above it; any other line ends it
def check.lead source · line 53 · raw
@lines:List<&2, String> -> @+nn:U32 -> @+ok:Bool -> Bool
reading lines 0 to nn - 1 down from ok: does a comment block end right above line nn, past a run of attribute lines?
def check.above source · line 64 · raw
@+lines:List<&2, String> -> @+nn:U32 -> Bool
is there a comment line right above line nn, or right above the attribute
lines right above it? A block of bare # lines counts, though its doc text
is empty. An item's comment block always ends there, so this test alone
decides: the doc text, what the comments say, is never read
def check.go source · line 67 · raw
@items:List<&2, 0x6bb0891959f774bd94f33b9c30f054d3/src/syntax/outline.Item> -> @+path:String -> @+lines:List<&2, String> -> List<&2, 0x6bb0891959f774bd94f33b9c30f054d3/src/finding.Finding>
def flags.depth source · line 97 · raw
Nat
how many bits of a line the flags branch on
def flags.cells source · line 101 · raw
@fl:Flags -> List<&2, Cell>
the cells at a leaf, none elsewhere
def flags.pick source · line 111 · raw
@bb:Bool -> @lo:Flags -> @hi:Flags -> Flags
the low half for a set bit, the high half else
def flags.near source · line 119 · raw
@bb:Bool -> @fl:Flags -> Flags
the half of a node a bit goes down, empty elsewhere
def flags.join source · line 127 · raw
@bb:Bool -> @sub:Flags -> @far:Flags -> Flags
a node whose half down a bit is sub, and the other half far
def flags.put source · line 136 · raw
@dd:Nat -> @+kk:U32 -> @+fl:Flags -> @cell:Cell -> Flags
the flags with one more cell, down the low bits of its line, in front of what its leaf held
def flags.find source · line 145 · raw
@cs:List<&2, Cell> -> @+nn:U32 -> Bool
the flag of the first cell at a line among these; none there is no flag
def flags.at source · line 153 · raw
@dd:Nat -> @+kk:U32 -> @fl:Flags -> @+nn:U32 -> Bool
the flag at a line, down the low bits of a line
def flags.build source · line 163 · raw
@lines:List<&2, String> -> @+ii:U32 -> @+ok:Bool -> Flags
the flags of these lines, the first of them line ii, read down from ok. Each line is put in after the lines below it, so a line number met again (past the U32's end) never hides the first
def flags source · line 171 · raw
@lines:List<&2, String> -> Flags
the flags of a file's lines
def above.at source · line 175 · raw
@fl:Flags -> @+nn:U32 -> Bool
does a comment block end right above line nn? The flags' answer
def check.fast source · line 178 · raw
@items:List<&2, 0x6bb0891959f774bd94f33b9c30f054d3/src/syntax/outline.Item> -> @+path:String -> @+fl:Flags -> List<&2, 0x6bb0891959f774bd94f33b9c30f054d3/src/finding.Finding>
def lines.go source · line 188 · raw
@ls:List<&2, String> -> @+ins:List<&2, Bool> -> List<&2, String>
def lines source · line 197 · raw
@text:String -> @toks:List<&2, 0x6bb0891959f774bd94f33b9c30f054d3/src/syntax/lex.Tok> -> List<&2, String>
the lines of a source, each one that starts inside a string literal read as empty: it is text, never a comment line
def check source · line 201 · raw
@ss:0x6bb0891959f774bd94f33b9c30f054d3/src/src.Src -> List<&2, 0x6bb0891959f774bd94f33b9c30f054d3/src/finding.Finding>
the rule
def check.role source · line 207 · raw
@rr:0x6bb0891959f774bd94f33b9c30f054d3/src/role.Role -> @ss:0x6bb0891959f774bd94f33b9c30f054d3/src/src.Src -> List<&2, 0x6bb0891959f774bd94f33b9c30f054d3/src/finding.Finding>
the rule, told the file's role (src/role.bend): a proof file is skipped