tygo

package
v0.2.14 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 13 Imported by: 5

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"`

	// Flavor defines what the key names of the output types will look like.
	// Supported values: "default", "" (same as "default"), "yaml".
	// In "default" mode, `json` and `yaml` tags are respected, but otherwise keys are unchanged.
	// In "yaml" mode, keys are lowercased to emulate gopkg.in/yaml.v2.
	Flavor string `yaml:"flavor"`

	// PreserveComments is an option to preserve comments in the generated TypeScript output.
	// Supported values: "default", "" (same as "default"), "types", "none".
	// By "default", package-level comments as well as type comments are
	// preserved.
	// In "types" mode, only type comments are preserved.
	// If "none" is supplied, no comments are preserved.
	PreserveComments string `yaml:"preserve_comments"`
}

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)

func (*PackageGenerator) PreserveDocComments added in v0.2.6

func (g *PackageGenerator) PreserveDocComments() bool

func (*PackageGenerator) PreserveTypeComments added in v0.2.6

func (g *PackageGenerator) PreserveTypeComments() bool

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