pseudomuto / protoc-gen-doc

Documentation generator plugin for Google Protocol Buffers
MIT License
2.66k stars 463 forks source link

How to use the `docs_out` flag rather than `doc_out` #539

Open Ekrekr opened 3 months ago

Ekrekr commented 3 months ago

I want to generate our protobuf documentation in camelCase rather than snake_case.

It seems to come down to the plugin trying to use protoc-gen-docs rather than protoc-gen-doc in the docker image. I'm a bit confused about the relationship between the two packages, but protoc-gen-docs allows the --docs_out=camel_case_fields=true:output_directory field https://pkg.go.dev/istio.io/tools/cmd/protoc-gen-docs#section-readme.

Using the docker image, I'm able to use:

$ protoc --plugin=/usr/bin/protoc-gen-doc --doc_opt=markdown,configs-reference.md --doc_out=/out protos/configs.proto

However, when I try to run

$ protoc --plugin=/usr/bin/protoc-gen-doc --doc_opt=markdown,configs-reference.md --docs_out=camel_case_fields=true:/out protos/configs.proto

I get the error protoc-gen-docs: program not found or is not executable.

I suspect that the doc_opt parameter should be able to extract this option, but it's not currently viable - it just writes an additional file camel_case_fields=true with the generated documentation.

docker run --rm \
  -v $(pwd)/docs:/out \
  -v $(pwd)/protos:/protos \
  pseudomuto/protoc-gen-doc configs.proto --doc_opt=markdown,camel_case_fields=true:configs-reference.md