Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: source_relative #450

Merged
merged 3 commits into from
Aug 11, 2021
Merged

feat: source_relative #450

merged 3 commits into from
Aug 11, 2021

Conversation

Rossiar
Copy link
Contributor

@Rossiar Rossiar commented Aug 9, 2021

adds support for generating the docs in the folder relative to the proto source path. If there are multiple directories containing proto files, adding the option --doc_out=markdown,index.md,source_relative will generate the file index.md under each of the proto directories with the documentation for the files in that directory. This PR satisfies #449 and is a very lazy copy of #399, which is simply out of date and I wasn't smart enough to fixup.

@pseudomuto it would be great to merge this as the source_relative opt is an accepted option for protoc-gen-go and will also allow this plugin to be used nicely with the lovely buf generate

adds support for generating the docs in the folder relative to the proto source path. If there are multiple directories containing proto files, adding the option --doc_out=markdown,index.md,source_relative will generate the file index.md under each of the proto directories with the documentation for the files in that directory
@pseudomuto
Copy link
Owner

Hey @Rossiar thanks for the PR! In general this looks good to me. I ran the tests and examples locally and things look good 👍

Can you document the option in README.md and add an entry to the CHANGELOG.md file? Once that's done, I'll get this merged and cut a new release.

@Rossiar
Copy link
Contributor Author

Rossiar commented Aug 11, 2021

@pseudomuto all done

@pseudomuto pseudomuto merged commit 4c1aff0 into pseudomuto:master Aug 11, 2021
@pseudomuto
Copy link
Owner

v1.5.0 has been released (docker image will take a little longer). Thanks again for the PR!

@Rossiar Rossiar deleted the feature/source_relative branch August 12, 2021 10:57
@kd7lxl
Copy link

kd7lxl commented Oct 25, 2021

Have you got this to work with buf generate? I tried a few permutations of what I thought were the right options and got errors each time.

@Rossiar
Copy link
Contributor Author

Rossiar commented Oct 26, 2021

@kd7lxl can you open a new issue? There are a few examples in #449 (which we can actually close @pseudomuto since I think this PR solved it) to help you debug

@houseofmercy-github
Copy link

For the benefit of anyone else trying out this plugin with buf who may be unfamiliar with the relationship between the buf.gen.yaml settings and the corresponding protoc-gen-doc options, here is what worked for me:

version: v1
plugins:
  - name: doc
    out: ./gen/doc
    opt: html,index.html,source_relative

Note here since name: doc is specified the plugin is passed --doc_opt=html,index.html,source_relative.

If you naively try to specify only the source_relative option like I first did e.g.

version: v1
plugins:
  - name: doc
    out: ./gen/doc
    opt: source_relative                   <--- don't do this it will fail

you will see Invalid parameter: source_relativebecause ParseOptions won't see a ,

The message isn't wrong but it's confusing and could be improved. It would have saved me some time had it given the description in the comment a few lines earlier e.g.

Invalid parameter: source_relative  
The parameter --doc_opt must be of the format
<TYPE|TEMPLATE_FILE>,<OUTPUT_FILE>[,default|source_relative]:<EXCLUDE_PATTERN>,<EXCLUDE_PATTERN>*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants