Skip to content

Commit

Permalink
render comments in webrpc methods (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJenicek authored Apr 24, 2024
1 parent badb0e7 commit 63ec3bf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
12 changes: 9 additions & 3 deletions _examples/golang-basics/example.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions _examples/golang-basics/example.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ error 400300 UserNotFound "user not found"

service ExampleService
- Ping()
# Status endpoint
#
# gives you current status of running application
- Status() => (status: bool)
- Version() => (version: Version)
- GetUser(header: map<string,string>, userID: uint64) => (user: User)
Expand Down
2 changes: 1 addition & 1 deletion _examples/golang-imports/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions types.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ var WebRPCServices = map[string][]string{
{{ if $opts.types -}}
type {{$service.Name}} interface {
{{- range $_, $method := $service.Methods}}
{{- if gt (len $method.Comments) 0 -}}
{{- range $_, $comment := $method.Comments }}
// {{ replaceAll $comment "\"" "'" }}
{{- end }}
{{- end }}
{{ if eq $method.StreamOutput true -}}
{{$method.Name}}(ctx context.Context{{range $_, $input := $method.Inputs}}, {{$input.Name}} {{template "field" dict "Name" $input.Name "Type" $input.Type "TypeMap" $typeMap "TypePrefix" $typePrefix "Optional" $input.Optional "TypeMeta" $input.Meta}}{{end}}, stream {{$method.Name}}StreamWriter) error
{{- else -}}
Expand Down Expand Up @@ -144,6 +149,11 @@ func (w *streamWriter) write(respPayload interface{}) error {
{{ range $_, $service := $services -}}
type {{$service.Name}}Client interface {
{{- range $_, $method := $service.Methods}}
{{- if gt (len $method.Comments) 0 }}
{{- range $_, $comment := $method.Comments }}
// {{ replaceAll $comment "\"" "'" }}
{{- end }}
{{- end }}
{{ if eq $method.StreamOutput true -}}
{{$method.Name}}(ctx context.Context{{range $_, $input := $method.Inputs}}, {{$input.Name}} {{template "field" dict "Name" $input.Name "Type" $input.Type "TypeMap" $typeMap "TypePrefix" $typePrefix "Optional" $input.Optional "TypeMeta" $input.Meta}}{{end}}) ({{$method.Name}}StreamReader, error)
{{- else -}}
Expand Down

0 comments on commit 63ec3bf

Please sign in to comment.