pseudomuto / protoc-gen-doc

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

Custom Template Path in --doc_opt doesn't work with an absolute path #497

Open chaitanyamalik opened 1 year ago

chaitanyamalik commented 1 year ago

Hey there,

I am trying to run protoc-gen-doc with a custom template with the following command: (this is a demo command)

"C:\User\protoc.exe" -I ./ "C:\User\path\to\proto\hello.proto" --plugin=protoc-gen-doc="protoc-gen-doc.exe" --doc_out="C:\User\output" --doc_opt="C:\User\custom.tmpl","out.csv":"google/*"

This returns an error stating: error parsing regexp: invalid escape sequence: \U pointing to C:\User (I assume).

When I do change the template path to relative in --doc_opt, it throws no such error. Indicating the problem lies in doc_opt.

But why is it taking this as a regex pattern in the first place?

I carried a bit of research and in the documentation, the format for doc-opt was stated as:

The parameter (--doc_opt) must be of the format <TYPE|TEMPLATE_FILE>,[,default|source_relative]:,*. The file will be written to the directory specified with the --doc_out argument to protoc.

Notice the colon(":"), I think that's what is causing the compiler to parse the path as a regex in the first place. (from C:\User). I even added quotes after that, to seperate the arguments but still didn't work.

Is there a way to solve this?

Thanks in advance!