Skip to content

Commit

Permalink
Merge pull request #987 from Workiva/release_2_17_0
Browse files Browse the repository at this point in the history
INFENG-5441 Release 2.17.0
  • Loading branch information
brianshannan-wf authored Apr 2, 2018
2 parents 0689625 + 68d0704 commit 94e131e
Show file tree
Hide file tree
Showing 1,276 changed files with 199,576 additions and 140,440 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ lib/python/frugalc
lib/python/dist
Library/

# Go lib specific
lib/go/vendor
lib/go/glide.lock
examples/go/vendor
examples/go/glide.lock

# Integration tests
artifacts/
test/integration/log/*
Expand Down
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ before_install:
- sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
- mkdir $HOME/.virtuanenvs && echo "export WORKON_HOME=$HOME/.virtualenvs" >> $HOME/.bashrc
- sudo add-apt-repository -y ppa:openjdk-r/ppa
- sudo add-apt-repository -y ppa:masterminds/glide
- sudo apt-get update -qq
- sudo apt-get -y install python3-pip python-dev build-essential virtualenvwrapper openjdk-8-jdk maven dart
- sudo apt-get -y install python3-pip python-dev build-essential virtualenvwrapper openjdk-8-jdk maven dart glide
- pip install -U setuptools virtualenv virtualenvwrapper
- echo "source /etc/bash_completion.d/virtualenvwrapper" >> $HOME/.bashrc && source $HOME/.bashrc
- cd $TRAVIS_BUILD_DIR/lib/python
- mkvirtualenv py2 && make deps-tornado deps-gae
- mkvirtualenv py3 -p $(which python3) && make deps-asyncio

install:
- go get github.com/tools/godep

script:
- cd $TRAVIS_BUILD_DIR && godep restore && godep go test ./test -race
- cd $TRAVIS_BUILD_DIR/lib/go && godep restore && godep go test -race
- cd $TRAVIS_BUILD_DIR && go test ./test -race
- cd $TRAVIS_BUILD_DIR/lib/go && glide install && go test -race $(glide nv)
- cd $TRAVIS_BUILD_DIR/lib/python
- workon py2 && make xunit-py2 flake8-py2
- workon py3 && make xunit-py3 flake8-py3
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ releases tab. Currently, adding these binaries is a manual process. If
a downloadable release is missing, notify the messaging team to have it
added.

### From Source

1. Install [go](https://golang.org/doc/install) and setup [`GOPATH`](https://github.com/golang/go/wiki/GOPATH).
1. Install [godep](https://github.com/tools/godep).
1. Get the frugal source code
If go is already installed and setup you can also simply:

```bash
$ go get github.com/Workiva/frugal
```
```bash
$ go get github.com/Workiva/frugal
```

Or you can manually clone the frugal repo
### From Source
**Our usage of godep has been deprecated as we move to glide. Once the deprecation period is over, we will remove both the Godeps/ and vendor/ folder, relying solely on glide for dependency management**
1. Install [go](https://golang.org/doc/install) and setup [`GOPATH`](https://github.com/golang/go/wiki/GOPATH).
1. Clone the frugal repo

```bash
$ mkdir -p $GOPATH/src/github.com/Workiva/
$ cd $GOPATH/src/github.com/Workiva
$ mkdir -p $GOPATH/src/github.com/Workiva && cd $_
$ git clone [email protected]:Workiva/frugal.git
```

1. Install frugal with godep
1. Install the CLI binary
```bash
$ cd $GOPATH/src/github.com/Workiva/frugal
$ godep go install
$ curl https://glide.sh/get | sh # get glide if necessary
$ glide install # get dependencies
$ go install
```

When generating go, be aware the frugal go library and the frugal compiler
Expand Down Expand Up @@ -215,7 +215,7 @@ Some common annotations are listed below
| Annotation | Values | Allowed Places | Description
| ------------- | ------------- | -------------- | -----------
| vendor | Optional location | Namespaces, Includes | See [vendoring includes](#vendoring-includes)
| deprecated | Optional description | Service methods | Marks a method as deprecated (if supported by the language) and logs a warning if the method is called.
| deprecated | Optional description | Service methods, Struct/union/exception fields | Marks a method or field as deprecated (if supported by the language, or in a comment otherwise), and logs a warning if a deprecated method is called.

### Vendoring Includes

Expand Down
59 changes: 25 additions & 34 deletions compiler/generator/dartlang/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,7 @@ func (g *Generator) generateStruct(s *parser.Struct) string {

// Fields
for _, field := range s.Fields {
if field.Comment != nil {
contents += g.GenerateInlineComment(field.Comment, tab+"/")
}
contents += g.generateCommentWithDeprecated(field.Comment, tab, field.Annotations)
contents += fmt.Sprintf(tab+"%s _%s%s;\n",
g.getDartTypeFromThriftType(field.Type), toFieldName(field.Name), g.generateInitValue(field))
contents += fmt.Sprintf(tab+"static const int %s = %d;\n", strings.ToUpper(field.Name), field.ID)
Expand Down Expand Up @@ -730,20 +728,19 @@ func (g *Generator) generateFieldMethods(s *parser.Struct) string {
fName := toFieldName(field.Name)
titleName := strings.Title(field.Name)

if field.Comment != nil {
contents += g.GenerateInlineComment(field.Comment, tab+"/")
}
contents += g.generateCommentWithDeprecated(field.Comment, tab, field.Annotations)
contents += fmt.Sprintf(tab+"%s get %s => this._%s;\n\n", dartType, fName, fName)
if field.Comment != nil {
contents += g.GenerateInlineComment(field.Comment, tab+"/")
}
contents += g.generateCommentWithDeprecated(field.Comment, tab, field.Annotations)
contents += fmt.Sprintf(tab+"set %s(%s %s) {\n", fName, dartType, fName)
contents += fmt.Sprintf(tabtab+"this._%s = %s;\n", fName, fName)
if dartPrimitive {
contents += fmt.Sprintf(tabtab+"this.__isset_%s = true;\n", fName)
}
contents += tab + "}\n\n"

if field.Annotations.IsDeprecated() {
contents += tab + "@deprecated"
}
if dartPrimitive {
contents += fmt.Sprintf(tab+"bool isSet%s() => this.__isset_%s;\n\n", titleName, fName)
contents += fmt.Sprintf(tab+"unset%s() {\n", titleName)
Expand Down Expand Up @@ -1511,6 +1508,22 @@ func (g *Generator) GenerateService(file *os.File, s *parser.Service) error {
return err
}

func (g *Generator) generateCommentWithDeprecated(comment []string, indent string, anns parser.Annotations) string {
contents := ""
if comment != nil {
contents += g.GenerateInlineComment(comment, indent+"/")
}

if deprecationValue, deprecated := anns.Deprecated(); deprecated {
if deprecationValue != "" {
contents += g.GenerateInlineComment([]string{"Deprecated: " + deprecationValue}, indent+"/")
}
contents += indent + "@deprecated\n"
}

return contents
}

func (g *Generator) generateInterface(service *parser.Service) string {
contents := ""
if service.Comment != nil {
Expand All @@ -1524,17 +1537,7 @@ func (g *Generator) generateInterface(service *parser.Service) string {
}
for _, method := range service.Methods {
contents += "\n"
if method.Comment != nil {
contents += g.GenerateInlineComment(method.Comment, tab+"/")
}

if deprecationValue, deprecated := method.Annotations.Deprecated(); deprecated {
if deprecationValue != "" {
contents += g.GenerateInlineComment([]string{"Deprecated: " + deprecationValue}, tab+"/")
}
contents += tab + "@deprecated\n"
}

contents += g.generateCommentWithDeprecated(method.Comment, tab, method.Annotations)
contents += fmt.Sprintf(tab+"Future%s %s(frugal.FContext ctx%s);\n",
g.generateReturnArg(method), parser.LowercaseFirstLetter(method.Name), g.generateInputArgs(method.Arguments))
}
Expand Down Expand Up @@ -1605,25 +1608,13 @@ func (g *Generator) generateClient(service *parser.Service) string {

func (g *Generator) generateClientMethod(service *parser.Service, method *parser.Method) string {
nameLower := parser.LowercaseFirstLetter(method.Name)
contents := ""

if method.Comment != nil {
contents += g.GenerateInlineComment(method.Comment, tab+"/")
}

deprecationValue, deprecated := method.Annotations.Deprecated()
if deprecated {
if deprecationValue != "" {
contents += g.GenerateInlineComment([]string{"Deprecated: " + deprecationValue}, tab+"/")
}
contents += tab + "@deprecated\n"
}
contents := g.generateCommentWithDeprecated(method.Comment, tab, method.Annotations)

// Generate wrapper method
contents += fmt.Sprintf(tab+"Future%s %s(frugal.FContext ctx%s) {\n",
g.generateReturnArg(method), nameLower, g.generateInputArgs(method.Arguments))

if deprecated {
if method.Annotations.IsDeprecated() {
contents += fmt.Sprintf(tabtab+"_frugalLog.warning(\"Call to deprecated function '%s.%s'\");\n", service.Name, nameLower)
}

Expand Down
33 changes: 21 additions & 12 deletions compiler/generator/golang/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (g *Generator) GenerateConstantsContents(constants []*parser.Constant) erro

// quote creates a Go string literal for a string.
func (g *Generator) quote(s string) string {
return strconv.Quote(s);
return strconv.Quote(s)
}

// generateConstantValue recursively generates the string representation of
Expand Down Expand Up @@ -442,6 +442,24 @@ func (g *Generator) generateStruct(s *parser.Struct, serviceName string) string
return contents
}

func (g *Generator) generateCommentWithDeprecated(comment []string, indent string, anns parser.Annotations) string {
contents := ""
if comment != nil {
contents += g.GenerateInlineComment(comment, indent)
}

deprecationValue, deprecated := anns.Deprecated()
if deprecated && deprecationValue != "" {
if deprecationValue == "" {
contents += indent + "// Deprecated\n"
} else {
contents += fmt.Sprintf("%s// Deprecated: %s\n", indent, deprecationValue)
}
}

return contents
}

func (g *Generator) generateStructDeclaration(s *parser.Struct, sName string) string {
contents := ""
if s.Comment != nil {
Expand All @@ -455,9 +473,7 @@ func (g *Generator) generateStructDeclaration(s *parser.Struct, sName string) st
fName := title(field.Name)
// All fields in a union are marked optional by default

if field.Comment != nil {
contents += g.GenerateInlineComment(field.Comment, "\t")
}
contents += g.generateCommentWithDeprecated(field.Comment, "\t", field.Annotations)

// Use the actual field name for annotations because the serialized
// name needs to be the same for all languages
Expand Down Expand Up @@ -1518,14 +1534,7 @@ func (g *Generator) generateServiceInterface(service *parser.Service) string {
contents += fmt.Sprintf("\t%s\n\n", g.getServiceExtendsName(service))
}
for _, method := range service.Methods {
if method.Comment != nil {
contents += g.GenerateInlineComment(method.Comment, "\t")
}

if _, ok := method.Annotations.Deprecated(); ok {
contents += "\t// Deprecated\n"
}

contents += g.generateCommentWithDeprecated(method.Comment, "\t", method.Annotations)
contents += fmt.Sprintf("\t%s(ctx frugal.FContext%s) %s\n",
snakeToCamel(method.Name), g.generateInterfaceArgs(method.Arguments),
g.generateReturnArgs(method))
Expand Down
2 changes: 1 addition & 1 deletion compiler/generator/html/module_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const moduleTemplate = `
<td>{{ .ID }}</td>
<td>{{ .Name }}</td>
<td><code>{{ .Type | displayType }}</code></td>
<td>{{ range .Comment }}{{ . }}<br />{{ end }}</td>
<td>{{ range .Comment }}{{ . }}<br />{{ end }}{{ if .Annotations.IsDeprecated }}Deprecated{{ if .Annotations.DeprecationValue }}: {{ .Annotations.DeprecationValue }}{{ end }}{{ end }}</td>
<td>{{ .Modifier.String | lowercase }}</td>
<td>{{ if .Default }}<code>{{ .Default | formatValue }}</code>{{ end }}</td>
</tr>
Expand Down
Loading

0 comments on commit 94e131e

Please sign in to comment.