basic

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 9 Imported by: 11

README

Basic Formatter

The basic formatter is a barebones formatter that simply takes the data provided, serializes it with gopkg.in/yaml.v3 and encodes it again. This provides a consistent output format that is very opinionated and cannot be configured.

Configuration

Key Type Default Description
indent int 2 The indentation level in spaces to use for the formatted yaml
include_document_start bool false Include --- at document start
line_ending lf or crlf crlf on Windows, lf otherwise Parse and write the file with "lf" or "crlf" line endings. This setting will be overwritten by the global line_ending.
emoji_support bool false Support encoding utf-8 emojis
retain_line_breaks bool false Retain line breaks in formatted yaml

Documentation

Index

Constants

View Source
const BasicFormatterType string = "basic"

Variables

This section is empty.

Functions

func ConfigureFeaturesFromConfig added in v0.4.0

func ConfigureFeaturesFromConfig(config *Config) yamlfmt.FeatureList

Types

type BasicFormatter

type BasicFormatter struct {
	Config   *Config
	Features yamlfmt.FeatureList
}

func (*BasicFormatter) Format

func (f *BasicFormatter) Format(input []byte) ([]byte, error)

func (*BasicFormatter) Type

func (f *BasicFormatter) Type() string

type BasicFormatterError added in v0.5.0

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

func (BasicFormatterError) Error added in v0.5.0

func (e BasicFormatterError) Error() string

func (BasicFormatterError) Unwrap added in v0.5.0

func (e BasicFormatterError) Unwrap() error

type BasicFormatterFactory

type BasicFormatterFactory struct{}

func (*BasicFormatterFactory) NewFormatter added in v0.5.0

func (f *BasicFormatterFactory) NewFormatter(configData map[string]interface{}) (yamlfmt.Formatter, error)

func (*BasicFormatterFactory) Type

func (f *BasicFormatterFactory) Type() string

type Config

type Config struct {
	Indent               int                    `mapstructure:"indent"`
	IncludeDocumentStart bool                   `mapstructure:"include_document_start"`
	EmojiSupport         bool                   `mapstructure:"emoji_support"`
	LineEnding           yamlfmt.LineBreakStyle `mapstructure:"line_ending"`
	RetainLineBreaks     bool                   `mapstructure:"retain_line_breaks"`
}

func DefaultConfig

func DefaultConfig() *Config

Jump to

Keyboard shortcuts

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