core

package
v0.0.0-...-8023e94 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2021 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllRuleNames

func AllRuleNames() []string

func HasRule

func HasRule(name string) bool

func ProcessSingleDoc

func ProcessSingleDoc(filename string, stream io.Reader, rule LintRuleOverTokens) error

ProcessSingleDoc processes a single document.

func RegisterLintRuleOverEvents

func RegisterLintRuleOverEvents(name string, instantiator func(Reporter) LintRuleOverEvents)

RegisterLintRuleOverEvents registers a lint rule over events. This meant to be called from an `init` block.

func RegisterLintRuleOverTokens

func RegisterLintRuleOverTokens(name string, instantiator func(Reporter) LintRuleOverTokens)

RegisterLintRuleOverTokens registers a lint rule over tokens. This meant to be called from an `init` block.

Types

type DefaultLintRuleOverEvents

type DefaultLintRuleOverEvents struct{}

The DefaultLintRuleOverEvents provides default implementation for the LintRuleOverEvents interface.

func (DefaultLintRuleOverEvents) OnDocEnd

func (DefaultLintRuleOverEvents) OnDocEnd()

func (DefaultLintRuleOverEvents) OnDocStart

func (DefaultLintRuleOverEvents) OnDocStart(doc *Doc)

func (DefaultLintRuleOverEvents) OnEnd

func (DefaultLintRuleOverEvents) OnEnd()

func (DefaultLintRuleOverEvents) OnLinkByURL

func (DefaultLintRuleOverEvents) OnLinkByURL(url Token)

func (DefaultLintRuleOverEvents) OnLinkByXref

func (DefaultLintRuleOverEvents) OnLinkByXref(xref Token)

func (DefaultLintRuleOverEvents) OnStart

func (DefaultLintRuleOverEvents) OnStart()

func (DefaultLintRuleOverEvents) OnTableOfContents

func (DefaultLintRuleOverEvents) OnTableOfContents(toc Token)

func (DefaultLintRuleOverEvents) OnXrefDefinition

func (DefaultLintRuleOverEvents) OnXrefDefinition(xref, url Token)

type DefaultLintRuleOverTokens

type DefaultLintRuleOverTokens struct{}

The DefaultLintRuleOverTokens provides default implementation for the LintRuleOverTokens interface.

func (DefaultLintRuleOverTokens) OnDocEnd

func (DefaultLintRuleOverTokens) OnDocEnd()

func (DefaultLintRuleOverTokens) OnDocStart

func (DefaultLintRuleOverTokens) OnDocStart(doc *Doc)

func (DefaultLintRuleOverTokens) OnEnd

func (DefaultLintRuleOverTokens) OnEnd()

func (DefaultLintRuleOverTokens) OnNext

func (DefaultLintRuleOverTokens) OnNext(tok Token)

func (DefaultLintRuleOverTokens) OnStart

func (DefaultLintRuleOverTokens) OnStart()

type Doc

type Doc struct {
	// contains filtered or unexported fields
}

A Doc represents a Markdown document.

TODO(fxbug.dev/62964): Avoid duplicating a document's content between the content in the token, and the content in the doc. To support reading the content of a token while a line is being read, we need to either lookup the content in the accumulated lines, or in the accumulated line buffer.

type LintRuleOverEvents

type LintRuleOverEvents interface {

	// OnLinkByXref is called when a link by label is read.
	OnLinkByXref(xref Token)

	// OnLinkByURL is called when a link by URL is read.
	OnLinkByURL(url Token)

	// OnXrefDefinition is called when a link label definition is read.
	OnXrefDefinition(xref, url Token)

	// OnTableOfContents is called when a table of contents is read.
	OnTableOfContents(toc Token)
	// contains filtered or unexported methods
}

LintRuleOverEvents defines how rules over events operate.

type LintRuleOverTokens

type LintRuleOverTokens interface {

	// OnNext is called for each token processed as part of reading a document.
	OnNext(tok Token)
	// contains filtered or unexported methods
}

LintRuleOverTokens defines how rules over tokens operate.

func InstantiateRules

func InstantiateRules(rootReporter *RootReporter, enabledRules []string) LintRuleOverTokens

InstantiateRules instantiates all `enabledRules`.

type Reporter

type Reporter interface {
	// Warnf formats and adds warning message using the format specifier.
	Warnf(tok Token, format string, a ...interface{})
}

A Reporter provides utilities to aggregate warning messages attached to specific tokens, and to pretty print these aggregates messages.

type RootReporter

type RootReporter struct {

	// JSONOutput enables JSON output, instead of the pretty printed human
	// readable output.
	JSONOutput bool
	// contains filtered or unexported fields
}

RootReporter is the linter wide reporter, and may be used to report general warnings. When reporting within rules, prefer creating rule reporters with:

rootReporter := ...
ruleReporter := rootReporter.ForRule("name-of-rule")

func (*RootReporter) ForRule

func (r *RootReporter) ForRule(rule string) Reporter

ForRule creates a reporter for a specific rule.

func (*RootReporter) HasMessages

func (r *RootReporter) HasMessages() bool

HasMessages indicates whether any message was added to this reporter.

func (*RootReporter) Print

func (r *RootReporter) Print(writer io.Writer) error

Print prints this report to the writer. For instance:

reporter.Print(os.Stderr)

func (*RootReporter) Warnf

func (r *RootReporter) Warnf(tok Token, format string, a ...interface{})

type Token

type Token struct {
	Doc     *Doc
	Kind    TokenKind
	Content string
	// contains filtered or unexported fields
}

func (Token) String

func (tok Token) String() string

type TokenKind

type TokenKind int
const (
	Anchor TokenKind
	Code
	EOF
	Header
	Link
	List
	Newline
	Space
	Text
	URL
)

func (TokenKind) String

func (kind TokenKind) String() string

Jump to

Keyboard shortcuts

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