Documentation ¶
Overview ¶
Package common provides common operation helpers to the generators
Index ¶
- Variables
- func IsIn(s string, ts ...string) bool
- func Proces(o *Op, req *Req, res *Res) error
- func ProcesRoot(o *Op, req *Req, res *Res) error
- func ProcessSingle(o *Op, def *schema.Schema, settings schema.Generator) ([]byte, error)
- func Read(path string) (*schema.Schema, error)
- func ReadJSON(path string) (string, error)
- func RunTest(t *testing.T, g Generator, testData string, expecteds []string)
- func SortedObjectSchemas(m map[string]*schema.Schema) []*schema.Schema
- func TestEquals(tb testing.TB, exp, act interface{})
- func WriteOutput(output []Output) error
- type Context
- type Generator
- type GeneratorPlugin
- type GeneratorRPCClient
- type GeneratorRPCServer
- type Op
- type Output
- type PluginStore
- type PostProcessor
- type Req
- type Res
- type TemplateData
Constants ¶
This section is empty.
Variables ¶
var HandshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "GENE_PLUGIN",
MagicCookieValue: "gene-cookie",
}
HandshakeConfig is the contract between rpc plugin clients and servers.
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 ProcessSingle ¶
ProcessSingle generates output for only one level of a schema
func SortedObjectSchemas ¶
SortedObjectSchemas filters object schemas and sorts them
func TestEquals ¶
TestEquals checks if the exp and act is deeply equal
Types ¶
type GeneratorPlugin ¶
type GeneratorPlugin struct {
// contains filtered or unexported fields
}
GeneratorPlugin provides basic plugin system
func NewGeneratorPlugin ¶
func NewGeneratorPlugin(g Generator) *GeneratorPlugin
NewGeneratorPlugin creates a new plugin out of given Generator
func (*GeneratorPlugin) Client ¶
func (g *GeneratorPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
Client provides client functionality for plugins
func (*GeneratorPlugin) Server ¶
func (g *GeneratorPlugin) Server(*plugin.MuxBroker) (interface{}, error)
Server provides server functionality for plugins
type GeneratorRPCClient ¶
GeneratorRPCClient provides rpc client functionality.
type GeneratorRPCServer ¶
type GeneratorRPCServer struct{ Impl Generator }
GeneratorRPCServer provides rpc server functionality.
type Op ¶
type Op struct { Name string Template string PathFunc func(data *TemplateData) string Clear bool DoNotFormat bool FormatSource bool RemoveNewLines bool PostProcessors []PostProcessor // contains filtered or unexported fields }
Op holds the operation information for processing.
type PluginStore ¶
PluginStore holds plugin names and their clients
func Discover ¶
func Discover(prefix string) (*PluginStore, error)
Discover searches for plugins located nearby with this binary and in PATH, matching given prefix name
func (*PluginStore) Shutdown ¶
func (g *PluginStore) Shutdown() error
type PostProcessor ¶
PostProcessor holds to be applied operations after generation is done.