Skip to content

Commit

Permalink
chore(grpc): update gRPC document (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f authored Jun 19, 2024
1 parent 586e9f2 commit 203a8a0
Show file tree
Hide file tree
Showing 20 changed files with 5,514 additions and 10,544 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ devtools:
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go install github.com/NathanBaulch/[email protected]
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@v1.5
go install github.com/pactus-project/protoc-gen-doc/cmd/protoc-gen-doc@master
go install github.com/bufbuild/buf/cmd/[email protected]
go install mvdan.cc/gofumpt@latest
go install github.com/rakyll/[email protected]
Expand Down
13 changes: 1 addition & 12 deletions www/grpc/buf/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ plugins:
- ./grpc-md.tmpl,grpc.md
- name: doc
out: ../gen/docs
opt:
- markdown,index.md
- name: doc
out: ../gen/docs
opt:
- html,index.html
opt: ./json-rpc-md.tmpl,json-rpc.md
- name: go-grpc
out: ../gen/go
opt: paths=source_relative,require_unimplemented_servers=false
Expand All @@ -34,12 +29,6 @@ plugins:
- openapi_configuration=openapi.config.yaml
- name: jrpc-gateway
out: ../gen/go
- name: jrpc-doc
out: ../gen/docs
opt: ./json-rpc-md.tmpl,json-rpc.md
- name: jrpc-doc
out: ../gen/docs
opt: ./json-rpc-html.tmpl,json-rpc.html
- plugin: buf.build/protocolbuffers/js:v3.21.2
out: ../gen/js
opt:
Expand Down
201 changes: 133 additions & 68 deletions www/grpc/buf/grpc-md.tmpl
Original file line number Diff line number Diff line change
@@ -1,110 +1,175 @@
{{/* This template generates gRPC document for https://pactus.org/ */}}---
layout: learn
title: gRPC API Reference
sidebar: gRPC API Reference
title: GRPC API Reference
weight: 1
---

<h1 id="title">gRPC API Reference</h1>

Each node in the Pactus network can be configured to use the [gRPC](https://grpc.io/) protocol for communication.
Here you can find the list of all gRPC methods and messages.

All the amounts and values in gRPC endpoints are in NanoPAC units, which are atomic and the smallest unit in the Pactus blockchain.
Each PAC is equivalent to 1,000,000,000 or 10<sup>9</sup> NanoPACs.

<h2>Table of Contents</h2>
<h2>gRPC Services</h2>

<div id="toc-container">
<ul class="">{{range .Files}} {{range .Services}}
<ul class="">
{{range .Files}}{{- print "" -}}
{{range .Services}}{{- print "" -}}
<li> {{.Name}} Service
<ul> {{$service_name := .FullName}} {{range .Methods}}
<ul> {{$service_name := .FullName}}
{{range .Methods}}{{- print "" -}}
<li>
<a href="#{{$service_name}}.{{.Name}}">
<span class="badge text-bg-primary">rpc</span> {{.Name}}</a>
</li> {{end}}
</ul>
</li>{{end}} {{end}}
<li>Messages and Enums
<ul>{{range .Files}} {{range .Messages}}
<li>
<a href="#{{.FullName}}">
<span class="badge text-bg-secondary">msg</span> {{.LongName}}
</a>
</li> {{end}} {{end}}
{{range .Files}} {{range .Enums}}
<li>
<a href="#{{.FullName}}">
<span class="badge text-bg-info">enum</span> {{.LongName}}
</a>
</li>{{end}} {{end}}
<li>
<a href="#scalar-value-types">Scalar Value Types</a>
<span class="rpc-badge"></span> {{.Name}}</a>
</li>
{{end}}{{- print "" -}}
</ul>
</li>
{{end}}{{- print "" -}}
{{end}}{{- print "" -}}
</ul>
</div>
{{range .Files}} {{$file_name := .Name}} {{range .Services}}
<h2>{{.Name}} Service <span class="badge text-bg-warning fs-6 align-top">{{ $file_name }}</span></h2>
{{p .Description}} {{$service_name := .FullName}} {{range .Methods}}
<h3 id="{{$service_name}}.{{.Name}}">{{.Name}} <span class="badge text-bg-primary fs-6 align-top">rpc</span></h3>
<div class="request pt-3">Request message: <a href="#{{.RequestFullType}}">{{.RequestLongType}}</a></div>
<div class="response pb-3">Response message: <a href="#{{.ResponseFullType}}">{{.ResponseLongType}}</a></div>
{{p .Description}} {{end}} {{end}} {{end}}
<h2>Messages and Enums</h2>{{range .Files}} {{range .Messages}}
<h3 id="{{.FullName}}">
{{.LongName}}
<span class="badge text-bg-secondary fs-6 align-top">msg</span>
</h3>
{{p .Description}}
{{if .HasFields}}
<table class="table table-bordered table-sm">

<div class="api-doc">
{{range .Files}}{{range .Services}}{{- print "\n" -}}

## {{.Name}} Service

{{p .Description}}
{{$service_name := .FullName}}{{range .Methods}}{{- print "\n" -}}

### {{.Name}} <span id="{{$service_name}}.{{.Name}}" class="rpc-badge"></span>

{{p .Description}}

<h4>{{.RequestLongType}} <span class="badge text-bg-info fs-6 align-top">Request</span></h4>

{{with getMessage .RequestLongType }}{{- print "" -}}
{{if .HasFields}}{{- print "" -}}
<table class="table table-bordered table-responsive table-sm">
<thead>
<tr><td>Field</td><td>Type</td><td>Description</td></tr>
</thead>
<tbody class="table-group-divider">
{{range .Fields}}<tr>
<td class="fw-bold">{{.Name}}</td>
<td>{{.Label}}
<a href="#{{.FullType}}">{{.LongType}}</a>
</td>
<td>{{if (index .Options "deprecated"|default false)}}<strong>Deprecated.</strong> {{end}}{{.Description}} {{if .DefaultValue}}Default: {{.DefaultValue}}{{end}}</td>
</tr>{{end}}
{{range .Fields}}{{- print "" -}}
<tr>
<td class="fw-bold">{{.Name}}</td>
<td>{{.Label}} {{.LongType}}</td>
<td>
{{if .IsEnum}}(Enum) {{end}}{{- print "" -}}
{{if .IsOneOf}}(OneOf) {{end}}{{- print "" -}}
{{if (index .Options "deprecated"|default false)}}<strong>(Deprecated) </strong>{{end}}{{- print "" -}}
{{.Description}}
{{if .DefaultValue}}Default: {{.DefaultValue}}{{end}}{{- print "" -}}
{{with getEnum .LongType }}{{- print "" -}}
<br>Available values:<ul>
{{range .Values}}{{- print "" -}}
<li>{{ .Name}} = {{ .Description }}</li>
{{end}}{{- print "" -}}
</ul>
{{end}}{{- print "" -}}
</td>
</tr>
{{end}}{{- print "" -}}
</tbody>
</table> {{else}} Message has no fields. {{end}} {{end}} {{end}}
{{range .Files}} {{range .Enums}}
<h3 id="{{.FullName}}">
{{.LongName}}
<span class="badge text-bg-info fs-6 align-top">enum</span>
</h3>
{{p .Description}}
<table class="table table-bordered table-sm">
</table>
{{else}}{{- print "" -}}
Message has no fields.
{{end}}{{- print "" -}}
{{end}}{{- print "" -}}

<h4>{{.ResponseLongType}} <span class="badge text-bg-warning fs-6 align-top">Response</span></h4>

{{with getMessage .ResponseLongType }}{{- print "" -}}
<table class="table table-bordered table-responsive table-sm">
<thead>
<tr><td>Name</td><td>Number</td><td>Description</td></tr>
<tr><td>Field</td><td>Type</td><td>Description</td></tr>
</thead>
<tbody class="table-group-divider">
{{range .Values}}<tr>
<td class="fw-bold">{{.Name}}</td>
<td>{{.Number}}</td>
<td>{{.Description}}</td>
</tr>{{end}}
{{range .Fields}}{{- print "" -}}
<tr>
<td class="fw-bold">{{.Name}}</td>
<td>{{.Label}} {{.LongType}}</td>
<td>
{{if .IsEnum}}(Enum) {{end}}{{- print "" -}}
{{if .IsOneOf}}(OneOf) {{end}}{{- print "" -}}
{{if (index .Options "deprecated"|default false)}}<strong>(Deprecated) </strong>{{end}}{{- print "" -}}
{{.Description}}
{{if .DefaultValue}}Default: {{.DefaultValue}}{{end}}{{- print "" -}}
{{with getEnum .LongType }}{{- print "" -}}
<br>Available values:<ul>
{{range .Values}}{{- print "" -}}
<li>{{ .Name}} = {{ .Description }}</li>
{{end}}{{- print "" -}}
</ul>
{{end}}{{- print "" -}}
</td>
</tr>
{{$msg0 := .}} {{with getMessage .LongType }}{{- print "" -}}
{{range .Fields}}{{- print "" -}}
<tr>
<td class="fw-bold">{{$msg0.Name}}{{if $msg0.IsRepeated}}[]{{end}}.{{.Name}}</td>
<td>{{.Label}} {{.LongType}}</td>
<td>
{{if .IsEnum}}(Enum) {{end}}{{- print "" -}}
{{if .IsOneOf}}(OneOf) {{end}}{{- print "" -}}
{{if (index .Options "deprecated"|default false)}}<strong>(Deprecated) </strong>{{end}}{{- print "" -}}
{{.Description}}
{{if .DefaultValue}}Default: {{.DefaultValue}}{{end}}{{- print "" -}}
{{with getEnum .LongType }}{{- print "" -}}
<br>Available values:<ul>
{{range .Values}}{{- print "" -}}
<li>{{ .Name}} = {{ .Description }}</li>
{{end}}{{- print "" -}}
</ul>
{{end}}{{- print "" -}}
</td>
</tr>
{{$msg1 := .}} {{with getMessage .LongType }}{{- print "" -}}
{{range .Fields}}{{- print "" -}}
<tr>
<td class="fw-bold">{{$msg0.Name}}{{if $msg0.IsRepeated}}[]{{end}}.{{$msg1.Name}}{{if $msg1.IsRepeated}}[]{{end}}.{{.Name}}</td>
<td>{{.Label}} {{.LongType}}</td>
<td>
{{if .IsEnum}}(Enum) {{end}}{{- print "" -}}
{{if .IsOneOf}}(OneOf) {{end}}{{- print "" -}}
{{if (index .Options "deprecated"|default false)}}<strong>(Deprecated) </strong>{{end}}{{- print "" -}}
{{.Description}}
{{if .DefaultValue}}Default: {{.DefaultValue}}{{end}}{{- print "" -}}
{{with getEnum .LongType }}{{- print "" -}}
<br>Available values:<ul>
{{range .Values}}{{- print "" -}}
<li>{{ .Name}} = {{ .Description }}</li>
{{end}}{{- print "" -}}
</ul>
{{end}}{{- print "" -}}
</td>
</tr>
{{end}}{{- print "" -}}
{{end}}{{- print "" -}}
{{end}}{{- print "" -}}
{{end}}{{- print "" -}}
{{end}}{{- print "" -}}
</tbody>
</table> {{end}} {{end}}
{{end}}{{- print "" -}}
</table>
{{end}}{{end}}{{end}}{{- print "\n" -}}

## Scalar Value Types

<h3 id="scalar-value-types">Scalar Value Types</h3>
<table class="table table-bordered table-sm">
<thead>
<tr><td>.proto Type</td><td>C++</td><td>Java</td><td>Python</td><td>Go</td><td>C#</td><td>PHP</td></tr>
<tr><td>.proto Type</td><td>Go</td><td>C++</td><td>Rust</td><td>Java</td><td>Python</td><td>C#</td></tr>
</thead>
<tbody class="table-group-divider"> {{range .Scalars}}
<tr id="{{.ProtoType}}">
<td class="fw-bold">{{.ProtoType}}</td>
<td>{{.GoType}}</td>
<td>{{.CppType}}</td>
<td>{{.RustType}}</td>
<td>{{.JavaType}}</td>
<td>{{.PythonType}}</td>
<td>{{.GoType}}</td>
<td>{{.CSharp}}</td>
<td>{{.PhpType}}</td>
</tr> {{end}}
</tbody>
</table>
46 changes: 0 additions & 46 deletions www/grpc/buf/json-rpc-html.tmpl

This file was deleted.

Loading

0 comments on commit 203a8a0

Please sign in to comment.