https://github.com/tmc/protoc-gen-d2
protoc-gen-d2
https://github.com/tmc/protoc-gen-d2
Last synced: about 1 year ago
JSON representation
protoc-gen-d2
- Host: GitHub
- URL: https://github.com/tmc/protoc-gen-d2
- Owner: tmc
- License: mit
- Created: 2023-08-21T06:33:25.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-01T01:30:37.000Z (over 2 years ago)
- Last Synced: 2025-03-24T09:47:15.379Z (over 1 year ago)
- Language: Go
- Size: 104 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# protoc-gen-d2
This project is a protoc plugin to render a d2 diagrams of protobuf packages.
Example:

is rendered from
[./testdata/acme/test/v1/test.proto](./testdata/acme/test/v1/test.proto)
```proto
syntax = "proto3";
package acme.test.v1;
// Sample service for our test proto.
service TestService {
// GetTestMessage retrieves a TestMessage
rpc GetTestMessage (GetTestMessageRequest) returns (GetTestMessageResponse);
// CreateTestMessage creates a new TestMessage.
rpc CreateTestMessage (CreateTestMessageRequest) returns (CreateTestMessageResponse);
}
// Status enumeration.
enum Status {
STATUS_UNSPECIFIED = 0;
STATUS_ACTIVE = 1;
STATUS_INACTIVE = 2;
}
// Address nested message.
message Address {
string street = 1;
string city = 2;
string state = 3;
string country = 4;
}
// Sample message representing our test proto.
message TestMessage {
string id = 1;
string name = 2;
repeated string items = 3;
Status status = 4; // Enumeration field
Address address = 5; // Nested message
map metadata = 6; // Map field
oneof payload { // Oneof field
string text_payload = 7;
bytes binary_payload = 8;
}
}
// GetTestMessageRequest is the request for GetTestMessage.
message GetTestMessageRequest {
string id = 1;
}
// GetTestMessageResponse is the response for GetTestMessage.
message GetTestMessageResponse {
TestMessage message = 1;
}
// CreateTestMessageRequest is the request for CreateTestMessage.
message CreateTestMessageRequest {
TestMessage message = 1;
}
// CreateTestMessageResponse is the response for CreateTestMessage.
message CreateTestMessageResponse {
TestMessage message = 1;
}
```