gapic-generator 0.51.1 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/gapic/formatting_utils.rb +85 -18
- data/lib/gapic/generator/version.rb +1 -1
- data/lib/gapic/generators/default_generator_parameters.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b45efa15311119a19ee117f8eaf8fa2af651151a80f8ed004373b232652f599f
|
|
4
|
+
data.tar.gz: 69203b61e070ca8a4a02e901299739754f1048aa935025fd9ac53af072a5aac7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 10fbd033561469722836fbbb60888097f91571179880221a033aff5e14be7e980c6a5e94e8383305a7422df16d7158ecf39f54a312c742ea642892927d7b248a
|
|
7
|
+
data.tar.gz: 5718898dd81be9b2b3eedf1dc188f61821f2d2d012daf12a82510ba1b09fd696c4594b6dbedee6c19b31ec64da5f15bca4c0ce4a98749c20e1f80aa64975aa8c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Release History for gapic-generator
|
|
2
2
|
|
|
3
|
+
### 0.52.0 / 2026-09-04
|
|
4
|
+
|
|
5
|
+
* Fix: escape multi-line braces and backtick unknown doc tags in yard formatting
|
|
6
|
+
* Fix: rejoin split doc URLs (b/153077040) and strip non-existent message links (b/158466893)
|
|
7
|
+
* Feature: add ruby-cloud-renamed-from for renamed wrapper gems
|
|
8
|
+
|
|
3
9
|
### 0.51.1 / 2026-08-05
|
|
4
10
|
|
|
5
11
|
No significant changes
|
|
@@ -21,16 +21,30 @@ module Gapic
|
|
|
21
21
|
# Various string formatting utils
|
|
22
22
|
#
|
|
23
23
|
module FormattingUtils
|
|
24
|
-
@brace_detector = /\A(?<pre>[^`]*(?:`[^`]*`[^`]*)*[^`\\])?\{(?<inside>[^\s][^}]*)\}(?<post>.*)\z/m
|
|
25
24
|
@xref_detector = /\A(?<pre>[^`]*(?:`[^`]*`[^`]*)*)?\[(?<text>[\w. `-]+)\]\[(?<addr>[\w.]+)\](?<post>.*)\z/m
|
|
26
25
|
@list_element_detector = /\A\s*(?:\*|\+|-|[0-9a-zA-Z]+\.)\s/
|
|
27
26
|
@omit_lines = ["@InputOnly\n", "@OutputOnly\n"]
|
|
27
|
+
# Built-in YARD meta-data tags as documented in:
|
|
28
|
+
# https://rubydoc.info/gems/yard/file/docs/Tags.md#Tag_List
|
|
29
|
+
@known_yard_tags = [
|
|
30
|
+
"abstract", "api", "attr", "attr_reader", "attr_writer", "author", "deprecated", "example",
|
|
31
|
+
"note", "option", "overload", "param", "private", "raise", "return", "see", "since", "todo",
|
|
32
|
+
"version", "yield", "yieldparam", "yieldreturn"
|
|
33
|
+
].freeze
|
|
34
|
+
|
|
35
|
+
# Non-existent messages referenced in proto documentation comments (b/158466893).
|
|
36
|
+
# Cross-references to these messages (or their fields) cannot be resolved, so the links
|
|
37
|
+
# are stripped to avoid broken documentation references.
|
|
38
|
+
@non_existent_messages = [
|
|
39
|
+
"google.cloud.automl.v1.ColumnSpec"
|
|
40
|
+
].freeze
|
|
28
41
|
|
|
29
42
|
class << self
|
|
30
43
|
##
|
|
31
44
|
# Given an enumerable of lines, performs yardoc formatting, including:
|
|
32
45
|
# * Interpreting cross-references identified as described in AIP 192
|
|
33
46
|
# * Escaping literal braces that look like yardoc type links
|
|
47
|
+
# * Backticking unknown doc tags so they are not parsed as YARD tags
|
|
34
48
|
#
|
|
35
49
|
# Tries to be smart about exempting preformatted text blocks.
|
|
36
50
|
#
|
|
@@ -45,23 +59,26 @@ module Gapic
|
|
|
45
59
|
#
|
|
46
60
|
def format_doc_lines api, lines, disable_xrefs: false, transport: nil
|
|
47
61
|
transport ||= api&.default_transport || :grpc
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# previous block, which is normally 0 except if we're in a list item.
|
|
51
|
-
# Then, if a block is indented at least 4 spaces past that expected
|
|
52
|
-
# indent (and as long as it remains so), those lines are considered
|
|
53
|
-
# preformatted.
|
|
62
|
+
lines = rejoin_split_urls lines
|
|
63
|
+
in_fence = in_code_span = false
|
|
54
64
|
in_block = nil
|
|
55
65
|
base_indent = 0
|
|
56
66
|
(lines - @omit_lines).map do |line|
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
if line =~ /^\s*(?:```|~~~)/
|
|
68
|
+
in_fence = !in_fence
|
|
69
|
+
in_code_span = false
|
|
59
70
|
in_block = nil
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
elsif !in_fence
|
|
72
|
+
indent = line_indent line
|
|
73
|
+
if indent.nil?
|
|
74
|
+
in_block = nil
|
|
75
|
+
in_code_span = false
|
|
76
|
+
else
|
|
77
|
+
in_block, base_indent = update_indent_state in_block, base_indent, line, indent
|
|
78
|
+
if in_block == false
|
|
79
|
+
line, in_code_span = format_line_content line, in_code_span
|
|
80
|
+
line = format_line_xrefs api, line, disable_xrefs, transport
|
|
81
|
+
end
|
|
65
82
|
end
|
|
66
83
|
end
|
|
67
84
|
line
|
|
@@ -88,6 +105,21 @@ module Gapic
|
|
|
88
105
|
|
|
89
106
|
private
|
|
90
107
|
|
|
108
|
+
def rejoin_split_urls lines
|
|
109
|
+
return lines if lines.empty?
|
|
110
|
+
|
|
111
|
+
# Fix for misformatted markdown links across line breaks (b/153077040).
|
|
112
|
+
# Callers may pass lines with trailing newlines (e.g., from String#each_line in schema wrappers)
|
|
113
|
+
# or without trailing newlines (e.g., from String#split("\n") in GemPresenter#readme_description).
|
|
114
|
+
# We must preserve the presence or absence of trailing newlines on each element.
|
|
115
|
+
has_newlines = lines.any? { |l| l.end_with? "\n" }
|
|
116
|
+
if has_newlines
|
|
117
|
+
lines.join.gsub(%r{https:\n\s*//}, "https://").each_line.to_a
|
|
118
|
+
else
|
|
119
|
+
lines.join("\n").gsub(%r{https:\n\s*//}, "https://").split("\n", -1)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
91
123
|
def update_indent_state in_block, base_indent, line, indent
|
|
92
124
|
if in_block != true && @list_element_detector =~ line
|
|
93
125
|
in_block = false
|
|
@@ -106,15 +138,50 @@ module Gapic
|
|
|
106
138
|
m[1].length
|
|
107
139
|
end
|
|
108
140
|
|
|
109
|
-
def
|
|
110
|
-
|
|
111
|
-
|
|
141
|
+
def format_line_content line, in_code_span
|
|
142
|
+
parts = line.split("`", -1)
|
|
143
|
+
formatted_parts = parts.each_with_index.map do |part, idx|
|
|
144
|
+
if in_code_span
|
|
145
|
+
in_code_span = false if idx < parts.length - 1
|
|
146
|
+
part
|
|
147
|
+
else
|
|
148
|
+
is_followed_by_backtick = idx < parts.length - 1
|
|
149
|
+
in_code_span = true if is_followed_by_backtick
|
|
150
|
+
formatted = escape_prose_braces part, is_followed_by_backtick: is_followed_by_backtick
|
|
151
|
+
sanitize_prose_tags formatted
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
[formatted_parts.join("`"), in_code_span]
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def escape_prose_braces text, is_followed_by_backtick: false
|
|
158
|
+
# Matches unescaped `{` outside backtick spans followed by non-whitespace.
|
|
159
|
+
# If `{` is at the end of a non-code chunk (is_followed_by_backtick: true), it is followed
|
|
160
|
+
# immediately by a backticked code span (starting with a non-whitespace backtick),
|
|
161
|
+
# so \z (end of string) is also matched.
|
|
162
|
+
pattern = is_followed_by_backtick ? /(?<!\\)\{(?=[^\s]|\z)/ : /(?<!\\)\{(?=[^\s])/
|
|
163
|
+
text.gsub(pattern) { "\\\\{" }
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def sanitize_prose_tags text
|
|
167
|
+
# Matches doc tags starting with `@` at the start of a line or preceded by whitespace.
|
|
168
|
+
# Avoids matching `@` within email addresses (e.g. user@example.com) or quotes.
|
|
169
|
+
# Any tag not in the YARD recognized list (or starting with `!`) is wrapped in backticks
|
|
170
|
+
# so YARD renders it as literal text rather than an unrecognized tag directive.
|
|
171
|
+
text.gsub(/(?<=\A|\s)@([a-zA-Z_]\w*)/) do |match|
|
|
172
|
+
tag = Regexp.last_match 1
|
|
173
|
+
@known_yard_tags.include?(tag) || tag.start_with?("!") ? match : "`#{match}`"
|
|
112
174
|
end
|
|
113
|
-
line
|
|
114
175
|
end
|
|
115
176
|
|
|
116
177
|
def format_line_xrefs api, line, disable_xrefs, transport
|
|
117
178
|
while (m = @xref_detector.match line)
|
|
179
|
+
# Remove links to known non-existent messages (b/158466893)
|
|
180
|
+
if @non_existent_messages.any? { |msg| m[:addr] == msg || m[:addr].start_with?("#{msg}.") }
|
|
181
|
+
line = "#{m[:pre]}#{m[:text]}#{m[:post]}"
|
|
182
|
+
next
|
|
183
|
+
end
|
|
184
|
+
|
|
118
185
|
entity = api.lookup m[:addr]
|
|
119
186
|
is_mixin_field_addr = Gapic::Model::Mixins.mixin_message_field_address?(
|
|
120
187
|
m[:addr],
|
|
@@ -40,6 +40,7 @@ module Gapic
|
|
|
40
40
|
":gem.:homepage",
|
|
41
41
|
":gem.:env_prefix",
|
|
42
42
|
":gem.:version_dependencies",
|
|
43
|
+
":gem.:renamed_from",
|
|
43
44
|
":gem.:migration_version",
|
|
44
45
|
":gem.:product_documentation_url",
|
|
45
46
|
":gem.:issue_tracker_url",
|
|
@@ -83,6 +84,7 @@ module Gapic
|
|
|
83
84
|
"gem-homepage" => ":gem.:homepage",
|
|
84
85
|
"gem-env-prefix" => ":gem.:env_prefix",
|
|
85
86
|
"gem-wrapper-of" => ":gem.:version_dependencies",
|
|
87
|
+
"gem-renamed-from" => ":gem.:renamed_from",
|
|
86
88
|
"gem-migration-version" => ":gem.:migration_version",
|
|
87
89
|
"gem-product-url" => ":gem.:product_documentation_url",
|
|
88
90
|
"gem-issues-url" => ":gem.:issue_tracker_url",
|