transforming your .proto
files into .dot
files (and .svg
, .png
if you happen to have graphviz
installed)
you can find an online demo of this tool here
you can download the sources (from this page) and build protodot
yourself, or
you can download pre-built binaries for a few selected environments (or from here):
protodot
output is highly customizable through its configuration file and a set of templates files.
if you installed protodot
from the binary distribution - you may want to extract aforementioned files by running:
./protodot -install
-src what.proto
- location and name of the source file, required-config config.json
- location and name of the configuration file, optional-select .one.two;three.four
- name(s) of the selected elements to show, optional, explained later in this document-output save-it-here
- name of the output file, optional-inc /abc/def;/xyz
- (semicolon separated) list of the include directories, optionaltbd
sometimes the resulting diagram can be overwhelming.
you have an option to limit the output to the elements that interest you the most, hence -select args
command line option.
so far, args
in -select args
can take one of the three available forms:
;
). the elements can be enums
, messages
, rpc
methods and services
.*
as an argument - this will result in the inclusion of the elements declared in the main .proto
file (specified in -src
argument) and their dependencies. in other words: all the unused elements declared in all the included .proto
files will not be shown.imports
as an argument - protodot
will generate import dependency graph (see an example below)-select
optionsusing https://github.com/googleapis/googleapis/blob/master/google/privacy/dlp/v2/dlp.proto
as the source
-select
everything declared in the root .proto
file and all the imports
will be produced:
-select *
only elements declared in the root .proto
file and their dependencies will be produced:
-select imports
only imports
dependency graph will be produced:
-select .ListDlpJobs
in this particular case, the name of the rpc
method was specified: this will result in production of the requested rpc
method, it's encompasing service
element and all the dependencied of the method:
-select .AnalyzeDataSourceRiskDetails
same as above, but instead of rpc
method, name of the message
was specified:
.svg
and/or .png
images from produced .dot
filegraphviz
(see https://graphviz.gitlab.io/download/ for the instructions)dot
utility (which is a part of graphviz)
in your version of configuration file, e.g.
{
"locations": {
"graphviz": "/path/to/dot",
options
in your version of configuration file, e.g.
{
"options" : {
"generate .png file": false,
"generate .svg file": true,