compact

package
v0.24.8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Comment  = "--"
	File     = "src"
	Position = "pos"
)

Common markup keys in tapestry compact (if) files. the comment marker was chosen to be distinctive and to sort in front of all other keys (ie. when using go's json encoder. )

Variables

This section is empty.

Functions

func ExtractComment added in v0.24.6

func ExtractComment(markup map[string]any) (ret []string, err error)

extract a comment string or strings from the passed msg markup. returns nil if no comment existed. errors if some data existed that couldn't be interpreted.

func IsMarkup added in v0.24.8

func IsMarkup(s string) (okay bool)

func IsUnhandled

func IsUnhandled(e error) bool

func JoinComment added in v0.24.8

func JoinComment(markup map[string]any) (ret string)

ignores errors and returns a blank string

func JoinLines

func JoinLines(slice []any) (ret string, okay bool)

type conversion: convert a slice of interfaces to a slice of strings joined with newlines.

func MakeSourceError added in v0.24.8

func MakeSourceError(src Source, e error) (err error)

func MessageError added in v0.24.8

func MessageError(msg Message, e error) error

func SliceBools

func SliceBools(slice []any) ([]bool, bool)

type conversion: convert a slice containing bool values into a bool slice. returns false if any member of the slice isnt a bool

func SliceFloats

func SliceFloats(slice []any) ([]float64, bool)

type conversion: convert a slice containing float values into a float slice. returns false if any member of the slice isnt a float64

func SliceStrings

func SliceStrings(slice []any) ([]string, bool)

type conversion: convert a slice containing string values into a string slice. returns false if any member of the slice isnt a string

func UserComment

func UserComment(markup map[string]any) (ret []string)

read a user comment from markup, normalizing it as an array of strings

Types

type Message

type Message struct {
	Key    string         // original specified text: "Sig:label:"
	Lede   string         // the leading part of the signature in lowercase
	Labels []string       // parameter names sans colons; the first can be blank ( anonymous )
	Args   []any          // the same length as labels
	Markup map[string]any // from lowercase keys and comments
}

A decoding of a tapestry command. Commands on disk are stored as plain value maps containing a command signature and command data pair; and any number of markup key-value pairs. Signatures start with a capital letter, and contain parameter names separated by colons. Markup keys start with a double dash.

func (*Message) AddMarkup

func (op *Message) AddMarkup(k string, v any)

panics if the value is a type gob encoding cant handle

func (*Message) Source added in v0.24.8

func (op *Message) Source() Source

attempts to read a source position from the markup data.

type Source added in v0.24.8

type Source struct {
	File    string // enough to locate the data
	Line    int    // a zero-offset printed as one-offset.
	Comment string
}

the compact format stores source file info inside the metadata.

func MakeSource added in v0.24.8

func MakeSource(m map[string]any) Source

func (Source) CompactPos added in v0.24.8

func (p Source) CompactPos() (ret string)

return the source position as line:base(path)

func (Source) ErrorString added in v0.24.8

func (p Source) ErrorString() (ret string)

type SourceError added in v0.24.8

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

func (SourceError) Error added in v0.24.8

func (e SourceError) Error() (ret string)

func (SourceError) Source added in v0.24.8

func (e SourceError) Source() Source

func (SourceError) Unwrap added in v0.24.8

func (e SourceError) Unwrap() error

type Unhandled

type Unhandled string

func (Unhandled) Error

func (u Unhandled) Error() string

Jump to

Keyboard shortcuts

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