Skip to content

Commit

Permalink
Update generated doc strings and make generate (#580)
Browse files Browse the repository at this point in the history
These changes are the result of:
- Re-tabbing the doc string generation logic of gen/enum.go and gen/field.go
- running 'GO111MODULE=on make generate' on dev.

These steps are performed to update generated code, make the generated
code compliant with gofmt, and resolve release issues ahead of time.
  • Loading branch information
r-hang authored Jun 7, 2023
1 parent 9197231 commit 0977c0d
Show file tree
Hide file tree
Showing 20 changed files with 1,650 additions and 1,650 deletions.
40 changes: 20 additions & 20 deletions gen/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func enum(g Generator, spec *compile.EnumSpec) error {
// containing its name.
<- if .Spec.Items>
//
// var <$v> <$enumName>
// err := <$v>.UnmarshalText([]byte("<(index .Spec.Items 0).Name>"))
// var <$v> <$enumName>
// err := <$v>.UnmarshalText([]byte("<(index .Spec.Items 0).Name>"))
<- end>
func (<$v> *<$enumName>) UnmarshalText(<$value> []byte) error {
<- $s := newVar "s" ->
Expand Down Expand Up @@ -196,10 +196,10 @@ func enum(g Generator, spec *compile.EnumSpec) error {
<$sw := newVar "sw">
// Encode encodes <$enumName> directly to bytes.
//
// sWriter := BinaryStreamer.Writer(writer)
// sWriter := BinaryStreamer.Writer(writer)
//
// var <$v> <$enumName>
// return <$v>.Encode(sWriter)
// var <$v> <$enumName>
// return <$v>.Encode(sWriter)
func (<$v> <$enumName>) Encode(<$sw> <$stream>.Writer) error {
return <$sw>.WriteInt32(int32(<$v>))
}
Expand All @@ -217,16 +217,16 @@ func enum(g Generator, spec *compile.EnumSpec) error {
// FromWire deserializes <$enumName> from its Thrift-level
// representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TI32)
// if err != nil {
// return <$enumName>(0), err
// }
// x, err := binaryProtocol.Decode(reader, wire.TI32)
// if err != nil {
// return <$enumName>(0), err
// }
//
// var <$v> <$enumName>
// if err := <$v>.FromWire(x); err != nil {
// return <$enumName>(0), err
// }
// return <$v>, nil
// var <$v> <$enumName>
// if err := <$v>.FromWire(x); err != nil {
// return <$enumName>(0), err
// }
// return <$v>, nil
func (<$v> *<$enumName>) FromWire(<$w> <$wire>.Value) error {
*<$v> = (<$enumName>)(<$w>.GetI32());
return nil
Expand All @@ -235,13 +235,13 @@ func enum(g Generator, spec *compile.EnumSpec) error {
<$sr := newVar "sr">
// Decode reads off the encoded <$enumName> directly off of the wire.
//
// sReader := BinaryStreamer.Reader(reader)
// sReader := BinaryStreamer.Reader(reader)
//
// var <$v> <$enumName>
// if err := <$v>.Decode(sReader); err != nil {
// return <$enumName>(0), err
// }
// return <$v>, nil
// var <$v> <$enumName>
// if err := <$v>.Decode(sReader); err != nil {
// return <$enumName>(0), err
// }
// return <$v>, nil
func (<$v> *<$enumName>) Decode(<$sr> <$stream>.Reader) error {
<- $i := newVar "i" ->
<$i>, err := <$sr>.ReadInt32()
Expand Down
32 changes: 16 additions & 16 deletions gen/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,14 @@ func (f fieldGroupGenerator) ToWire(g Generator) error {
// An error is returned if the struct or any of its fields failed to
// validate.
//
// x, err := <$v>.ToWire()
// if err != nil {
// return err
// }
// x, err := <$v>.ToWire()
// if err != nil {
// return err
// }
//
// if err := binaryProtocol.Encode(x, writer); err != nil {
// return err
// }
// if err := binaryProtocol.Encode(x, writer); err != nil {
// return err
// }
func (<$v> *<.Name>) ToWire() (<$wire>.Value, error) {
<$fields := newVar "fields" ->
<- $i := newVar "i" ->
Expand Down Expand Up @@ -392,16 +392,16 @@ func (f fieldGroupGenerator) FromWire(g Generator) error {
// An error is returned if we were unable to build a <.Name> struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var <$v> <.Name>
// if err := <$v>.FromWire(x); err != nil {
// return nil, err
// }
// return &<$v>, nil
// var <$v> <.Name>
// if err := <$v>.FromWire(x); err != nil {
// return nil, err
// }
// return &<$v>, nil
func (<$v> *<.Name>) FromWire(<$w> <$wire>.Value) error {
<if len .Fields> var err error <end>
<$f := newVar "field">
Expand Down
Loading

0 comments on commit 0977c0d

Please sign in to comment.