Skip to content
Permalink
Browse files

regenerate for schema changes by 2019-06-01

Start cleaning descriptions by using new "clean" template function.

Some of the GraphQL descriptions started being split across multiple
lines via newline characters. That was not compatible with how we're
generating the line comments, because the assumption was that the
description was a single line.

For now, it's viable to clean them by replacing all whitespace
characters with a single space, effectively inlining their text.
This works because none of the descriptions we're using at this
time contain multiple paragraphs. Should that change, we'll need
to start using a different strategy for generating comments.

Regenerated with:

	GITHUB_TOKEN=<redacted> go generate ./...

Reference: https://developer.github.com/v4/changelog/.
  • Loading branch information...
dmitshur committed Jun 1, 2019
1 parent 7040323 commit 068505affed7d8555196a48eb3e0ed43410aa8e8
Showing with 533 additions and 22 deletions.
  1. +137 −15 enum.go
  2. +7 −6 gen.go
  3. +389 −1 input.go
152 enum.go

Some generated files are not rendered by default. Learn more.

13 gen.go
@@ -86,12 +86,12 @@ package githubv4
{{- define "enum" -}}
// {{.name}} {{.description | endSentence}}
// {{.name}} {{.description | clean | endSentence}}
type {{.name}} string
// {{.description | fullSentence}}
// {{.description | clean | fullSentence}}
const ({{range .enumValues}}
{{$.name}}{{.name | enumIdentifier}} {{$.name}} = {{.name | quote}} // {{.description | fullSentence}}{{end}}
{{$.name}}{{.name | enumIdentifier}} {{$.name}} = {{.name | quote}} // {{.description | clean | fullSentence}}{{end}}
)
{{- end -}}
`),
@@ -110,12 +110,12 @@ type Input interface{}
{{- define "inputObject" -}}
// {{.name}} {{.description | endSentence}}
// {{.name}} {{.description | clean | endSentence}}
type {{.name}} struct {{"{"}}{{range .inputFields}}{{if eq .type.kind "NON_NULL"}}
// {{.description | fullSentence}} (Required.)
// {{.description | clean | fullSentence}} (Required.)
{{.name | identifier}} {{.type | type}} ` + "`" + `json:"{{.name}}"` + "`" + `{{end}}{{end}}
{{range .inputFields}}{{if ne .type.kind "NON_NULL"}}
// {{.description | fullSentence}} (Optional.)
// {{.description | clean | fullSentence}} (Optional.)
{{.name | identifier}} {{.type | type}} ` + "`" + `json:"{{.name}},omitempty"` + "`" + `{{end}}{{end}}
}
{{- end -}}
@@ -167,6 +167,7 @@ func t(text string) *template.Template {
"identifier": func(name string) string { return ident.ParseLowerCamelCase(name).ToMixedCaps() },
"enumIdentifier": func(name string) string { return ident.ParseScreamingSnakeCase(name).ToMixedCaps() },
"type": typeString,
"clean": func(s string) string { return strings.Join(strings.Fields(s), " ") },
"endSentence": func(s string) string {
s = strings.ToLower(s[0:1]) + s[1:]
switch {

0 comments on commit 068505a

Please sign in to comment.
You can’t perform that action at this time.