lint

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllChecks = map[string]check{}

AllChecks holds all of our individual checks. The keys are in the form "styleName.checkName".

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Check    string // the name of the check
	Line     int    // the source line
	Link     string // reference material
	Message  string // the output message
	Severity string // 'suggestion', 'warning', or 'error'
	Span     []int  // the [begin, end] location within a line
}

An Alert represents a potential error in prose.

type Block

type Block struct {
	Context string   // parent content (if any) - e.g., paragraph -> sentence
	Text    string   // text content
	Scope   Selector // section selector
}

A Block represents a section of text.

func NewBlock

func NewBlock(ctx string, txt string, sel string) Block

NewBlock makes a new Block with prepared text and a Selector.

type ByPosition

type ByPosition []Alert

ByPosition sorts Alerts by line and column.

func (ByPosition) Len

func (a ByPosition) Len() int

func (ByPosition) Less

func (a ByPosition) Less(i, j int) bool

func (ByPosition) Swap

func (a ByPosition) Swap(i, j int)

type File

type File struct {
	Alerts     []Alert         // all alerts associated with this file
	BaseStyles []string        // base style assigned in .vale
	Checks     map[string]bool // syntax-specific checks assigned in .txtint
	Counts     map[string]int  // word counts
	Format     string          // 'code', 'markup' or 'prose'
	NormedExt  string          // the normalized extension (see util/format.go)
	Path       string          // the full path
	RealExt    string          // actual file extension
	Scanner    *bufio.Scanner  // used by lintXXX functions
	Sequences  []string        // tracks various info (e.g., defined abbreviations)
}

A File represents a linted text file.

func (*File) SortedAlerts

func (f *File) SortedAlerts() []Alert

SortedAlerts returns all of f's alerts sorted by line and column.

type Linter

type Linter struct{}

A Linter lints a File.

func (*Linter) Lint

func (l *Linter) Lint(src string) ([]File, error)

Lint src according to its format.

type Selector

type Selector struct {
	Value string // e.g., text.comment.line.py
}

A Selector represents a named section of text.

func (Selector) Contains

func (s Selector) Contains(sel Selector) bool

Contains determines if all if sel's sections are in s.

func (Selector) Equal

func (s Selector) Equal(sel Selector) bool

Equal determines if sel == s.

func (Selector) Has

func (s Selector) Has(scope string) bool

Has determines if s has a part equal to scope.

func (Selector) Sections

func (s Selector) Sections() []string

Sections splits a Selector into its parts -- e.g., text.comment.line.py -> []string{"text", "comment", "line", "py"}.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL