Skip to content

fix(generator): escape multi-line braces and backtick unknown doc tags in yard formatting - #1337

Draft
suztomo wants to merge 2 commits into
googleapis:mainfrom
suztomo:fix/yard-brace-and-tag-escaping
Draft

fix(generator): escape multi-line braces and backtick unknown doc tags in yard formatting#1337
suztomo wants to merge 2 commits into
googleapis:mainfrom
suztomo:fix/yard-brace-and-tag-escaping

Conversation

@suztomo

@suztomo suztomo commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

This PR addresses YARD documentation warnings and errors generated when formatting proto docstrings containing multiline braces (such as inline JSON examples or range syntax) and proto comments with unknown doc tags (such as @pattern or @required).

Problem

  1. Multiline / Unclosed Braces:
    • Gapic::FormattingUtils.escape_line_braces previously matched { and } on the same line using @brace_detector.
    • When docstrings contain multiline JSON examples (e.g. [{name: "app1", port: 8080}, {name:\n"app1"...}) or multiline ranges ({min: min-value, max:\nmax-value} or {100, 200,\n300}), the opening { on the first line remained unescaped.
    • YARD then attempts to parse {min: ...} across lines as an object/class link, resulting in Cannot resolve link to min: from text: warnings.
  2. Unknown Doc Tags:
    • Proto comments containing tags like @pattern (e.g., in regex patterns) or @required compute.instancegroups.addInstances cause YARD to emit [warn]: Unknown tag @<tag> because YARD interprets any @word at the start of a line or after whitespace as a doc tag.

Solution

  1. Escape all unescaped { outside backticks:
    • Split each line by inline code spans (`...`) and replace all unescaped { outside backticks (including when followed by backtick code spans) with \{.
    • This ensures all literal braces are escaped regardless of whether the closing } is on the same line or subsequent lines.
  2. Sanitize unknown doc tags outside backticks:
    • For any (?<=\A|\s)@tag outside backtick spans that is not a known YARD tag (@param, @return, @see, @!attribute, etc.), wrap it in backticks (`@tag`) so YARD renders it as literal text rather than an unrecognized tag directive.
    • Email addresses (e.g. support@example.com) and string literals in code blocks/quotes remain unaffected.

Preview in google-cloud-ruby

A full regeneration preview across google-cloud-ruby was verified in draft PR googleapis/google-cloud-ruby#36487, where:

  • All multiline brace and tag warnings were resolved across generated libraries.
  • toys ci --yard --gems google-cloud-compute-v1 passed with 0 warnings and 0 errors.

Related issues:

@suztomo

suztomo commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

Example rendering of HTML.

Image Image

@suztomo
suztomo marked this pull request as draft August 31, 2026 21:38
@suztomo

suztomo commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

Example for google-apps-chat-v1/proto_docs/google/apps/card/v1/card.rb:

Screenshot 2026-08-31 at 5 42 08 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant