Documentation
¶
Index ¶
- Constants
- func GetModuleName(file protoreflect.FileDescriptor) string
- func JSONCamelCase(s string) string
- type Definition
- type ProtobufESDefinition
- func (d ProtobufESDefinition) EnumToJson(enum *protogen.Enum) func(g *TSRegistry, in string) string
- func (d ProtobufESDefinition) FieldToJson(field *protogen.Field) func(g *TSRegistry, in string) string
- func (d ProtobufESDefinition) GetFieldSyntax(opt *TSOption, rootMsg *protogen.Message) func(rootVar, path string) string
- func (d ProtobufESDefinition) JsonFieldPath(opt *TSOption, rootMsg *protogen.Message) func(path string) string
- func (d ProtobufESDefinition) MessageToJson(msg *protogen.Message) func(g *TSRegistry, in string) string
- func (d ProtobufESDefinition) MsgFromJson(msg *protogen.Message) func(g *TSRegistry, in string) string
- func (d ProtobufESDefinition) MsgFromPartial(msg *protogen.Message) func(g *TSRegistry, in string) string
- func (d ProtobufESDefinition) MsgScalarable(msg *protogen.Message) bool
- func (d ProtobufESDefinition) ScalarToJson() func(g *TSRegistry, in string) string
- func (d ProtobufESDefinition) TSIdentMsg(msg *protogen.Message) TSIdent
- func (d ProtobufESDefinition) TSModule(file protoreflect.FileDescriptor) TSModule
- type TSIdent
- type TSModule
- type TSOption
- type TSProtoDefinition
- func (d TSProtoDefinition) EnumToJson(enumTyp *protogen.Enum) func(g *TSRegistry, in string) string
- func (d TSProtoDefinition) FieldToJson(field *protogen.Field) func(g *TSRegistry, in string) string
- func (d TSProtoDefinition) GetFieldSyntax(opt *TSOption, rootMsg *protogen.Message) func(rootVar string, path string) string
- func (d TSProtoDefinition) JsonFieldPath(opt *TSOption, rootMsg *protogen.Message) func(path string) string
- func (d TSProtoDefinition) MessageToJson(msgTyp *protogen.Message) func(g *TSRegistry, in string) string
- func (d TSProtoDefinition) MsgFromJson(msg *protogen.Message) func(g *TSRegistry, in string) string
- func (d TSProtoDefinition) MsgFromPartial(msg *protogen.Message) func(g *TSRegistry, in string) string
- func (d TSProtoDefinition) MsgScalarable(msg *protogen.Message) bool
- func (d TSProtoDefinition) ScalarToJson() func(g *TSRegistry, in string) string
- func (d TSProtoDefinition) TSIdentMsg(msg *protogen.Message) TSIdent
- func (d TSProtoDefinition) TSModule(file protoreflect.FileDescriptor) TSModule
- type TSRegistry
- func (g *TSRegistry) Apply(w io.Writer) error
- func (g *TSRegistry) ImportSegments() string
- func (g *TSRegistry) P(v ...any)
- func (opt *TSRegistry) PComment(comments ...string)
- func (opt *TSRegistry) PCommentf(format string, args ...interface{})
- func (opt *TSRegistry) PTmpl(tmpl *template.Template, data interface{}, funcs ...template.FuncMap)
- func (opt *TSRegistry) PTmplStr(tmpl string, data interface{}, funcs ...template.FuncMap)
- func (opt *TSRegistry) Pf(format string, v ...any)
- func (r *TSRegistry) QualifiedTSIdent(ident TSIdent) string
- func (g *TSRegistry) Write(p []byte) (n int, err error)
Constants ¶
View Source
const ( Definition_ProtobufES = "protobuf-es" Definition_TSProto = "ts-proto" )
Variables ¶
This section is empty.
Functions ¶
func GetModuleName ¶
func GetModuleName(file protoreflect.FileDescriptor) string
GetModuleName returns module name = package name + base file name to be the unique identifier for source file in a ts file. Package name and base file name are converted to camel case, special characters like dot, dash and underscore are removed. packageName: memos.api.v1 fileName: memos.proto
func JSONCamelCase ¶
JSONCamelCase converts a snake_case identifier to a camelCase identifier, according to the protobuf JSON specification.
Copied from: google.golang.org/protobuf/internal/strs.
Types ¶
type Definition ¶ added in v1.0.26
type Definition interface { TSModule(file protoreflect.FileDescriptor) TSModule TSIdentMsg(msg *protogen.Message) TSIdent GetFieldSyntax(opt *TSOption, rootMsg *protogen.Message) func(rootVar, path string) string // text_name format path JsonFieldPath(opt *TSOption, rootMsg *protogen.Message) func(path string) string // text_name format path to json_name format path MsgScalarable(msg *protogen.Message) bool // if the message type can be into json scalar MsgFromPartial(msg *protogen.Message) func(g *TSRegistry, in string) string MsgFromJson(msg *protogen.Message) func(g *TSRegistry, in string) string FieldToJson(field *protogen.Field) func(g *TSRegistry, in string) string // contains filtered or unexported methods }
func DefinitionFromOpts ¶ added in v1.0.26
func DefinitionFromOpts(opts TSOption) Definition
type ProtobufESDefinition ¶ added in v1.0.26
type ProtobufESDefinition struct{}
func (ProtobufESDefinition) EnumToJson ¶ added in v1.0.26
func (d ProtobufESDefinition) EnumToJson(enum *protogen.Enum) func(g *TSRegistry, in string) string
func (ProtobufESDefinition) FieldToJson ¶ added in v1.0.26
func (d ProtobufESDefinition) FieldToJson(field *protogen.Field) func(g *TSRegistry, in string) string
func (ProtobufESDefinition) GetFieldSyntax ¶ added in v1.0.26
func (ProtobufESDefinition) JsonFieldPath ¶ added in v1.0.26
func (ProtobufESDefinition) MessageToJson ¶ added in v1.0.26
func (d ProtobufESDefinition) MessageToJson(msg *protogen.Message) func(g *TSRegistry, in string) string
func (ProtobufESDefinition) MsgFromJson ¶ added in v1.0.26
func (d ProtobufESDefinition) MsgFromJson(msg *protogen.Message) func(g *TSRegistry, in string) string
func (ProtobufESDefinition) MsgFromPartial ¶ added in v1.0.26
func (d ProtobufESDefinition) MsgFromPartial(msg *protogen.Message) func(g *TSRegistry, in string) string
func (ProtobufESDefinition) MsgScalarable ¶ added in v1.0.26
func (d ProtobufESDefinition) MsgScalarable(msg *protogen.Message) bool
func (ProtobufESDefinition) ScalarToJson ¶ added in v1.0.26
func (d ProtobufESDefinition) ScalarToJson() func(g *TSRegistry, in string) string
func (ProtobufESDefinition) TSIdentMsg ¶ added in v1.0.26
func (d ProtobufESDefinition) TSIdentMsg(msg *protogen.Message) TSIdent
func (ProtobufESDefinition) TSModule ¶ added in v1.0.26
func (d ProtobufESDefinition) TSModule(file protoreflect.FileDescriptor) TSModule
type TSModule ¶
type TSProtoDefinition ¶ added in v1.0.26
type TSProtoDefinition struct{}
func (TSProtoDefinition) EnumToJson ¶ added in v1.0.26
func (d TSProtoDefinition) EnumToJson(enumTyp *protogen.Enum) func(g *TSRegistry, in string) string
func (TSProtoDefinition) FieldToJson ¶ added in v1.0.26
func (d TSProtoDefinition) FieldToJson(field *protogen.Field) func(g *TSRegistry, in string) string
func (TSProtoDefinition) GetFieldSyntax ¶ added in v1.0.26
func (TSProtoDefinition) JsonFieldPath ¶ added in v1.0.26
func (TSProtoDefinition) MessageToJson ¶ added in v1.0.26
func (d TSProtoDefinition) MessageToJson(msgTyp *protogen.Message) func(g *TSRegistry, in string) string
func (TSProtoDefinition) MsgFromJson ¶ added in v1.0.26
func (d TSProtoDefinition) MsgFromJson(msg *protogen.Message) func(g *TSRegistry, in string) string
func (TSProtoDefinition) MsgFromPartial ¶ added in v1.0.26
func (d TSProtoDefinition) MsgFromPartial(msg *protogen.Message) func(g *TSRegistry, in string) string
func (TSProtoDefinition) MsgScalarable ¶ added in v1.0.26
func (d TSProtoDefinition) MsgScalarable(msg *protogen.Message) bool
func (TSProtoDefinition) ScalarToJson ¶ added in v1.0.26
func (d TSProtoDefinition) ScalarToJson() func(g *TSRegistry, in string) string
func (TSProtoDefinition) TSIdentMsg ¶ added in v1.0.26
func (d TSProtoDefinition) TSIdentMsg(msg *protogen.Message) TSIdent
func (TSProtoDefinition) TSModule ¶ added in v1.0.26
func (d TSProtoDefinition) TSModule(file protoreflect.FileDescriptor) TSModule
type TSRegistry ¶
type TSRegistry struct { GenOpts pluginutils.GenerateOptions ImportIdents map[string][]TSIdent // map<module_path, TSIdent> // contains filtered or unexported fields }
func NewTSRegistry ¶
func NewTSRegistry(opts pluginutils.GenerateOptions) *TSRegistry
func (*TSRegistry) ImportSegments ¶
func (g *TSRegistry) ImportSegments() string
func (*TSRegistry) P ¶
func (g *TSRegistry) P(v ...any)
func (*TSRegistry) PComment ¶
func (opt *TSRegistry) PComment(comments ...string)
PComment allows multiple lines string as comment.
func (*TSRegistry) PCommentf ¶
func (opt *TSRegistry) PCommentf(format string, args ...interface{})
PCommentf allows formatted string as comment.
func (*TSRegistry) PTmpl ¶
func (opt *TSRegistry) PTmpl(tmpl *template.Template, data interface{}, funcs ...template.FuncMap)
func (*TSRegistry) PTmplStr ¶
func (opt *TSRegistry) PTmplStr(tmpl string, data interface{}, funcs ...template.FuncMap)
func (*TSRegistry) Pf ¶
func (opt *TSRegistry) Pf(format string, v ...any)
Pf is same as P, but with formatted string.
func (*TSRegistry) QualifiedTSIdent ¶
func (r *TSRegistry) QualifiedTSIdent(ident TSIdent) string
Click to show internal directories.
Click to hide internal directories.