common

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratedCommentHeader

func GeneratedCommentHeader(config languages.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, opts ...PathPrefixerOption) codejen.FileMapper

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

func TypeResolvingTemplateHelpers

func TypeResolvingTemplateHelpers(context languages.Context) template.FuncMap

Types

type APIReference

type APIReference struct {
	Collector *APIReferenceCollector
	Language  string
	Formatter APIReferenceFormatter
	Tmpl      *template.Template
}

func (APIReference) Generate

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

func (APIReference) JennyName

func (jenny APIReference) JennyName() string

type APIReferenceCollector

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

func NewAPIReferenceCollector

func NewAPIReferenceCollector() *APIReferenceCollector

func (*APIReferenceCollector) BuilderMethod

func (collector *APIReferenceCollector) BuilderMethod(builder ast.Builder, methodReference MethodReference)

func (*APIReferenceCollector) FunctionsForPackage

func (collector *APIReferenceCollector) FunctionsForPackage(pkg string) []FunctionReference

func (*APIReferenceCollector) MethodsForBuilder

func (collector *APIReferenceCollector) MethodsForBuilder(builder ast.Builder) []MethodReference

func (*APIReferenceCollector) MethodsForObject

func (collector *APIReferenceCollector) MethodsForObject(object ast.Object) []MethodReference

func (*APIReferenceCollector) ObjectMethod

func (collector *APIReferenceCollector) ObjectMethod(object ast.Object, methodReference MethodReference)

func (*APIReferenceCollector) RegisterFunction

func (collector *APIReferenceCollector) RegisterFunction(pkg string, functionReference FunctionReference)

type APIReferenceFormatter

type APIReferenceFormatter struct {
	KindName func(kind ast.Kind) string

	FunctionSignature func(context languages.Context, function FunctionReference) string

	ObjectName       func(object ast.Object) string
	ObjectDefinition func(context languages.Context, object ast.Object) string

	MethodName      func(method MethodReference) string
	MethodSignature func(context languages.Context, method MethodReference) string

	BuilderName          func(builder ast.Builder) string
	ConstructorSignature func(context languages.Context, builder ast.Builder) string
	OptionName           func(option ast.Option) string
	OptionSignature      func(context languages.Context, builder ast.Builder, option ast.Option) string
}

type ArgumentReference

type ArgumentReference struct {
	Name     string
	Type     string
	Comments []string
}

type BuildOptions

type BuildOptions struct {
	Languages []string
}

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 FunctionReference

type FunctionReference struct {
	Name      string
	Comments  []string
	Arguments []ArgumentReference
	Return    string
}

type ImportMapConfig

type ImportMapConfig[M any] struct {
	Formatter           func(importMap M) string
	AliasSanitizer      func(string) string
	ImportPathSanitizer func(string) string
	PackagesImportMap   map[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]

func WithPackagesImportMap added in v0.0.4

func WithPackagesImportMap[M any](packagesImportMap map[string]string) ImportMapOption[M]

type MethodReference

type MethodReference struct {
	ReceiverObject  *ast.Object
	ReceiverBuilder *ast.Builder

	Name      string
	Comments  []string
	Arguments []ArgumentReference
	Return    string
	Static    bool
}

type PackageTemplate

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

func (PackageTemplate) Generate

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

func (PackageTemplate) JennyName

func (jenny PackageTemplate) JennyName() string

type PathPrefixerOption

type PathPrefixerOption func(*pathPrefixerCfg)

func PrefixExcept

func PrefixExcept(pathPrefix ...string) PathPrefixerOption

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