protoc-gen-pu
protoc plugin to generate a plant UML class diagram.
prerequisites
- go ~> v1.19
- protoc ~> 3.15
install
go install github.com/lp-peg/protoc-gen-pu@latest
usage
protoc --pu_out=. testdata/pet.proto
then, you can see diagram as below:
options
You can use these plugin options.
Pass option via --pu_opt
flag.
option key |
description |
default |
out |
output file name |
out.pu |
skinparams |
skin param. Required format is <param>:<value> . You can pass this opt multiple times. |
"linetype:ortho" |
circle |
hide or show circle |
hide |
example:
❯ protoc -Itestdata \
--pu_opt=out=pet.pu \
--pu_opt=skinparams=linetype:ortho \
--pu_opt=skinparams=classFontSize:10 \
--pu_opt=circle=show \
--pu_out=. \
testdata/pet.proto
@startuml
skinparam linetype ortho
skinparam classFontSize 10
entity Pet {
name (STRING)
age (INT32)
animal (Animal<FK>)
}
entity Animal {
name (STRING)
category (AnimalCategory<FK>)
}
entity AnimalCategory {
UNSPECIFIED (ENUM: 0)
DOG (ENUM: 1)
CAT (ENUM: 2)
COW (ENUM: 3)
BEAR (ENUM: 4)
}
Animal <-- Pet
AnimalCategory <-- Animal
@enduml