protoc-gen-doc icon indicating copy to clipboard operation
protoc-gen-doc copied to clipboard

Unknown flag: --doc_opt

Open ben-skyportsystems opened this issue 7 years ago • 9 comments

Hi,

I'm trying to use your plugin and can't get it to accept the '--doc_opt' flag. From what I can tell, protoc parses flags as "--foo_arg" and sends "arg" to the plugin "foo", at least that's what I see in other plugins we use (notably protoc-gen-go)

ben@ben-lab-sc1:~/src/github.com/pseudomuto/protoc-gen-doc/examples$ protoc --doc_out=doc --doc_opt=html,myoutput.html proto/Customer.proto 
Unknown flag: --doc_opt
ben@ben-lab-sc1:~/src/github.com/pseudomuto/protoc-gen-doc/examples$ protoc --version
libprotoc 3.0.0
ben@ben-lab-sc1:~/src/github.com/pseudomuto/protoc-gen-doc/examples$ go version
go version go1.8.3 linux/amd64
ben@ben-lab-sc1:~/src/github.com/pseudomuto/protoc-gen-doc/examples$ which protoc-gen-doc
/home/ben/bin/protoc-gen-doc
ben@ben-lab-sc1:~src/github.com/pseudomuto/protoc-gen-doc/examples$ echo $GOPATH
/home/ben

I built the tool as follows:

ben@ben-lab-sc1:~/src/github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc$ go install -v
github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc

Are there any steps that I missed in order to enable this flag?

thanks, Ben

ben-skyportsystems avatar Sep 28 '17 23:09 ben-skyportsystems

The exact same error also happened to me. Somebody suggested, in a different protoc plugin issue, to explicitly set --plugin flag as workaround and it seemed to work well for their case, but it didn't work for me when I tried for this protoc-gen-doc case (still return Unknown flag error).

har07 avatar Oct 02 '17 03:10 har07

What version of protoc are you on?

SPSpwetter avatar Oct 02 '17 19:10 SPSpwetter

@SPSpwetter this is mine :

$ protoc --version
libprotoc 3.1.0

har07 avatar Oct 03 '17 02:10 har07

Upgraded to 3.4.0 and now it seems to work (without --plugin flag), only my custom template still has errors. Thanks!!

har07 avatar Oct 04 '17 07:10 har07

Yeah, I thought that might be it. We're on 3.0.0 so we have the same problem. We can generate the non-html off line though until we go all the way to 3.4.

SPSpwetter avatar Oct 04 '17 17:10 SPSpwetter

Seems like this works from 3.3.0 forward. If you're unable to bump the protoc version, you could always use the docker container to generate docs.

Does this work for you?

docker run --rm \
  -v $(pwd)/doc:/out \
  -v $(pwd)/proto:/protos \
  pseudomuto/protoc-gen-doc --doc_opt=html,myoutput.html /protos/Customer.proto

pseudomuto avatar Oct 06 '17 13:10 pseudomuto

Thanks for responding @pseudomuto. We have a bunch of tooling around protoc, so I'm really not able to use the docker solution. Moving protobufs forward would also be a big change that I'm not sure I can bite off at this time. Can you tell me more about what changes in Protobuf 3.3 make this work? Also, what version dependencies do you have on protoc-gen-go, which this seems to piggy-back on top of? Thanks!

ben-skyportsystems avatar Oct 06 '17 14:10 ben-skyportsystems

I'm trying to get v1.0.0 working together with google/protobuf-gradle-plugin and are struggling also with --doc_opt.

Apparently, protoc allows custom options to be passed to the *_out flag. In turn, the gradle plugin specifically allows to pass custom plugin options to this flag only. See how they are setting up options for the protoc invokation: GenerateProtoTask.groovy#L324-L328.

Would it be possible to support options prepended to the output argument? Maybe additionally to the --doc_opt flag?

brnhffmnn avatar Nov 14 '17 11:11 brnhffmnn

As I just learnt from google/protobuf-gradle-plugin#184 options can also be passed using the older way of by prepending them to the _out flag. Accordingly, --doc_out=doc --doc_opt=html,myoutput.html is equivalent to --doc_out=html,myoutput.html:doc.

brnhffmnn avatar Nov 15 '17 07:11 brnhffmnn