File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,13 @@ func (o *GenOpts) templateFuncMap() template.FuncMap {
123
123
typ := anchor (fmt .Sprint (f .Message .Desc .FullName ()))
124
124
return fmt .Sprintf (`{{< relref "%s#%s" >}}` , fn , typ )
125
125
}
126
+ if f .Enum != nil {
127
+ fn := fmt .Sprint (f .Enum .Desc .ParentFile ().Path ())
128
+ fn = filepath .Base (fn )
129
+ fn = strings .TrimSuffix (fn , filepath .Ext (fn ))
130
+ typ := anchor (fmt .Sprint (f .Enum .Desc .FullName ()))
131
+ return fmt .Sprintf (`{{< relref "%s#%s" >}}` , fn , typ )
132
+ }
126
133
return fmt .Sprintf (`#%s` , anchor (f .Desc .FullName ()))
127
134
},
128
135
"description" : func (s interface {}) string {
Original file line number Diff line number Diff line change @@ -84,8 +84,9 @@ Message template
84
84
{{if .Fields}}
85
85
| Field | Type | Description |
86
86
| ----- | ---- | ----------- |
87
- {{range .Fields}}{{template "field" .}}{{end}}
88
- {{end}}
87
+ {{range .Fields}}{{ if (not .Desc.ContainingOneof) }}{{template "field" .}}{{end}}{{end}}
88
+ {{- end -}}
89
+ {{range .Oneofs}}{{template "oneof" .}}{{end}}
89
90
90
91
{{if .Extensions}}
91
92
| Extension | Type | Base | Number | Description |
@@ -109,15 +110,23 @@ Message template
109
110
Field template
110
111
***************************************************************/}}
111
112
{{define "field" -}}
112
- | {{.Desc.Name}} |
113
+ | {{.Desc.Name}}{{ if .Desc.IsList }}[]{{ end }} |
113
114
{{- if (is_primitive .) -}}
114
- {{ if .Desc.IsList }}repeated {{ end }} {{ field_type . }}
115
+ {{ field_type . }}
115
116
{{- else -}}
116
- [{{ .| field_type }}]({{ type_link . }})
117
+ [{{ .| field_type }}]({{ type_link . }})
117
118
{{- end -}}
118
119
| {{ .Comments.Leading | description | nobr}} {{ .Comments.Trailing | description | nobr }} |
119
120
{{end}}
120
121
122
+ {{/***************************************************************
123
+ Oneof template
124
+ This is kind of gross since GFM doesn't support colspan.
125
+ ***************************************************************/}}
126
+ {{define "oneof" -}}
127
+ |<tr><td colspan=2>Union field `{{ .Desc.Name }}`. {{ .Comments.Leading | description | nobr}} {{ .Comments.Trailing | description | nobr }} `{{ .Desc.Name }}` can be only one of the following:</td></tr>|
128
+ {{range .Fields}}{{template "field" .}}{{end}}
129
+ {{end}}
121
130
122
131
{{/***************************************************************
123
132
Enum template
You can’t perform that action at this time.
0 commit comments