~/bend-docscommunity

src/rules/style/doc.bend checks

raw source on the hub · import bolt@1.21.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.

7 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 ../../syntax/lex.bend as Lex

Definitions

def needs source · line 19 · raw

@kk:0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/outline.ItemKind -> Bool

does an item of this kind need a comment?

def exempt source · line 31 · raw

@+name:String -> Bool

main, and helpers named x.go

def what source · line 35 · raw

@kk:0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/outline.ItemKind -> String

an item's kind, for the message

def check.after source · line 47 · 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 52 · 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 63 · 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 66 · raw

@items:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/outline.Item> -> @+path:String -> @+lines:List<&2, String> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

def lines.go source · line 76 · raw

@ls:List<&2, String> -> @+ins:List<&2, Bool> -> List<&2, String>

def lines source · line 85 · raw

@text:String -> @toks:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/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 89 · raw

@ss:0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

the rule