pseudomuto / protoc-gen-doc

Documentation generator plugin for Google Protocol Buffers
MIT License
2.61k stars 462 forks source link

Nested Protobuf Directory #398

Closed bigthyme closed 4 years ago

bigthyme commented 5 years ago

Hello!

Thanks for the development of this great tool. I was wondering if there was an easy way to generate docs for nested proto files in their own subdirectories. Below is an example of my particular setup:

- protobufs
     |- protos 
         |- users 
             |- users.proto
         |- address
             |- address.proto 
...

and users.proto might import dependencies like so: import protobufs/protos/foo/foo.proto

Currently, I'm using the recommended docker setup without much success unless I flatten my current directory structure and make the corresponding changings to the imports. Ideally, it'd be nice if I could use a glob command like the so: docker run --rm -v $(pwd)/doc:/out -v $(pwd)/protobufs/protos/*:/protos pseudomuto/protoc-gen-doc --doc_opt=markdown,docs.md

kawasakizx10rr commented 5 years ago

 you can just supply multiple proto_path= for each directory path containing the proto files  On Friday, August 9, 2019, 06:38:19 PM GMT+1, Anthony notifications@github.com wrote:

Hello!

Thanks for the development of this great tool. I was wondering if there was an easy way to generate docs for nested proto files in their own subdirectories. Below is an example of my particular setup:

and users.proto might import dependencies like so: import protobufs/protos/foo/foo.proto

Currently, I'm using the recommended docker setup without much success unless I flatten my current directory structure. Ideally, it'd be nice if I could use a glob command like the so: docker run --rm -v $(pwd)/doc:/out -v $(pwd)/protobufs/protos/*:/protos pseudomuto/protoc-gen-doc --doc_opt=markdown,docs.md

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

bigthyme commented 5 years ago

Apologies for the late reply. When supplying another proto path option, I get the following error:

docker run --rm -v $(pwd)/doc:/out -v $(pwd)/protobufs/protos/:/protos pseudomuto/protoc-gen-doc --doc_opt=html,index.html --proto_path=$(pwd)/protobufs/protos/users/
> warning: directory does not exist.
> Missing input file
davidraleigh commented 4 years ago

@bigthyme This is how I solved it with my project:

docker run --rm   -v $(pwd)/docs:/out   -v $(pwd)/proto:/protos   pseudomuto/protoc-gen-doc --proto_path=/protos/ epl/protobuf/geometry.proto epl/protobuf/geometry_service.proto epl/protobuf/query.proto epl/protobuf/stac.proto epl/protobuf/stac_service.proto

If you'd like you can clone my repo and see how the folders are setup: https://github.com/geo-grpc/api

eweise commented 4 years ago

It would be so wonderful if you could just point this tool at a toplevel directory and have it generate the docs. I'm sure this is the default case for most people. Please consider it.

ryukato commented 4 years ago

could you let me know what is the option name or how I can pass the Proto_path to the plugin for java project?

bigthyme commented 4 years ago

The latest master commit works for my project. Thanks all!

suchitgupta01 commented 4 years ago

@bigthyme @davidraleigh I have a similar issue. Instead of giving each file, is there a way to give multiple folders?

kalzoo commented 3 years ago

Consider using a script to perform the glob expansion prior to protoc-gen-doc:

#!/bin/bash

proto_paths="protobuf/**/*.proto"
docker run --rm \
  -v $(pwd)/public:/out \
  -v $(pwd)/protobuf:/protobuf \
  pseudomuto/protoc-gen-doc --proto_path=protobuf/ $proto_paths
yasark commented 2 years ago

I faced similar issue while trying to run with nested folders for proto, using docker. Later tried to run it in local and it worked fine!. Installed the protoc-gen-doc to local and added it to system path. Folder structure

-out
-protos
--text
---*.proto
--common
---*.proto

protoc --doc_out=./out --doc_opt=html,index.html --proto_path=./ protos/text/*.proto protos/common/*.proto