pseudomuto / protoc-gen-doc

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

Add support for proto3 optional fields #423

Closed ezimanyi closed 3 years ago

ezimanyi commented 4 years ago

What is Changing?

Protobuf 3.12 includes experimental support for field presence via the optional keyword. Please see #422 for more details/discussion about field presence in proto3.

This pull request updates protoc-gen-doc to support proto3 optional fields.

How is it Changing?

This pull request:

What Could Go Wrong?

The primary risk is that this change could inadvertently affect code generation for fields that are not proto3 optional fields. This could occur due to either:

The test coverage for proto2 field attributes seemed good, and the existing tests continue to pass after this change. I added some tests to proto3 fields as the first commit, so that I could ensure that these would not be affected by the change; these continue to pass after the later commits.

I've also tested this manually on my project (which does not yet have proto3 optional fields), and found no diff in the generated markdown before/after. That being said, I think that the unit tests (which have a great variety of different field types) are a better indication of correctness here than the manual test I ran.

Details of individual commits

ezimanyi commented 4 years ago

@pseudomuto : Pinging you here as suggested in the contributing docs. Thanks for this great project, and look forward to your comments on this PR!

bpeake-illuscio commented 4 years ago

+1 for this, using this project to help with my documentation and I love it. Want to try supporting experimental fields.