config

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveConfig

func SaveConfig(persister Store, config *Config) error

SaveConfig saves the configuration to the persister

Types

type BoolVariable

type BoolVariable struct {
	Value bool
}

BoolVariable represents a boolean variable

func (BoolVariable) Get

func (v BoolVariable) Get(path string) (Variable, bool)

func (BoolVariable) Keys

func (v BoolVariable) Keys() []string

func (BoolVariable) Len

func (v BoolVariable) Len() int

func (BoolVariable) MarshalJSON

func (v BoolVariable) MarshalJSON() ([]byte, error)

func (*BoolVariable) Set

func (v *BoolVariable) Set(path string, value Variable) error

func (BoolVariable) String

func (v BoolVariable) String() string

func (BoolVariable) Type

func (v BoolVariable) Type() VariableType

func (*BoolVariable) UnmarshalJSON

func (v *BoolVariable) UnmarshalJSON(data []byte) error

type Config

type Config struct {
	Template   Template   `yaml:"template" json:"template" default:""`
	Output     Output     `yaml:"output" json:"output" default:""`
	Variables  Variables  `yaml:"variables" json:"variables" default:"{}"`
	Engine     Engine     `yaml:"engine" json:"engine" default:"pdflatex"`
	Conversion Conversion `yaml:"conversion" json:"conversion"`
	Passes     int        `yaml:"passes" json:"passes" default:"1"`
	UseLatexmk bool       `yaml:"use_latexmk" json:"use_latexmk" default:"false"`
}

Config defines the YAML configuration schema for AutoPDF

func GetConfig

func GetConfig(persister Store) (*Config, error)

func GetDefaultConfig

func GetDefaultConfig() *Config

GetDefaultConfig returns a default configuration

func NewConfigFromYAML

func NewConfigFromYAML(yamlData []byte) (*Config, error)

NewConfigFromYAML creates a new Config from YAML data

func (*Config) Marshal

func (c *Config) Marshal() ([]byte, error)

func (*Config) String

func (c *Config) String() string

func (*Config) ToJSON

func (c *Config) ToJSON() (string, error)

ToJSON converts a Config to JSON string representation

func (*Config) Unmarshal

func (c *Config) Unmarshal(data []byte) error

type Conversion

type Conversion struct {
	Enabled bool     `yaml:"enabled" json:"enabled" default:"false"`
	Formats []string `yaml:"formats" json:"formats" default:"[]"`
}

type Engine

type Engine string

func (Engine) String

func (e Engine) String() string

type MapVariable

type MapVariable struct {
	Values map[string]Variable
}

MapVariable represents a map of nested variables

func NewMapVariable

func NewMapVariable() *MapVariable

func (MapVariable) Get

func (v MapVariable) Get(path string) (Variable, bool)

func (MapVariable) Keys

func (v MapVariable) Keys() []string

func (MapVariable) Len

func (v MapVariable) Len() int

func (MapVariable) MarshalJSON

func (v MapVariable) MarshalJSON() ([]byte, error)

func (*MapVariable) Set

func (v *MapVariable) Set(path string, value Variable) error

func (MapVariable) String

func (v MapVariable) String() string

func (MapVariable) Type

func (v MapVariable) Type() VariableType

func (*MapVariable) UnmarshalJSON

func (v *MapVariable) UnmarshalJSON(data []byte) error

type NumberVariable

type NumberVariable struct {
	Value float64
}

NumberVariable represents a numeric variable

func (NumberVariable) Get

func (v NumberVariable) Get(path string) (Variable, bool)

func (NumberVariable) Keys

func (v NumberVariable) Keys() []string

func (NumberVariable) Len

func (v NumberVariable) Len() int

func (NumberVariable) MarshalJSON

func (v NumberVariable) MarshalJSON() ([]byte, error)

func (*NumberVariable) Set

func (v *NumberVariable) Set(path string, value Variable) error

func (NumberVariable) String

func (v NumberVariable) String() string

func (NumberVariable) Type

func (v NumberVariable) Type() VariableType

func (*NumberVariable) UnmarshalJSON

func (v *NumberVariable) UnmarshalJSON(data []byte) error

type Output

type Output string

func (Output) String

func (o Output) String() string

type SliceVariable

type SliceVariable struct {
	Values []Variable
}

SliceVariable represents a slice of variables

func NewSliceVariable

func NewSliceVariable() *SliceVariable

func (SliceVariable) Get

func (v SliceVariable) Get(path string) (Variable, bool)

func (SliceVariable) Keys

func (v SliceVariable) Keys() []string

func (SliceVariable) Len

func (v SliceVariable) Len() int

func (SliceVariable) MarshalJSON

