common

package
v0.0.0-...-3ae477e Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratedCommentHeader

func GeneratedCommentHeader(config Config) codejen.FileMapper

GeneratedCommentHeader produces a FileMapper that injects a comment header onto a codejen.File indicating the jenny or jennies that constructed the file.

func If

func If[Input any](condition bool, innerJenny codejen.OneToMany[Input]) codejen.OneToMany[Input]

func NoopImportSanitizer

func NoopImportSanitizer(s string) string

func PathPrefixer

func PathPrefixer(prefix string) codejen.FileMapper

PathPrefixer returns a FileMapper that injects the provided path prefix to files passed through it.

Types

type BuildOptions

type BuildOptions struct {
	Languages []string
}

type Config

type Config struct {
	// Debug turns on or off the debugging mode.
	Debug bool

	// Types indicates whether types should be generated or not.
	Types bool

	// Builders indicates whether builders should be generated or not.
	Builders bool
}

Config represents global configuration options, to be used by all jennies.

type Context

type Context struct {
	Schemas  ast.Schemas
	Builders ast.Builders
}

func (*Context) IsDisjunctionOfBuilders

func (context *Context) IsDisjunctionOfBuilders(def ast.Type) bool

func (*Context) LocateObject

func (context *Context) LocateObject(pkg string, name string) (ast.Object, bool)

func (*Context) ResolveToBuilder

func (context *Context) ResolveToBuilder(def ast.Type) bool

func (*Context) ResolveToComposableSlot

func (context *Context) ResolveToComposableSlot(def ast.Type) (ast.Type, bool)

func (*Context) ResolveToStruct

func (context *Context) ResolveToStruct(def ast.Type) bool

type DirectImportMap

type DirectImportMap struct {
	Imports *orderedmap.Map[string, string] // alias → importPath
	// contains filtered or unexported fields
}

func NewDirectImportMap

func NewDirectImportMap(opts ...ImportMapOption[DirectImportMap]) *DirectImportMap

func (DirectImportMap) Add

func (im DirectImportMap) Add(alias string, importPath string) string

func (DirectImportMap) IsIdentical

func (im DirectImportMap) IsIdentical(aliasA string, aliasB string) bool

func (DirectImportMap) String

func (im DirectImportMap) String() string

type ImportMapConfig

type ImportMapConfig[M any] struct {
	Formatter           func(importMap M) string
	AliasSanitizer      func(string) string
	ImportPathSanitizer func(string) string
}

type ImportMapOption

type ImportMapOption[M any] func(importMap *ImportMapConfig[M])

func WithAliasSanitizer

func WithAliasSanitizer[M any](sanitizer func(string) string) ImportMapOption[M]

func WithFormatter

func WithFormatter[M any](formatter func(M) string) ImportMapOption[M]

func WithImportPathSanitizer

func WithImportPathSanitizer[M any](sanitizer func(string) string) ImportMapOption[M]

type PackageTemplate

type PackageTemplate struct {
	Language    string
	TemplateDir string
	ExtraData   map[string]string
}

func (PackageTemplate) Generate

func (jenny PackageTemplate) Generate(context Context) (codejen.Files, error)

func (PackageTemplate) JennyName

func (jenny PackageTemplate) JennyName() string

type RepositoryTemplate

type RepositoryTemplate struct {
	TemplateDir string
	ExtraData   map[string]string
}

func (RepositoryTemplate) Generate

func (jenny RepositoryTemplate) Generate(buildOpts BuildOptions) (codejen.Files, error)

func (RepositoryTemplate) JennyName

func (jenny RepositoryTemplate) JennyName() string

Jump to

Keyboard shortcuts

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