Skip to content

Commit ab870f9

Browse files
committed
markdown: put Services first
1 parent bc76cf3 commit ab870f9

File tree

2 files changed

+110
-110
lines changed

2 files changed

+110
-110
lines changed

parse/markdown.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ func (p *Proto) Markdown(title, fpath string, lopts ...string) error {
2828
buf := new(bytes.Buffer)
2929
buf.WriteString(fmt.Sprintf("### %s\n\n\n", title))
3030

31+
for _, svs := range p.Services {
32+
buf.WriteString(fmt.Sprintf("##### service `%s`\n\n", svs.Name))
33+
if svs.Description != "" {
34+
buf.WriteString(svs.Description)
35+
buf.WriteString("\n\n")
36+
}
37+
hd1 := "| Method | Request Type | Response Type | Description |"
38+
hd2 := "| ------ | ------------ | ------------- | ----------- |"
39+
buf.WriteString(hd1 + "\n")
40+
buf.WriteString(hd2 + "\n")
41+
42+
for _, elem := range svs.Methods {
43+
line := fmt.Sprintf("| %s | `%s` | `%s` | %s |", elem.Name, elem.RequestType, elem.ResponseType, elem.Description)
44+
buf.WriteString(line + "\n")
45+
}
46+
buf.WriteString("\n\n<br>\n\n")
47+
}
48+
3149
for _, msg := range p.Messages {
3250
buf.WriteString(fmt.Sprintf("##### message `%s`\n\n", msg.Name))
3351
if msg.Description != "" {
@@ -86,23 +104,5 @@ func (p *Proto) Markdown(title, fpath string, lopts ...string) error {
86104
buf.WriteString("\n\n<br>\n\n")
87105
}
88106

89-
for _, svs := range p.Services {
90-
buf.WriteString(fmt.Sprintf("##### service `%s`\n\n", svs.Name))
91-
if svs.Description != "" {
92-
buf.WriteString(svs.Description)
93-
buf.WriteString("\n\n")
94-
}
95-
hd1 := "| Method | Request Type | Response Type | Description |"
96-
hd2 := "| ------ | ------------ | ------------- | ----------- |"
97-
buf.WriteString(hd1 + "\n")
98-
buf.WriteString(hd2 + "\n")
99-
100-
for _, elem := range svs.Methods {
101-
line := fmt.Sprintf("| %s | `%s` | `%s` | %s |", elem.Name, elem.RequestType, elem.ResponseType, elem.Description)
102-
buf.WriteString(line + "\n")
103-
}
104-
buf.WriteString("\n\n<br>\n\n")
105-
}
106-
107107
return toFile(buf.String(), fpath)
108108
}

parse/testdata/README.md

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,86 @@
11
### etcdserverpb
22

33

4+
##### service `Auth`
5+
6+
| Method | Request Type | Response Type | Description |
7+
| ------ | ------------ | ------------- | ----------- |
8+
| AuthEnable | `AuthEnableRequest` | `AuthEnableResponse` | AuthEnable enables authentication. |
9+
| AuthDisable | `AuthDisableRequest` | `AuthDisableResponse` | AuthDisable disables authentication. |
10+
| Authenticate | `AuthenticateRequest` | `AuthenticateResponse` | Authenticate processes authenticate request. |
11+
| UserAdd | `AuthUserAddRequest` | `AuthUserAddResponse` | UserAdd adds a new user. |
12+
| UserGet | `AuthUserGetRequest` | `AuthUserGetResponse` | UserGet gets a detailed information of a user or lists entire users. |
13+
| UserDelete | `AuthUserDeleteRequest` | `AuthUserDeleteResponse` | UserDelete deletes a specified user. |
14+
| UserChangePassword | `AuthUserChangePasswordRequest` | `AuthUserChangePasswordResponse` | UserChangePassword changes password of a specified user. |
15+
| UserGrant | `AuthUserGrantRequest` | `AuthUserGrantResponse` | UserGrant grants a role to a specified user. |
16+
| UserRevoke | `AuthUserRevokeRequest` | `AuthUserRevokeResponse` | UserRevoke revokes a role of specified user. |
17+
| RoleAdd | `AuthRoleAddRequest` | `AuthRoleAddResponse` | RoleAdd adds a new role. |
18+
| RoleGet | `AuthRoleGetRequest` | `AuthRoleGetResponse` | RoleGet gets a detailed information of a role or lists entire roles. |
19+
| RoleDelete | `AuthRoleDeleteRequest` | `AuthRoleDeleteResponse` | RoleDelete deletes a specified role. |
20+
| RoleGrant | `AuthRoleGrantRequest` | `AuthRoleGrantResponse` | RoleGrant grants a permission of a specified key or range to a specified role. |
21+
| RoleRevoke | `AuthRoleRevokeRequest` | `AuthRoleRevokeResponse` | RoleRevoke revokes a key or range permission of a specified role. |
22+
23+
24+
<br>
25+
26+
##### service `Cluster`
27+
28+
| Method | Request Type | Response Type | Description |
29+
| ------ | ------------ | ------------- | ----------- |
30+
| MemberAdd | `MemberAddRequest` | `MemberAddResponse` | MemberAdd adds a member into the cluster. |
31+
| MemberRemove | `MemberRemoveRequest` | `MemberRemoveResponse` | MemberRemove removes an existing member from the cluster. |
32+
| MemberUpdate | `MemberUpdateRequest` | `MemberUpdateResponse` | MemberUpdate updates the member configuration. |
33+
| MemberList | `MemberListRequest` | `MemberListResponse` | MemberList lists all the members in the cluster. |
34+
35+
36+
<br>
37+
38+
##### service `KV`
39+
40+
| Method | Request Type | Response Type | Description |
41+
| ------ | ------------ | ------------- | ----------- |
42+
| Range | `RangeRequest` | `RangeResponse` | Range gets the keys in the range from the store. |
43+
| Put | `PutRequest` | `PutResponse` | Put puts the given key into the store. A put request increases the revision of the store, and generates one event in the event history. |
44+
| DeleteRange | `DeleteRangeRequest` | `DeleteRangeResponse` | Delete deletes the given range from the store. A delete request increase the revision of the store, and generates one event in the event history. |
45+
| Txn | `TxnRequest` | `TxnResponse` | Txn processes all the requests in one transaction. A txn request increases the revision of the store, and generates events with the same revision in the event history. It is not allowed to modify the same key several times within one txn. |
46+
| Compact | `CompactionRequest` | `CompactionResponse` | Compact compacts the event history in etcd. User should compact the event history periodically, or it will grow infinitely. |
47+
48+
49+
<br>
50+
51+
##### service `Lease`
52+
53+
| Method | Request Type | Response Type | Description |
54+
| ------ | ------------ | ------------- | ----------- |
55+
| LeaseGrant | `LeaseGrantRequest` | `LeaseGrantResponse` | LeaseGrant creates a lease. A lease has a TTL. The lease will expire if the server does not receive a keepAlive within TTL from the lease holder. All keys attached to the lease will be expired and deleted if the lease expires. The key expiration generates an event in event history. |
56+
| LeaseRevoke | `LeaseRevokeRequest` | `LeaseRevokeResponse` | LeaseRevoke revokes a lease. All the key attached to the lease will be expired and deleted. |
57+
| LeaseKeepAlive | `LeaseKeepAliveRequest` | `LeaseKeepAliveResponse` | KeepAlive keeps the lease alive. |
58+
59+
60+
<br>
61+
62+
##### service `Maintenance`
63+
64+
| Method | Request Type | Response Type | Description |
65+
| ------ | ------------ | ------------- | ----------- |
66+
| Alarm | `AlarmRequest` | `AlarmResponse` | Alarm activates, deactivates, and queries alarms regarding cluster health. |
67+
| Status | `StatusRequest` | `StatusResponse` | Status gets the status of the member. |
68+
| Defragment | `DefragmentRequest` | `DefragmentResponse` | |
69+
| Hash | `HashRequest` | `HashResponse` | Hash returns the hash of the local KV state for consistency checking purpose. This is designed for testing; do not use this in production when there are ongoing transactions. |
70+
| Snapshot | `SnapshotRequest` | `SnapshotResponse` | Snapshot sends a snapshot of the entire backend |
71+
72+
73+
<br>
74+
75+
##### service `Watch`
76+
77+
| Method | Request Type | Response Type | Description |
78+
| ------ | ------------ | ------------- | ----------- |
79+
| Watch | `WatchRequest` | `WatchResponse` | Watch watches the events happening or happened. Both input and output are stream. One watch rpc can watch for multiple keys or prefixs and get a stream of events. The whole events history can be watched unless compacted. |
80+
81+
82+
<br>
83+
484
##### message `AlarmMember`
585

686
| Field | Description | Type | Go | Java | Python | C++ |
@@ -27,7 +107,7 @@
27107
| Field | Description | Type | Go | Java | Python | C++ |
28108
| ----- | ----------- | ---- | --- | ---- | ------ | --- |
29109
| header | | ResponseHeader | | | | |
30-
| alarms | | slice of AlarmMember | | | | |
110+
| alarms | | (slice of) AlarmMember | | | | |
31111

32112

33113
<br>
@@ -473,8 +553,8 @@ An InternalRaftRequest is the union of all requests which can be sent via raft.
473553
| ----- | ----------- | ---- | --- | ---- | ------ | --- |
474554
| ID | | uint64 | uint64 | long | int/long | uint64 |
475555
| name | If the member is not started, name will be an empty string. | string | string | String | str/unicode | string |
476-
| peerURLs | | slice of string | []string | []String | []str/unicode | []string |
477-
| clientURLs | If the member is not started, client_URLs will be an zero length string array. | slice of string | []string | []String | []str/unicode | []string |
556+
| peerURLs | | (slice of) string | (slice of) string | (slice of) String | (slice of) str/unicode | (slice of) string |
557+
| clientURLs | If the member is not started, client_URLs will be an zero length string array. | (slice of) string | (slice of) string | (slice of) String | (slice of) str/unicode | (slice of) string |
478558

479559

480560
<br>
@@ -483,7 +563,7 @@ An InternalRaftRequest is the union of all requests which can be sent via raft.
483563

484564
| Field | Description | Type | Go | Java | Python | C++ |
485565
| ----- | ----------- | ---- | --- | ---- | ------ | --- |
486-
| peerURLs | | slice of string | []string | []String | []str/unicode | []string |
566+
| peerURLs | | (slice of) string | (slice of) string | (slice of) String | (slice of) str/unicode | (slice of) string |
487567

488568

489569
<br>
@@ -511,7 +591,7 @@ An InternalRaftRequest is the union of all requests which can be sent via raft.
511591
| Field | Description | Type | Go | Java | Python | C++ |
512592
| ----- | ----------- | ---- | --- | ---- | ------ | --- |
513593
| header | | ResponseHeader | | | | |
514-
| members | | slice of Member | | | | |
594+
| members | | (slice of) Member | | | | |
515595

516596

517597
<br>
@@ -539,7 +619,7 @@ An InternalRaftRequest is the union of all requests which can be sent via raft.
539619
| Field | Description | Type | Go | Java | Python | C++ |
540620
| ----- | ----------- | ---- | --- | ---- | ------ | --- |
541621
| ID | | uint64 | uint64 | long | int/long | uint64 |
542-
| peerURLs | | slice of string | []string | []String | []str/unicode | []string |
622+
| peerURLs | | (slice of) string | (slice of) string | (slice of) String | (slice of) str/unicode | (slice of) string |
543623

544624

545625
<br>
@@ -603,7 +683,7 @@ An InternalRaftRequest is the union of all requests which can be sent via raft.
603683
| Field | Description | Type | Go | Java | Python | C++ |
604684
| ----- | ----------- | ---- | --- | ---- | ------ | --- |
605685
| header | | ResponseHeader | | | | |
606-
| kvs | | slice of storagepb.KeyValue | | | | |
686+
| kvs | | (slice of) storagepb.KeyValue | | | | |
607687
| more | more indicates if there are more keys to return in the requested range. | bool | bool | boolean | boolean | bool |
608688

609689

@@ -717,9 +797,9 @@ If the comparisons succeed, then the success requests will be processed in order
717797

718798
| Field | Description | Type | Go | Java | Python | C++ |
719799
| ----- | ----------- | ---- | --- | ---- | ------ | --- |
720-
| compare | | slice of Compare | | | | |
721-
| success | | slice of RequestUnion | | | | |
722-
| failure | | slice of RequestUnion | | | | |
800+
| compare | | (slice of) Compare | | | | |
801+
| success | | (slice of) RequestUnion | | | | |
802+
| failure | | (slice of) RequestUnion | | | | |
723803

724804

725805
<br>
@@ -730,7 +810,7 @@ If the comparisons succeed, then the success requests will be processed in order
730810
| ----- | ----------- | ---- | --- | ---- | ------ | --- |
731811
| header | | ResponseHeader | | | | |
732812
| succeeded | | bool | bool | boolean | boolean | bool |
733-
| responses | | slice of ResponseUnion | | | | |
813+
| responses | | (slice of) ResponseUnion | | | | |
734814

735815

736816
<br>
@@ -776,87 +856,7 @@ If the comparisons succeed, then the success requests will be processed in order
776856
| created | If the response is for a create watch request, created is set to true. Client should record the watch_id and prepare for receiving events for that watching from the same stream. All events sent to the created watching will attach with the same watch_id. | bool | bool | boolean | boolean | bool |
777857
| canceled | If the response is for a cancel watch request, cancel is set to true. No further events will be sent to the canceled watching. | bool | bool | boolean | boolean | bool |
778858
| compact_revision | CompactRevision is set to the minimum index if a watching tries to watch at a compacted index. This happens when creating a watching at a compacted revision or the watching cannot catch up with the progress of the KV. Client should treat the watching as canceled and should not try to create any watching with same start_revision again. | int64 | int64 | long | int/long | int64 |
779-
| events | | slice of storagepb.Event | | | | |
780-
781-
782-
<br>
783-
784-
##### service `Auth`
785-
786-
| Method | Request Type | Response Type | Description |
787-
| ------ | ------------ | ------------- | ----------- |
788-
| AuthEnable | `AuthEnableRequest` | `AuthEnableResponse` | AuthEnable enables authentication. |
789-
| AuthDisable | `AuthDisableRequest` | `AuthDisableResponse` | AuthDisable disables authentication. |
790-
| Authenticate | `AuthenticateRequest` | `AuthenticateResponse` | Authenticate processes authenticate request. |
791-
| UserAdd | `AuthUserAddRequest` | `AuthUserAddResponse` | UserAdd adds a new user. |
792-
| UserGet | `AuthUserGetRequest` | `AuthUserGetResponse` | UserGet gets a detailed information of a user or lists entire users. |
793-
| UserDelete | `AuthUserDeleteRequest` | `AuthUserDeleteResponse` | UserDelete deletes a specified user. |
794-
| UserChangePassword | `AuthUserChangePasswordRequest` | `AuthUserChangePasswordResponse` | UserChangePassword changes password of a specified user. |
795-
| UserGrant | `AuthUserGrantRequest` | `AuthUserGrantResponse` | UserGrant grants a role to a specified user. |
796-
| UserRevoke | `AuthUserRevokeRequest` | `AuthUserRevokeResponse` | UserRevoke revokes a role of specified user. |
797-
| RoleAdd | `AuthRoleAddRequest` | `AuthRoleAddResponse` | RoleAdd adds a new role. |
798-
| RoleGet | `AuthRoleGetRequest` | `AuthRoleGetResponse` | RoleGet gets a detailed information of a role or lists entire roles. |
799-
| RoleDelete | `AuthRoleDeleteRequest` | `AuthRoleDeleteResponse` | RoleDelete deletes a specified role. |
800-
| RoleGrant | `AuthRoleGrantRequest` | `AuthRoleGrantResponse` | RoleGrant grants a permission of a specified key or range to a specified role. |
801-
| RoleRevoke | `AuthRoleRevokeRequest` | `AuthRoleRevokeResponse` | RoleRevoke revokes a key or range permission of a specified role. |
802-
803-
804-
<br>
805-
806-
##### service `Cluster`
807-
808-
| Method | Request Type | Response Type | Description |
809-
| ------ | ------------ | ------------- | ----------- |
810-
| MemberAdd | `MemberAddRequest` | `MemberAddResponse` | MemberAdd adds a member into the cluster. |
811-
| MemberRemove | `MemberRemoveRequest` | `MemberRemoveResponse` | MemberRemove removes an existing member from the cluster. |
812-
| MemberUpdate | `MemberUpdateRequest` | `MemberUpdateResponse` | MemberUpdate updates the member configuration. |
813-
| MemberList | `MemberListRequest` | `MemberListResponse` | MemberList lists all the members in the cluster. |
814-
815-
816-
<br>
817-
818-
##### service `KV`
819-
820-
| Method | Request Type | Response Type | Description |
821-
| ------ | ------------ | ------------- | ----------- |
822-
| Range | `RangeRequest` | `RangeResponse` | Range gets the keys in the range from the store. |
823-
| Put | `PutRequest` | `PutResponse` | Put puts the given key into the store. A put request increases the revision of the store, and generates one event in the event history. |
824-
| DeleteRange | `DeleteRangeRequest` | `DeleteRangeResponse` | Delete deletes the given range from the store. A delete request increase the revision of the store, and generates one event in the event history. |
825-
| Txn | `TxnRequest` | `TxnResponse` | Txn processes all the requests in one transaction. A txn request increases the revision of the store, and generates events with the same revision in the event history. It is not allowed to modify the same key several times within one txn. |
826-
| Compact | `CompactionRequest` | `CompactionResponse` | Compact compacts the event history in etcd. User should compact the event history periodically, or it will grow infinitely. |
827-
828-
829-
<br>
830-
831-
##### service `Lease`
832-
833-
| Method | Request Type | Response Type | Description |
834-
| ------ | ------------ | ------------- | ----------- |
835-
| LeaseGrant | `LeaseGrantRequest` | `LeaseGrantResponse` | LeaseGrant creates a lease. A lease has a TTL. The lease will expire if the server does not receive a keepAlive within TTL from the lease holder. All keys attached to the lease will be expired and deleted if the lease expires. The key expiration generates an event in event history. |
836-
| LeaseRevoke | `LeaseRevokeRequest` | `LeaseRevokeResponse` | LeaseRevoke revokes a lease. All the key attached to the lease will be expired and deleted. |
837-
| LeaseKeepAlive | `LeaseKeepAliveRequest` | `LeaseKeepAliveResponse` | KeepAlive keeps the lease alive. |
838-
839-
840-
<br>
841-
842-
##### service `Maintenance`
843-
844-
| Method | Request Type | Response Type | Description |
845-
| ------ | ------------ | ------------- | ----------- |
846-
| Alarm | `AlarmRequest` | `AlarmResponse` | Alarm activates, deactivates, and queries alarms regarding cluster health. |
847-
| Status | `StatusRequest` | `StatusResponse` | Status gets the status of the member. |
848-
| Defragment | `DefragmentRequest` | `DefragmentResponse` | |
849-
| Hash | `HashRequest` | `HashResponse` | Hash returns the hash of the local KV state for consistency checking purpose. This is designed for testing; do not use this in production when there are ongoing transactions. |
850-
| Snapshot | `SnapshotRequest` | `SnapshotResponse` | Snapshot sends a snapshot of the entire backend |
851-
852-
853-
<br>
854-
855-
##### service `Watch`
856-
857-
| Method | Request Type | Response Type | Description |
858-
| ------ | ------------ | ------------- | ----------- |
859-
| Watch | `WatchRequest` | `WatchResponse` | Watch watches the events happening or happened. Both input and output are stream. One watch rpc can watch for multiple keys or prefixs and get a stream of events. The whole events history can be watched unless compacted. |
859+
| events | | (slice of) storagepb.Event | | | | |
860860

861861

862862
<br>

0 commit comments

Comments
 (0)