protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Use .proto comments as @moduledoc for generated schemas

Open supersimple opened this issue 2 years ago • 6 comments

I would like to have my generated files show up in documentation. In my case, I am publishing a private hex package that we use to distribute the generated pb files amongst different Elixir services in our organization. For my case, I just want to documentation to show what the module names are. We don't need any more detail than that.

supersimple avatar Feb 25 '22 20:02 supersimple

@supersimple this is on our radar and has been for a while. See https://github.com/elixir-protobuf/protobuf/pull/123. At the time we decided to postpone this but I'd be okay adding it, it seems like it's a desired feature for multiple users of the library.

Todd, any chance you'd have some time to work on this? I can work on this but in a couple weeks at best, using all my cycles now for https://github.com/lexhide/xandra.

whatyouhide avatar Mar 01 '22 15:03 whatyouhide

@whatyouhide i might have some time. I was just hoping for a flag to remove the @moduledoc: false so I could see the module names in docs. It looks like that PR wants to provide a binary for the documentation. Would it be okay to send up a PR for just the first part? or would you rather support that binary option?

supersimple avatar Mar 03 '22 15:03 supersimple

Starting with an option to just disable @moduledoc: false sounds fine with me as long as it can be extended in the future to include the moduledoc string.

ericmj avatar Mar 06 '22 16:03 ericmj

@supersimple ping? 🙃

whatyouhide avatar Jun 25 '22 08:06 whatyouhide

@supersimple ping? 🙃

Sorry, Andrea. My life exploded on me and I never got to this.

supersimple avatar Jun 25 '22 17:06 supersimple

Hello from 2023! I'd love this functionality.

As an example, Temporal has detailed comments in their protobuf definitions: https://github.com/temporalio/api/blob/master/temporal/api/common/v1/message.proto

The produced Elixir code: https://github.com/mruoss/temporalio.ex/blob/main/lib/temporal/api/common/v1/message.pb.ex

Although protobuf doesn't specify what should happen to comments, that information seems to be available?

@btkostner seems to have a working implementation; the PR just needs code reviews. 😄

Nezteb avatar Nov 07 '23 00:11 Nezteb