common

package
v0.0.0-...-bcdf8a7 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package common provides common operation helpers to the generators

Index

Constants

This section is empty.

Variables

View Source
var TemplateFuncs = template.FuncMap{
	"Pointerize":              stringext.Pointerize,
	"ToLower":                 strings.ToLower,
	"ToUpper":                 strings.ToUpper,
	"Join":                    strings.Join,
	"ToLowerFirst":            stringext.ToLowerFirst,
	"ToUpperFirst":            stringext.ToUpperFirst,
	"AsComment":               stringext.AsComment,
	"DepunctWithInitialUpper": stringext.DepunctWithInitialUpper,
	"DepunctWithInitialLower": stringext.DepunctWithInitialLower,
	"Equal":                   stringext.Equal,
	"ToFieldName":             stringext.ToFieldName,
	"Argumentize":             schema.Argumentize,
	"SortedObjectSchemas":     SortedObjectSchemas,
	"SortedSchema":            schema.SortedSchema,
}

TemplateFuncs provides utility functions for template operations

Functions

func IsIn

func IsIn(s string, ts ...string) bool

IsIn checks if the first param is in the following ones

func Read

func Read(path string) (*schema.Schema, error)

NewFromFile reads the given file and creates a new module out of it

func SortedObjectSchemas

func SortedObjectSchemas(m map[string]*schema.Schema) []*schema.Schema

func TestEquals

func TestEquals(tb testing.TB, exp, act interface{})

func WriteOutput

func WriteOutput(output []Output) error

WriteOutput writes output slice

Types

type Context

type Context struct {
	Config *config.Config

	// Funcs
	ModuleNameFunc func(string) string
	FileNameFunc   func(string) string
	FieldNameFunc  func(string) string

	// TemplateFuncs
	TemplateFuncs template.FuncMap
}

func NewContext

func NewContext() *Context

type Generator

type Generator interface {
	Generate(*Context, *schema.Schema) ([]Output, error)
}

type Output

type Output struct {
	Content     []byte
	Path        string
	DoNotFormat bool
}

Jump to

Keyboard shortcuts

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