Skip to content

Commit 2a12574

Browse files
committed
Add custom markdown template
This template does the following: - Adds an indication that the the field in a message has the `oneof` property - Removes the table of contents (Mkdocs automatically adds one for us when we use this file in the SDK docs) Other than that the output should be the same as with the standard template.
1 parent a8de68e commit 2a12574

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

markdown.tmpl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Protocol Documentation
2+
{{range .Files}}
3+
{{$file_name := .Name}}
4+
<a name="{{.Name | anchor}}"></a>
5+
6+
## {{.Name}}
7+
{{.Description}}
8+
9+
{{range .Messages}}
10+
<a name="{{.FullName | anchor}}"></a>
11+
12+
### {{.LongName}}
13+
{{.Description}}
14+
15+
{{ if .HasFields}}
16+
| Field | Type | Description |
17+
| ------| ---- | ----------- |
18+
{{range .Fields -}}
19+
| {{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 */ -}}
20+
| [{{if .IsMap}}map{{else}}{{.Label}} {{end}}{{.LongType}}](#{{.FullType | anchor}}) {{/* noline */ -}}
21+
| {{if (index .Options "deprecated" | default false)}}**deprecated**<br>{{end}}{{if .Description}}{{.Description | replace "\n" "<br>"}}{{end}} {{/* noline */ -}}
22+
|
23+
{{end}}{{/* range .Fields */}}
24+
{{- end}}{{/* if .HasFields */}}
25+
{{- end}}{{/* range .Messages */}}
26+
27+
{{range .Enums}}
28+
<a name="{{.FullName | anchor}}"></a>
29+
30+
### {{.LongName}}
31+
{{.Description}}
32+
33+
| Name | Number | Description |
34+
| ---- | ------ | ----------- |
35+
{{range .Values -}}
36+
| {{.Name}} | {{.Number}} | {{nobr .Description}} |
37+
{{end}}
38+
39+
{{end}}
40+
41+
{{- end}}{{/* range .Files */}}
42+
43+
## Scalar Value Types
44+
45+
| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |
46+
| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- |
47+
{{range .Scalars -}}
48+
| <a name="{{.ProtoType | anchor}}" /> {{.ProtoType}} | {{.Notes}} | {{.CppType}} | {{.JavaType}} | {{.PythonType}} | {{.GoType}} | {{.CSharp}} | {{.PhpType}} | {{.RubyType}} |
49+
{{end}}

protoc-gen-doc.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ echo "Generating Markdown documentation $(pwd)/docs/markdown/protocol.md"
44
docker run --rm \
55
-v $(pwd)/docs/markdown:/out \
66
-v $(pwd)/protobuf_definitions:/protos \
7-
pseudomuto/protoc-gen-doc --doc_opt=markdown,protocol.md
7+
-v $(pwd)/markdown.tmpl:/markdown.tmpl \
8+
pseudomuto/protoc-gen-doc --doc_opt=markdown.tmpl,protocol.md
89

910
echo "Generating HTML documentation $(pwd)/docs/html/protocol.html"
1011
docker run --rm \

0 commit comments

Comments
 (0)