formatter

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyEscapeRune = '#'
)

Variables

This section is empty.

Functions

func EscapeNonStringKeys

func EscapeNonStringKeys(l *lua.LState, value lua.LValue) lua.LValue

Since Lua allow non-string key within table, we need to escape them by prepending a key escape rune in order to cast as map[string]interface{}. Key escaoe rune '#' indicate the key which is orignal an number key, EscapeNonStringKeys escapes non-string keys of the table.

func Format

func Format(name string, value interface{}, opts ...Option) string

func UnescapeNonStringKeys

func UnescapeNonStringKeys(l *lua.LState, value lua.LValue) lua.LValue

UnescapeNonStringKeys unescapes non-string keys of the table.

Types

type KeySortType

type KeySortType int8
const (
	KeySortNone KeySortType = iota
	KeySortHashFnv64
	KeySortHashFnv64Reversed
	KeySortAlphabetical
	KeySortAlphabeticalReversed
)

type Option

type Option func(*options)

An Option is used to define the behavior and rules of a Format.

func IndentWidthStep

func IndentWidthStep(width int) Option

IndentWidthStep sets the width of the indentation for each step.

func KeySort

func KeySort(sort KeySortType) Option

KeySort sets the key sort type.

func KeySortPriority

func KeySortPriority(priority ...string) Option

KeySortPriority sets the key sort priority.

func MaxLineLength

func MaxLineLength(length int) Option

MaxLineLength sets the maximum length of a line.

func RootIndentWidth

func RootIndentWidth(width int) Option

RootIndentWidth sets the width of the indentation.

func RootTrait

func RootTrait(trait string) Option

Trait sets the trait of the root element.

Jump to

Keyboard shortcuts

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