core

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2017 License: MIT Imports: 19 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
	Description string // why `Message` is meaningful
	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 Conditional added in v0.3.0

type Conditional struct {
	Definition `mapstructure:",squash"`
	Ignorecase bool
	First      string
	Second     string
	Exceptions []string
}

Conditional ensures that the present of First ensures the present of Second.

type Consistency added in v0.3.0

type Consistency struct {
	Definition `mapstructure:",squash"`
	Nonword    bool
	Ignorecase bool
	Either     map[string]string
}

Consistency ensures that the keys and values of Either don't both exist.

type Definition added in v0.3.0

type Definition struct {
	Description string
	Extends     string
	Level       string
	Link        string
	Message     string
	Name        string
	Scope       string
}

Definition holds the common attributes of rule definitions.

type Existence added in v0.3.0

type Existence struct {
	Definition `mapstructure:",squash"`
	Ignorecase bool
	Nonword    bool
	Raw        []string
	Tokens     []string
}

Existence checks for the present of Tokens.

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, pat string) ([]File, error)

Lint src according to its format.

type Occurrence added in v0.3.0

type Occurrence struct {
	Definition `mapstructure:",squash"`
	Max        int
	Token      string
}

Occurrence counts the number of times Token appears.

type Repetition added in v0.3.0

type Repetition struct {
	Definition `mapstructure:",squash"`
	Max        int
	Ignorecase bool
	Tokens     []string
}

Repetition looks for repeated uses of Tokens.

type Script added in v0.3.0

type Script struct {
	Definition `mapstructure:",squash"`
	Exe        string
	Runtime    string
}

Script runs Exe with Runtime.

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"}.

type Substitution added in v0.3.0

type Substitution struct {
	Definition `mapstructure:",squash"`
	Ignorecase bool
	Nonword    bool
	Swap       map[string]string
}

Substitution switches the values of Swap for its keys.

Jump to

Keyboard shortcuts

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