tygo

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Packages []*PackageConfig `yaml:"packages"`
}

func (Config) PackageConfig

func (c Config) PackageConfig(packagePath string) *PackageConfig

func (Config) PackageNames

func (c Config) PackageNames() []string

type PackageConfig

type PackageConfig struct {
	// The package path just like you would import it in Go
	Path string `yaml:"path"`

	// Where this output should be written to.
	// If you specify a folder it will be written to a file `index.ts` within that folder. By default it is written into the Golang package folder.
	OutputPath string `yaml:"output_path"`

	// Customize the indentation (use \t if you want tabs)
	Indent string `yaml:"indent"`

	// Specify your own custom type translations, useful for custom types, `time.Time` and `null.String`.
	// Be default unrecognized types will be output as `any /* name */`.
	TypeMappings map[string]string `yaml:"type_mappings"`

	// This content will be put at the top of the output Typescript file.
	// You would generally use this to import custom types.
	Frontmatter string `yaml:"frontmatter"`

	// Filenames of Go source files that should not be included in the Typescript output.
	ExcludeFiles []string `yaml:"exclude_files"`

	// Filenames of Go source files that should be included in the Typescript output.
	IncludeFiles []string `yaml:"include_files"`

	// FallbackType defines the Typescript type used as a fallback for unknown Go types.
	FallbackType string `yaml:"fallback_type"`

	// IncludeStructNames
	IncludeStructComment string `yaml:"include_struct_comment"`
}

func (PackageConfig) IsFileIgnored

func (c PackageConfig) IsFileIgnored(pathToFile string) bool

func (PackageConfig) ResolvedOutputPath

func (c PackageConfig) ResolvedOutputPath(packageDir string) string

type PackageGenerator

type PackageGenerator struct {
	GoFiles []string
	// contains filtered or unexported fields
}

Responsible for generating the code for an input package

func (*PackageGenerator) Generate

func (g *PackageGenerator) Generate() (string, error)

type Tygo

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

Generator for one or more input packages, responsible for linking them together if necessary.

func New

func New(config *Config) *Tygo

func (*Tygo) Generate

func (g *Tygo) Generate() error

func (*Tygo) SetTypeMapping

func (g *Tygo) SetTypeMapping(goType string, tsType string)

Jump to

Keyboard shortcuts

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