Skip to content

Generated program elements should include Rustdoc from Cap'n Proto schema #582

@toddATavail

Description

@toddATavail

I'm open to many possibilities for how this could be realized, but the generator ought to take any element docs from Cap'n Proto schema files and emit them appropriately in the generated code. I realize that a fully "literate" approach that massages wording after the fact would be quite challenging without appealing to an unacceptably heavy machine learning model, but hopefully pasting the source docs into the output verbatim wouldn't be too difficult. Even that much would add a lot of value.

Let's use the following Cap'n Proto schema snippet for reference:

struct Point {
   # A 2D point.

    x @0 :Float64;
    # The x-coordinate.

    y @1 :Float64;
    # The y-coordinate.
}

The struct comment ("A 2D point.") could be added as Rustdoc to the generated Builder and Reader. The field comments ("The x-coordinate.", "The y-coordinate.") could be added to the getters and setters of Builders and Readers.

The obvious use cases are cargo doc and development tooling (e.g., IDEs, LSP servers, …). A substantial amount of effort might go into writing good comments in the Cap'n Proto schema files, and it's a shame to lose that value after code generation. Currently, a developer needs to keep open the original schema files while developing against the Rust bindings in order to see the original documentation, and it would be nice to have the docs available from the tooling while coding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions