typespecgo

package
v0.0.0-...-f9b13d0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGoOption

func AddGoOption(f *ast.File, mapValue *orderedmap.OrderedMap) error

将 @azure-tool/typespec-go 的配置添加到 ast.File 中

func Go

func Go(dir string, args ...string) error

func GoFmt

func GoFmt(dir string, args ...string) error

func GoFumpt

func GoFumpt(dir string, args ...string) error

func MergeNode

func MergeNode(f *ast.File, path string, value ast.Node) error

func Node

func Node(f *ast.File, path string) (ast.Node, error)

通过路径获取节点

func SearchTSP

func SearchTSP(dir string) ([]string, error)

有tspconfig.yaml并且有readme.go.md的目录

func TSP

func TSP(dir string, args ...string) (string, error)

Types

type EmitOption

type EmitOption struct {
	ServiceDir       string `yaml:"service-dir"`
	PackageDir       string `yaml:"package-dir"`
	EmitterOutputDir string `yaml:"emitter-output-dir"`
}

type GoEmitterOptions

type GoEmitterOptions struct {
	AzcoreVersion           string `yaml:"azcore-version"`
	DisallowUnknownFields   bool   `yaml:"disallow-unknown-fields"`
	FilePrefix              string `yaml:"file-prefix"`
	GenerateFake            bool   `yaml:"generate-fakes"`
	InjectSpanc             bool   `yaml:"inject-spans"`
	Module                  string `yaml:"module"`
	ModuleVersion           string `yaml:"module-version"`
	RawJsonAsBytes          bool   `yaml:"rawjson-as-bytes"`
	SliceElementsByVal      bool   `yaml:"slice-elements-byval"`
	SingleClient            bool   `yaml:"single-client"`
	Stutter                 string `yaml:"stutter"`
	FixConstStuttering      bool   `yaml:"fix-const-stuttering"`
	RemoveUnreferencedTypes bool   `yaml:"remove-unreferenced-types"`
}

https://github.com/Azure/autorest.go/blob/main/packages/typespec-go/src/lib.ts#GoEmitterOptions

@azure-tools/typespec-go option

type GoOption

type GoOption struct {
	EmitOption

	GoEmitterOptions
}

type LinterConfig

type LinterConfig struct {
	Extends []RuleRef          `yaml:"extends,omitempty"`
	Enable  map[RuleRef]bool   `yaml:"enable,omitempty"`
	Disable map[RuleRef]string `yaml:"disable,omitempty"`
}

<library name>:<rule/ruleset name>

type NodeX

type NodeX struct {
	// tspconfit.yaml path
	Path string

	// tspconfig.yaml node
	File *ast.File
}

func NewNodeX

func NewNodeX(path string) (*NodeX, error)

type RuleRef

type RuleRef string

func (RuleRef) Validate

func (r RuleRef) Validate() bool

type TSPConfig

type TSPConfig struct {
	Path string

	TypeSpecProjectSchema
}

func NewTSPConfig

func NewTSPConfig(tspconfigYaml string) (*TSPConfig, error)

func (*TSPConfig) EditEmit

func (tc *TSPConfig) EditEmit(emits []string)

func (*TSPConfig) EditOptions

func (tc *TSPConfig) EditOptions(emit string, option any, append bool)

func (*TSPConfig) EmitOption

func (tc *TSPConfig) EmitOption(emit string) (any, error)

func (TSPConfig) ExistEmitOption

func (tc TSPConfig) ExistEmitOption(emit string) bool

func (*TSPConfig) OnlyEmit

func (tc *TSPConfig) OnlyEmit(emit string)

func (*TSPConfig) Write

func (tc *TSPConfig) Write() error

type TSPConfigX

type TSPConfigX struct {
	TSPConfig
	// contains filtered or unexported fields
}

func (*TSPConfigX) Marshal

func (t *TSPConfigX) Marshal() ([]byte, error)

func (*TSPConfigX) Unmarshal

func (t *TSPConfigX) Unmarshal(data []byte) error

type TypeSpecAzureTools

type TypeSpecAzureTools string
const (
	TypeSpec_GO       TypeSpecAzureTools = "@azure-tools/typespec-go"
	TypeSpec_AUTOREST TypeSpecAzureTools = "@azure-tools/typespec-autorest"
	TypeSpec_CSHARP   TypeSpecAzureTools = "@azure-tools/typespec-csharp"
	TypeSpec_PYTHON   TypeSpecAzureTools = "@azure-tools/typespec-python"
	TypeSpec_TS       TypeSpecAzureTools = "@azure-tools/typespec-ts"
)

type TypeSpecProjectSchema

type TypeSpecProjectSchema struct {
	Extends              string         `yaml:"extends,omitempty"`
	Parameters           map[string]any `yaml:"parameters,omitempty"`
	EnvironmentVariables map[string]any `yaml:"environment-variables,omitempty"`
	WarnAsError          bool           `yaml:"warn-as-error,omitempty"`
	OutPutDir            string         `yaml:"output-dir,omitempty"` // 不应该是bool
	Trace                []string       `yaml:"trace,omitempty"`
	Imports              string         `yaml:"imports,omitempty"`
	Emit                 []string       `yaml:"emit,omitempty"`
	Options              map[string]any `yaml:"options,omitempty"`
	Linter               LinterConfig   `yaml:"linter,omitempty"`
}

https://typespec.io/docs/handbook/configuration#schema

Jump to

Keyboard shortcuts

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