func (v SliceVariable) MarshalJSON() ([]byte, error)

func (*SliceVariable) Set

func (v *SliceVariable) Set(path string, value Variable) error

func (SliceVariable) String

func (v SliceVariable) String() string

func (SliceVariable) Type

func (v SliceVariable) Type() VariableType

func (*SliceVariable) UnmarshalJSON

func (v *SliceVariable) UnmarshalJSON(data []byte) error

type Store

type Store interface {
	Get(key string) string
	Set(key, value string)
}

GetConfig retrieves the configuration from the persister Store is the persistence capability required by configuration serialization.

type StringVariable

type StringVariable struct {
	Value string
}

StringVariable represents a simple string variable

func (StringVariable) Get

func (v StringVariable) Get(path string) (Variable, bool)

func (StringVariable) Keys

func (v StringVariable) Keys() []string

func (StringVariable) Len

func (v StringVariable) Len() int

func (StringVariable) MarshalJSON

func (v StringVariable) MarshalJSON() ([]byte, error)

func (*StringVariable) Set

func (v *StringVariable) Set(path string, value Variable) error

func (StringVariable) String

func (v StringVariable) String() string

func (StringVariable) Type

func (v StringVariable) Type() VariableType

func (*StringVariable) UnmarshalJSON

func (v *StringVariable) UnmarshalJSON(data []byte) error

type Template

type Template string

func (Template) String

func (t Template) String() string

type Variable

type Variable interface {
	// String returns the string representation for template substitution
	String() string
	// Get retrieves a nested value by path (e.g., "foo.bar[0]")
	Get(path string) (Variable, bool)
	// Set sets a nested value by path
	Set(path string, value Variable) error
	// Keys returns the keys for map-like variables
	Keys() []string
	// Len returns the length for slice-like variables
	Len() int
	// Type returns the variable type
	Type() VariableType
	// MarshalJSON implements json.Marshaler
	MarshalJSON() ([]byte, error)
	// UnmarshalJSON implements json.Unmarshaler
	UnmarshalJSON(data []byte) error
}

Variable represents a complex variable that can be: - A simple string value - A map of nested variables - A slice of values - Any combination of the above

type VariableSet

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

VariableSet represents a collection of variables with complex operations

func NewVariableSet

func NewVariableSet() *VariableSet

func (*VariableSet) Flatten

func (vs *VariableSet) Flatten() map[string]string

FlattenVariables flattens nested variables into dot-notation paths

func (*VariableSet) Get

func (vs *VariableSet) Get(name string) (Variable, bool)

func (*VariableSet) GetByPath

func (vs *VariableSet) GetByPath(path string) (Variable, bool)

func (*VariableSet) GetString

func (vs *VariableSet) GetString(name string) (string, bool)

func (*VariableSet) GetVariables

func (vs *VariableSet) GetVariables() map[string]Variable

GetVariables returns a copy of the variables map for template processing

func (*VariableSet) Keys

func (vs *VariableSet) Keys() []string

func (*VariableSet) Len

func (vs *VariableSet) Len() int

func (*VariableSet) MarshalJSON

func (vs *VariableSet) MarshalJSON() ([]byte, error)

func (*VariableSet) Range

func (vs *VariableSet) Range(fn func(name string, value Variable) bool)

RangeVariables provides iteration over variables

func (*VariableSet) Set

func (vs *VariableSet) Set(name string, value Variable)

func (*VariableSet) SetByPath

func (vs *VariableSet) SetByPath(path string, value Variable) error

func (*VariableSet) UnmarshalJSON

func (vs *VariableSet) UnmarshalJSON(data []byte) error

type VariableType

type VariableType int

VariableType represents the type of a variable

const (
	VariableTypeString VariableType = iota
	VariableTypeMap
	VariableTypeSlice
	VariableTypeNumber
	VariableTypeBool
)

type Variables

type Variables struct {
	*VariableSet
}

Variables represents a collection of complex variables

func NewVariables

func NewVariables() *Variables

NewVariables creates a new Variables collection

func (Variables) GetString

func (v Variables) GetString(path string) (string, bool)

GetString gets a string value by path (for backward compatibility)

func (Variables) MarshalJSON

func (v Variables) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (Variables) MarshalYAML

func (v Variables) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler

func (*Variables) SetString

func (v *Variables) SetString(path string, value string) error

SetString sets a string value by path (for backward compatibility)

func (Variables) String

func (v Variables) String() string

String returns the string representation

func (*Variables) UnmarshalJSON

func (v *Variables) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

func (*Variables) UnmarshalYAML

func (v *Variables) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler

Jump to

Keyboard shortcuts

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