Skip to content

Generated field doc comments render as ///Field without space #4

@iainmcgin

Description

@iainmcgin

Three format!("Field ...") call sites in the codegen produce
#[doc = "Field ..."] attributes, which prettyplease renders verbatim
as ///Field ... - no space after the slashes:

// from generated output:
///Field 1: `sentence`
pub sentence: &'a str,

Standard rustdoc style is /// Field 1: ... with a space.

Why

prettyplease emits ///X for #[doc = "X"] verbatim - no space
insertion (attr.rs:35-38).
rustfmt doesn't fix it either (roundtrips doc attrs as-is). To get
/// X the doc string itself needs a leading space.

Fix

Three sites, one-character change each:

  • buffa-codegen/src/message.rs:1057 - format!("Field ...") ->
    format!(" Field ...")
  • buffa-codegen/src/view.rs:312 - same
  • buffa-codegen/src/view.rs:322 - same

For reference, connectrpc-codegen handles this with a doc_attrs()
helper that prefixes each non-blank line with a space before emitting
the #[doc = ...] attribute - worth considering if more doc-string
sites get added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions