Skip to content

Commit 0f3b8ca

Browse files
committed
protoc-gen-apidocs: Regenerate with optional support
1 parent 133c166 commit 0f3b8ca

File tree

4 files changed

+4
-303
lines changed

4 files changed

+4
-303
lines changed

templates/markdown.tmpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ Message template
8686
| ----- | ---- | ----------- |
8787
{{range .Fields}}{{ if (not .Desc.ContainingOneof) }}{{template "field" .}}{{end}}{{end}}
8888
{{- end -}}
89-
{{range .Oneofs}}{{template "oneof" .}}{{end}}
89+
90+
{{range .Oneofs}}{{ if .Desc.IsSynthetic }}{{template "field" (index .Fields 0) }}{{else}}{{template "oneof" .}}{{end}}{{end}}
9091

9192
{{if .Extensions}}
9293
| Extension | Type | Base | Number | Description |
@@ -110,7 +111,7 @@ Message template
110111
Field template
111112
***************************************************************/}}
112113
{{define "field" -}}
113-
| {{.Desc.Name}}{{ if .Desc.IsList }}[]{{ end }} |
114+
| {{.Desc.Name }}{{ if .Desc.IsList }}[]{{ end }}{{ if .Desc.HasOptionalKeyword }} (optional){{ end }} |
114115
{{- if (or (is_primitive .) (is_google_type .)) -}}
115116
{{ field_type . }}
116117
{{- else -}}

testdata/example1/Booking.md

Lines changed: 0 additions & 131 deletions
This file was deleted.

testdata/example1/Vehicle.md

Lines changed: 0 additions & 167 deletions
This file was deleted.

testdata/example1/field_presence.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ description: API Specification for the com.example.proto3 package.
2222
| Field | Type | Description |
2323
| ----- | ---- | ----------- |
2424
| not_tracked |int32| |
25-
|<tr><td colspan=2>Union field `_tracked`. `_tracked` can be only one of the following:</td></tr>|
26-
| tracked |int32| Explicit presence |
27-
25+
| tracked (optional) |int32| Explicit presence |
2826

2927

3028

0 commit comments

Comments
 (0)