render

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Newline = "\n"

Variables

This section is empty.

Functions

This section is empty.

Types

type Colorized

type Colorized struct{}

func (Colorized) Assignment

func (c Colorized) Assignment(a *ast.Assignment, settings Settings) string

func (Colorized) Comment

func (r Colorized) Comment(comment *ast.Comment, settings Settings, isAssignmentComment bool) string

func (Colorized) Group

func (c Colorized) Group(group *ast.Group, settings Settings) string

func (Colorized) Newline

func (r Colorized) Newline(newline *ast.Newline, settings Settings) string

type Handler

type Handler func(in *HandlerInput) Signal

type HandlerInput

type HandlerInput struct {
	Presenter *Renderer
	Previous  ast.Statement
	Settings  Settings
	Statement any
	Value     string
}

func (*HandlerInput) Continue

func (si *HandlerInput) Continue() Signal

func (*HandlerInput) Return

func (si *HandlerInput) Return(val string) Signal

func (*HandlerInput) Stop

func (si *HandlerInput) Stop() Signal

type LineBuffer

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

func (*LineBuffer) Add

func (lb *LineBuffer) Add(str string) *LineBuffer

func (*LineBuffer) AddPrinted

func (lb *LineBuffer) AddPrinted(str string) bool

func (*LineBuffer) EnsureEOF

func (lb *LineBuffer) EnsureEOF() *LineBuffer

func (*LineBuffer) Get

func (lb *LineBuffer) Get() string

func (*LineBuffer) GetWithEOF

func (lb *LineBuffer) GetWithEOF() string

func (*LineBuffer) Newline

func (lb *LineBuffer) Newline() *LineBuffer

type Outputter

type Outputter interface {
	Group(*ast.Group, Settings) string
	Assignment(*ast.Assignment, Settings) string
	Comment(*ast.Comment, Settings, bool) string
	Newline(*ast.Newline, Settings) string
}

type Plain

type Plain struct{}

func (Plain) Assignment

func (c Plain) Assignment(a *ast.Assignment, settings Settings) string

func (Plain) Comment

func (r Plain) Comment(comment *ast.Comment, settings Settings, isAssignmentComment bool) string

func (Plain) Group

func (c Plain) Group(group *ast.Group, settings Settings) string

func (Plain) Newline

func (r Plain) Newline(newline *ast.Newline, settings Settings) string

type Renderer

type Renderer struct {
	Output   Outputter
	Previous ast.Statement
	Settings Settings
	// contains filtered or unexported fields
}

func NewFormatter

func NewFormatter() *Renderer

func NewRenderer

func NewRenderer(settings Settings, handlers ...Handler) *Renderer

func (*Renderer) Assignment

func (r *Renderer) Assignment(a *ast.Assignment) string

func (*Renderer) Comment

func (r *Renderer) Comment(comment *ast.Comment, isAssignmentComment bool) string

func (*Renderer) Document

func (r *Renderer) Document(doc *ast.Document) string

func (*Renderer) Group

func (r *Renderer) Group(group *ast.Group) string

func (*Renderer) Newline

func (r *Renderer) Newline(newline *ast.Newline) string

func (*Renderer) SetOutput

func (r *Renderer) SetOutput(output Outputter)

func (*Renderer) Statement

func (r *Renderer) Statement(stmt any) string

type Settings

type Settings struct {
	FilterKeyPrefix  string
	FilterGroup      string
	IncludeCommented bool

	ShowBlankLines bool
	ShowColors     bool
	ShowComments   bool
	ShowGroups     bool
	ShowPretty     bool

	Interpolate bool
}

func (*Settings) Match

func (rs *Settings) Match(assignment *ast.Assignment) bool

func (*Settings) WithBlankLines

func (rs *Settings) WithBlankLines() bool

func (*Settings) WithColors

func (rs *Settings) WithColors() bool

func (*Settings) WithComments

func (rs *Settings) WithComments() bool

func (*Settings) WithGroups

func (rs *Settings) WithGroups() bool

type Signal

type Signal uint
const (
	Continue Signal = iota
	Stop
	Return
)

func Format

func Format(in *HandlerInput) Signal

func (Signal) String

func (ss Signal) String() string

String returns the string corresponding to the token.

Jump to

Keyboard shortcuts

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