Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SpellcheckerImportComments = &analysis.Analyzer{ Name: "spellchecker_import_comments", Doc: "Checks that each import declaration has exactly one 'spellchecker:words' comment containing the words in the imports", Run: func(pass *analysis.Pass) (interface{}, error) { for _, file := range pass.Files { if isDoNotEdit(file) || isDisabled(file) { continue } analyzeImportWordDirective(pass, file) } return nil, nil }, }
var SpellcheckerPackageComments = &analysis.Analyzer{ Name: "spellchecker_package_comments", Doc: "Checks that each package name has exactly one 'spellchecker:words' comment containing the words in the package name", Run: func(pass *analysis.Pass) (interface{}, error) { for _, file := range pass.Files { if isDoNotEdit(file) || isDisabled(file) { continue } analyzePackageWordDirective(pass, file) } return nil, nil }, }
var SpellcheckerWords = &analysis.Analyzer{ Name: "spellchecker_word_comments", Doc: "Checks that each 'spellchecker:words' comment is formatted correctly and not empty", Run: func(pass *analysis.Pass) (interface{}, error) { for _, file := range pass.Files { if isDoNotEdit(file) || isDisabled(file) { continue } analyzeWordsDirectives(pass, file) } return nil, nil }, }
Functions ¶
func CountWords ¶
CountWords counts the number of words in the given text. It is an efficient version of len(SplitWords(text))
func FormatDirective ¶
FormatDirective formats a directive into a string
func ParseSpellComment ¶
ParseSpellComment parses text belonging to a spellchecker comment. It is expected to be of the form `keyword:directive args`. Each part may contain spaces at the edges and is matched under case folding.
func SplitWords ¶
SplitWords splits text into words.
A word is a sequence of runes within the text. Each word may consist of upper and lowercase letters.
Uppercase letters may only appear contiguously at the beginning of the word. "HELLOworld" is one word, whereas "HelloWorld" is two words "Hello" and "World".
To count the number of words in text, use CountWords instead.
Types ¶
type CommentText ¶
CommentText represents the text belonging to a parsed spellchecker directive. A comment looks like:
keyword:directive Value
A keyword must be one of 'spellchecker', 'cSpell' or 'spell-checker'. Keywords and directives are parsed under case-folding.
func (CommentText) IsDirective ¶
func (ct CommentText) IsDirective(directive string) bool
IsDirective checks if this CommentText represents the given directive. Directives are compared under case folding.
func (CommentText) Normalize ¶
func (ct CommentText) Normalize() CommentText
CommentText returns a normalized copy of comment.
The picks the default keyword, and lowercases the directive.
func (*CommentText) Parse ¶
func (ct *CommentText) Parse(text string) bool
Parse parses the given text into a comment. If the comment does not represent a text, returns false.
func (CommentText) String ¶
func (ct CommentText) String() string
String formats the contents of this CommentText, that is it brings it back into the form:
Keyword:Directive Value
func (CommentText) Text ¶
func (ct CommentText) Text() string
Text is like string, but includes the comment character ("//").