bones

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(protoSet, methodDir string, force bool, targets []string, formatter FormatOptions) error

Generate writes exemplars for the methods specified by targets that match the methods in the protoSet file, or all methods if targets is an empty slice. Method exemplars are written to stdout if methodDir is empty, otherwise each method is written to a separate file in that directory. Existing files will not be overwritten unless force is true.

Types

type FormatOptions added in v0.0.22

type FormatOptions struct {
	Lang       Lang
	QuoteStyle QuoteStyle
}

FormatOptions is a configurable target language exemplar generator.

func (*FormatOptions) EnumExemplar added in v0.0.22

func (o *FormatOptions) EnumExemplar(fd protoreflect.FieldDescriptor) exemplar

EnumExemplar returns an exemplar with a sample value for the enum. An empty exemplar is returned if the field is not an enum.

Enum exemplars are emitted as a string with the name of the second enum if there is more than one enum value, otherwise the first enum. The second enum is preferred as often the first enum is the "invalid" value for that enum.

func (*FormatOptions) Extension added in v0.0.22

func (o *FormatOptions) Extension() string

Return the file extension for the given language.

func (*FormatOptions) FieldExemplar added in v0.0.22

func (o *FormatOptions) FieldExemplar(fd protoreflect.FieldDescriptor) exemplar

FieldExemplar returns an exemplar for a message field. It has the JSON name for the field prefixed and a comment appended to the first line describing the type of the field.

func (*FormatOptions) FieldValueExemplar added in v0.0.22

func (o *FormatOptions) FieldValueExemplar(fd protoreflect.FieldDescriptor) exemplar

FieldValueExemplar returns an exemplar for the value of a FieldDescriptor. The value is as per the exemplar form for the fields type. See the other *Exemplar functions for details of those.

Map fields are emitted as repeated key/value message pairs in the expanded backward-compatible form, as opposed to {key: value, ...} objects.

Repeated fields are emitted with a single element exemplar of the repeated type.

func (*FormatOptions) MessageExemplar added in v0.0.22

func (o *FormatOptions) MessageExemplar(md protoreflect.MessageDescriptor) exemplar

MessageExemplar returns an exemplar of a protobuf message as a JSON object with a field for every message field. Each field value is an exemplar of the type of the field. Oneof fields are emitted as comments as a message should not have more than one oneof specified.

func (*FormatOptions) MethodExemplar added in v0.0.22

func (o *FormatOptions) MethodExemplar(md protoreflect.MethodDescriptor) exemplar

MethodExemplar returns an exemplar for a method, with an exemplar for the input message as a comment and a function returning an exemplar of the output message as the method implementation.

func (*FormatOptions) ScalarExemplar added in v0.0.22

func (o *FormatOptions) ScalarExemplar(kind protoreflect.Kind) exemplar

ScalarExemplar returns an exemplar with a value for basic kinds that have a single value (scalars). An empty exemplar is returned for other kinds.

func (*FormatOptions) WellKnownExemplar added in v0.0.22

func (o *FormatOptions) WellKnownExemplar(md protoreflect.MessageDescriptor) exemplar

WellKnownExemplar returns an exemplar for a well-known type (those in the google.protobuf package). These are typically messages that are rendered in JSON as a single field, rather than as an object.

https://developers.google.com/protocol-buffers/docs/reference/google.protobuf

type Lang added in v0.0.22

type Lang int
const (
	Jsonnet Lang = iota
	JS
)

func (Lang) String added in v0.0.22

func (l Lang) String() string

func (*Lang) UnmarshalText added in v0.0.22

func (l *Lang) UnmarshalText(text []byte) error

type QuoteStyle added in v0.0.22

type QuoteStyle int
const (
	Double QuoteStyle = iota
	Single
)

func (QuoteStyle) String added in v0.0.22

func (qs QuoteStyle) String() string

func (*QuoteStyle) UnmarshalText added in v0.0.22

func (qs *QuoteStyle) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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