generator

package
v0.0.0-...-00d32dd Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrNoConfig = fmt.Errorf("no config files")

ErrNoConfig is the error to be returned if there are no config files

Functions

This section is empty.

Types

type BasicGenerator

type BasicGenerator struct {
	SourceFolder     string
	I18NFolder       string
	ConfigFolder     string
	OutputFolder     string
	IgnorePattern    string
	ScannerFactory   func([]string) Scanner
	CollectorFactory func(string, string) Collector
	RendererFactory  func(string, *regexp.Regexp) Renderer
}

func (*BasicGenerator) Generate

func (g *BasicGenerator) Generate(isos string) error

type Collector

type Collector interface {
	Collect(string) (Data, error)
	AvailableISOs() []string
}

Collector defines the interface for collecting config and translation data

func NewCollector

func NewCollector(configFolder, i18nFolder string) Collector

type Data

type Data struct {
	I18N   map[string]Map
	Config map[string]Map
}

Data contains all the collected data

func (Data) String

func (d Data) String() string

type Dumper

type Dumper func(string, string, Data) error

type Generator

type Generator interface {
	Generate(isos string) error
}
Example
// log.SetOutput(ioutil.Discard)
if err := New(os.Getenv("PWD")+"/test", "ignore").Generate("*"); err != nil {
	fmt.Println("generation aborted:", err)
}
fmt.Println("ok")
Output:

ok

func New

func New(basePath, ignoreRegex string) Generator

type Map

type Map map[string]string

func (Map) String

func (d Map) String() string

type Render

type Render struct {
	OutputFolder string
	Regexp       *regexp.Regexp
	Dumper       Dumper
}

func (*Render) Render

func (r *Render) Render(iso string, data Data, scanner Scanner) error

type Renderer

type Renderer interface {
	Render(string, Data, Scanner) error
}

func NewRenderer

func NewRenderer(outputFolder string, r *regexp.Regexp) Renderer

type Scanner

type Scanner interface {
	Scan() []TmplFolder
}

func NewScanner

func NewScanner(ts []string) Scanner

type SimpleCollector

type SimpleCollector struct {
	ConfigFolder string
	I18NFolder   string
}

func (SimpleCollector) AvailableISOs

func (c SimpleCollector) AvailableISOs() []string

func (SimpleCollector) Collect

func (c SimpleCollector) Collect(iso string) (Data, error)

type TmplFolder

type TmplFolder struct {
	Path    string
	Content []string
}

type TmplScanner

type TmplScanner []string

func (TmplScanner) Scan

func (ts TmplScanner) Scan() []TmplFolder

Jump to

Keyboard shortcuts

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