Skip to content

Linking to items in doc comment is not possible because brackets are always escaped #850

@pgimalac

Description

@pgimalac

Since #510, writing a doc comment linking to an item is not possible because brackets are escaped, meaning that the following proto definition

// A message, represented by a [`Data`].
message Msg {
    Data content = 1;
}

produces the following rust code

/// A message, represented with by a \[`Data`\].
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Msg {
    #[prost(message, optional, tag = "1")]
    pub content: ::core::option::Option<Data>,
}

A trick which works is to add a space between the brackets because the regex used expects non-space characters between the brackets, but then the generated text has an extra space too.

I understand that not all brackets are for doc links (like with #495) but it would be nice to at least have a way to write such doc links properly.

I think that one of the following solutions would be reasonable:

  • not escaping brackets which contain backticks:
// A message, represented by a [`Data`].
  • not escaping brackets which are followed by parenthesis
// A message, represented by a [Data](Data).

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