bavard

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: Apache-2.0 Imports: 12 Imported by: 10

README

bavard

Internal package with some code-generation helper (txt/template and asm).

Used by:

Documentation

Overview

Package bavard contains helper functions to generate consistent code from text/template templates it is used by github.com/consensys/gurvy && github.com/consensys/gnark && github.com/consensys/goff

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apache2

func Apache2(copyrightHolder string, year int) func(*Bavard) error

Apache2 returns a bavard option to be used in Generate writing an apache2 licence header in the generated file

func Apache2Header added in v0.1.6

func Apache2Header(copyrightHolder string, year int) string

Apache2Header returns a Apache2 header string

func BuildTag added in v0.1.1

func BuildTag(buildTag string) func(*Bavard) error

BuildTag returns a bavard option to be used in Generate adding build tags string on top of the generated file

func Format

func Format(v bool) func(*Bavard) error

Format returns a bavard option to be used in Generate. If set to true, will run gofmt on generated file. Or simple tab alignment on .s files

func Funcs added in v0.1.1

func Funcs(funcs template.FuncMap) func(*Bavard) error

Funcs returns a bavard option to be used in Generate. See text/template FuncMap for more info

func Generate

func Generate(output string, templates []string, data interface{}, options ...func(*Bavard) error) error

Generate will concatenate templates and create output file from executing the resulting text/template see other package functions to add options (package name, licensing, build tags, ...)

func GenerateF added in v0.1.7

func GenerateF(output string, templateF []string, data interface{}, options ...func(*Bavard) error) error

GenerateF will concatenate templates and create output file from executing the resulting text/template see other package functions to add options (package name, licensing, build tags, ...)

func GeneratedBy

func GeneratedBy(label string) func(*Bavard) error

GeneratedBy returns a bavard option to be used in Generate writing a standard "Code generated by 'label' DO NOT EDIT"

func Import

func Import(v bool) func(*Bavard) error

Import returns a bavard option to be used in Generate. If set to true, will run goimports

func Package

func Package(name string, doc ...string) func(*Bavard) error

Package returns a bavard option adding package name and optional package documentation in the generated file

func Verbose

func Verbose(v bool) func(*Bavard) error

Verbose returns a bavard option to be used in Generate. If set to true, will print to stdout during code generation

Types

type BatchGenerator added in v0.1.7

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

BatchGenerator enables more efficient and clean multiple file generation

func NewBatchGenerator added in v0.1.7

func NewBatchGenerator(copyrightHolder, generatedBy string) *BatchGenerator

NewBatchGenerator returns a new BatchGenerator

func (*BatchGenerator) Generate added in v0.1.7

func (b *BatchGenerator) Generate(entries ...Entry) error

Generate an entry with generator default config

func (*BatchGenerator) GenerateF added in v0.1.7

func (b *BatchGenerator) GenerateF(data interface{}, packageName string, baseTmplDir string, entries ...EntryF) error

GenerateF an entry with generator default config

type Bavard

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

Bavard root object to configure the code generation from text/template

type Entry added in v0.1.7

type Entry struct {
	File        string
	Templates   []string
	BuildTag    string
	PackageName string
	PackageDoc  string
	Data        interface{}
}

Entry to be used in batch generation of files

type EntryF added in v0.1.7

type EntryF struct {
	File       string
	TemplateF  []string
	BuildTag   string
	PackageDoc string
}

EntryF to be used in batch generation of files

Directories

Path Synopsis
Package amd64 contains wrapper to amd64 instructions in Go assembly.
Package amd64 contains wrapper to amd64 instructions in Go assembly.

Jump to

Keyboard shortcuts

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