Last active
October 8, 2021 14:55
-
-
Save lambdalisue/1f5ec5ee66e66c51564ab0c6ab2e89ce to your computer and use it in GitHub Desktop.
Makrdown template of protoc-gen-doc for better looks in GitHub Pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<details open markdown="block"> | |
<summary>Table of contents</summary> | |
<ul> | |
<li> | |
<a href="#services">Services</a> | |
<ul> | |
{{- range .Files}}{{range .Services}} | |
<li><a href="#{{.FullName | lower | replace "." ""}}">{{.LongName}} (<code>{{.FullName}}</code>)</a></li> | |
{{- end}}{{end}} | |
</ul> | |
</li> | |
<li> | |
<a href="#messages">Messages</a> | |
<ul> | |
{{- range .Files}}{{range .Messages}} | |
<li><a href="#{{.FullName | lower | replace "." ""}}">{{.LongName}} (<code>{{.FullName}}</code>)</a></li> | |
{{- end}}{{end}} | |
</ul> | |
</li> | |
<li> | |
<a href="#enums">Enums</a> | |
<ul> | |
{{- range .Files}}{{range .Enums}} | |
<li><a href="#{{.FullName | lower | replace "." ""}}">{{.LongName}} (<code>{{.FullName}}</code>)</a></li> | |
{{- end}}{{end}} | |
</ul> | |
</li> | |
<li><a href="#scalar-value-types">Scalar Value Types</a></li> | |
</ul> | |
</details> | |
<h1 id="service" name="service">Service</h1> | |
{{- range .Files}}{{range .Services}} | |
<h2 id="{{.FullName | lower | replace "." ""}}" name="{{.FullName | lower | replace "." ""}}">{{.LongName}} <small>(<code>{{.FullName}}</code>)</small></h2> | |
{{.Description}} | |
| Method name | Request type | Response type | Description | | |
| ----------- | ------------ | ------------- | ----------- | | |
{{range .Methods -}} | |
| `{{.Name}}`{{/* noline */ -}} | |
| {{if .RequestStreaming}}**stream** {{end}}[`{{.RequestLongType}}`](#{{.RequestFullType | lower | replace "." ""}}){{/* noline */ -}} | |
| {{if .ResponseStreaming}}**stream** {{end}}[`{{.ResponseLongType}}`](#{{.ResponseFullType | lower | replace "." ""}}){{/* noline */ -}} | |
| {{if .Description}}{{.Description | replace "\n" "<br>"}}{{end}}{{/* noline */ -}} | |
| | |
{{end}}{{/* range .Methods */}} | |
{{- end}}{{/* range .Services */}} | |
{{- end}}{{/* range .Files */}} | |
<h1 id="messages" name="messages">Messages</h1> | |
{{- range .Files}}{{range .Messages}} | |
<h2 id="{{.FullName | lower | replace "." ""}}" name="{{.FullName | lower | replace "." ""}}">{{.LongName}} <small>(<code>{{.FullName}}</code>)</small></h2> | |
{{.Description}} | |
{{ if .HasFields}} | |
| Field | Type | Description | | |
| ------| ---- | ----------- | | |
{{range .Fields -}} | |
| {{if .IsOneof -}}<small>{{if eq .OneofDecl (printf "_%s" .Name)}}<strong>optional</strong>{{else}}<strong>oneof</strong> <code>{{.OneofDecl}}</code>{{end}}</small><br>{{end}}`{{.Name}}` {{/* noline */ -}} | |
| [`{{if .IsMap}}map{{else}}{{.Label}}{{end}}{{.LongType}}`](#{{.FullType | lower | replace "." ""}}) {{/* noline */ -}} | |
| {{if (index .Options "deprecated" | default false)}}**deprecated**<br>{{end}}{{if .Description}}{{.Description | replace "\n" "<br>"}}{{end}} {{/* noline */ -}} | |
| | |
{{end}}{{/* range .Fields */}} | |
{{- end}}{{/* if .HasFields */}} | |
{{- end}}{{/* range .Messages */}} | |
{{- end}}{{/* range .Files */}} | |
<h1 id="enums" name="enums">Enums</h1> | |
{{- range .Files}}{{range .Enums}} | |
<h2 id="{{.FullName | lower | replace "." ""}}" name="{{.FullName | lower | replace "." ""}}">{{.LongName}} <small>(<code>{{.FullName}}</code>)</small></h2> | |
{{.Description}} | |
| Name | Number | Description | | |
| ---- | ------ | ----------- | | |
{{range .Values -}} | |
| `{{.Name}}` | `{{.Number}}` | {{if .Description}}{{.Description | replace "\n" "<br>"}}{{end}} | | |
{{end}}{{/* range .Value */}} | |
{{- end}}{{/* range .Enums */}} | |
{{- end}}{{/* range .Files */}} | |
<h1 id="scalar-value-types" name="scalar-value-types">Scalar Value Types</h1> | |
| .proto Type | Notes | | |
| ----------- | ----- | | |
{{range .Scalars -}} | |
| <code id="{{.ProtoType | lower | replace "." ""}}" name="{{.ProtoType | lower | replace "." ""}}">{{.ProtoType }}</code> | {{.Notes | replace "\n" "<br>"}} | | |
{{end}} |
Above markdown.tmpl
support oneof and optional like
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/pseudomuto/protoc-gen-doc