buf icon indicating copy to clipboard operation
buf copied to clipboard

Include PGV validation options in bufdoc

Open akshayjshah opened this issue 2 years ago • 5 comments

When generating documentation for messages with protoc-gen-validate annotations, it'd be nice to have the docs automatically include the annotations. We could do that by synthesizing an extra paragraph of text (e.g., "This field is required" or "The value must match the regexp abc.*"), by including the raw annotations (possibly with some progressive disclosure in the UI), or by some other means.

@josephschorr from Authzed brought this up in our Slack.

akshayjshah avatar Aug 07 '22 21:08 akshayjshah

I don't think we want to special-case protoc-gen-validate annotations:

  • It's a rabbit hole - do we also special-case google.api? gogoproto? The newest library that comes out?
  • protoc-gen-validate looks to be less maintained these days, and doesn't look like the long-term solution for validation.

bufdev avatar Aug 08 '22 15:08 bufdev

All reasonable concerns. OTOH, validation is reasonably common, as are the Google HTTP transcoding annotations. The validation annotations in particular are important to understand the schema, and it seems like a fairly large omission to drop them completely.

It might be sufficient to show the literal text of the annotation in a progressive disclosure dropdown.

Edit: Basically, I agree that ideally we wouldn't special-case PGV and we'd instead find some generic way to show annotations to end users. Failing that, we're choosing between docs that are incomplete in important ways, or picking and choosing plugins to special-case.

akshayjshah avatar Aug 08 '22 16:08 akshayjshah

There seems to be a middle ground where annotations are rendered and the associated extensions are documented inline where referenced (perhaps as a tool tip or something unobstructive). I agree special-casing is a rabbit hole -- ideally extension authors can supply descriptive documentation that is used to provide the experience proposed experience.

lrewega avatar Aug 09 '22 04:08 lrewega

Since you guys have taken over protoc-gen-validate now (as per https://twitter.com/mattklein123/status/1576971951394164736), perhaps this can be special cased now? :)

josephschorr avatar Oct 03 '22 21:10 josephschorr

We'd still prefer to avoid special-casing PGV - we'd rather not give our plugins special treatment :) However, we are looking at the UX options for including these sorts of annotations in the generated documentation.

akshayjshah avatar Oct 04 '22 03:10 akshayjshah