gapic-generator 0.1.5 → 0.1.7
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 +12 -0
- data/lib/gapic/formatting_utils.rb +58 -12
- data/lib/gapic/generator/version.rb +1 -1
- data/lib/gapic/schema/api.rb +8 -0
- data/lib/gapic/schema/wrappers.rb +17 -1
- data/templates/default/gem/gemspec.erb +1 -1
- data/templates/default/gem/rubocop.erb +2 -0
- data/templates/default/helpers/presenters/gem_presenter.rb +1 -1
- data/templates/default/service/client/_paths.erb +1 -0
- data/templates/default/service/client/method/def/_options_defaults.erb +1 -1
- data/templates/default/service/client/method/def/_response_normal.erb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7758f2d15a52b89f57555f192cf9d477cbfdbd9788578ba30b5e04d9c468ed85
|
4
|
+
data.tar.gz: ef2c5bd9924646eea488db7060dc654dc0cc2ff2ad1d5736e4f04cad217e0fe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d28f3903643f3b86770f83538dcaa669668bcd9f89e85592bbc6680c95c13fc043b323cf406fa0fa37b0ad0ad21ed30bb56ed42c7a2be0b423cbfc4c0b7c423
|
7
|
+
data.tar.gz: a98b3d1af7be74a680e0b738b4d0753130f90c51ef71fb181a94189d1806b947338558826cd3e4f5b8c3315897546d2e36a1ce5d99d58dd501fd5aa5e8c3a76d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Release History for gapic-generator
|
2
2
|
|
3
|
+
### 0.1.7 / 2020-03-18
|
4
|
+
|
5
|
+
* Path modules extend self so helpers can be invoked on them directly
|
6
|
+
* Trigger IAM dependency for IAM V1 files other than iam_policy.proto
|
7
|
+
|
8
|
+
### 0.1.6 / 2020-03-17
|
9
|
+
|
10
|
+
* Generated libraries now depend on gapic-common 0.2
|
11
|
+
* Convert cross-reference syntax in proto docs to YARD cross-reference links.
|
12
|
+
* Preserve call options in LROs
|
13
|
+
* Fix implicit kwarg warnings under Ruby 2.7
|
14
|
+
|
3
15
|
### 0.1.5 / 2020-03-13
|
4
16
|
|
5
17
|
* More improvements to escaping of curly braces.
|
@@ -22,25 +22,21 @@ module Gapic
|
|
22
22
|
#
|
23
23
|
module FormattingUtils
|
24
24
|
@brace_detector = /\A(?<pre>[^`]*(`[^`]*`[^`]*)*[^`\\])?\{(?<inside>[^\s][^}]*)\}(?<post>.*)\z/m
|
25
|
+
@xref_detector = /\A(?<pre>[^`]*(`[^`]*`[^`]*)*)?\[(?<text>[\w\.]+)\]\[(?<addr>[\w\.]+)\](?<post>.*)\z/m
|
25
26
|
@list_element_detector = /\A\s*(\*|\+|-|[0-9a-zA-Z]+\.)\s/
|
26
27
|
|
27
28
|
class << self
|
28
29
|
##
|
29
|
-
# Given an enumerable of lines,
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
30
|
+
# Given an enumerable of lines, performs yardoc formatting, including:
|
31
|
+
# * Interpreting cross-references identified as described in AIP 192
|
32
|
+
# * Escaping literal braces that look like yardoc type links
|
33
|
+
#
|
34
|
+
# Tries to be smart about exempting preformatted text blocks.
|
33
35
|
#
|
34
36
|
# @param lines [Enumerable<String>]
|
35
37
|
# @return [Enumerable<String>]
|
36
38
|
#
|
37
|
-
def
|
38
|
-
# This looks for braces that:
|
39
|
-
# * Are opened and closed on the same line
|
40
|
-
# * Are not nested
|
41
|
-
# * Are not located between backticks
|
42
|
-
# * Are not in a preformatted block
|
43
|
-
#
|
39
|
+
def format_doc_lines api, lines
|
44
40
|
# To detect preformatted blocks, this tracks the "expected" base indent
|
45
41
|
# according to Markdown. Specifically, this is the effective indent of
|
46
42
|
# previous block, which is normally 0 except if we're in a list item.
|
@@ -55,7 +51,10 @@ module Gapic
|
|
55
51
|
in_block = nil
|
56
52
|
else
|
57
53
|
in_block, base_indent = update_indent_state in_block, base_indent, line, indent
|
58
|
-
|
54
|
+
if in_block == false
|
55
|
+
line = escape_line_braces line
|
56
|
+
line = format_line_xrefs api, line
|
57
|
+
end
|
59
58
|
end
|
60
59
|
line
|
61
60
|
end
|
@@ -104,6 +103,53 @@ module Gapic
|
|
104
103
|
end
|
105
104
|
line
|
106
105
|
end
|
106
|
+
|
107
|
+
def format_line_xrefs api, line
|
108
|
+
while (m = @xref_detector.match line)
|
109
|
+
entity = api.lookup m[:addr]
|
110
|
+
return line if entity.nil?
|
111
|
+
yard_link = yard_link_for_entity entity, m[:text]
|
112
|
+
return line if yard_link.nil?
|
113
|
+
line = "#{m[:pre]}#{yard_link}#{m[:post]}"
|
114
|
+
end
|
115
|
+
line
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Generate a YARD-style cross-reference for the given entity.
|
120
|
+
#
|
121
|
+
# @param entity [Gapic::Schema::Proto] the entity to link to
|
122
|
+
# @param text [String] the text for the link
|
123
|
+
# @return [String] YARD cross-reference syntax
|
124
|
+
#
|
125
|
+
def yard_link_for_entity entity, text
|
126
|
+
# As a special case, omit the service "google.longrunning.Operations"
|
127
|
+
# and its methods. This is because the generator creates
|
128
|
+
# service-specific copies of the operations client, rather than a
|
129
|
+
# Google::Longrunning::Operations::Client class, and there is in
|
130
|
+
# general no way to tell what the actual service-specific namespace is.
|
131
|
+
return text if entity.address[0, 3] == ["google", "longrunning", "Operations"]
|
132
|
+
|
133
|
+
case entity
|
134
|
+
when Gapic::Schema::Service
|
135
|
+
"{#{convert_address_to_ruby entity}::Client #{text}}"
|
136
|
+
when Gapic::Schema::Method
|
137
|
+
"{#{convert_address_to_ruby entity.parent}::Client##{entity.name.underscore} #{text}}"
|
138
|
+
when Gapic::Schema::Message, Gapic::Schema::Enum, Gapic::Schema::EnumValue
|
139
|
+
"{#{convert_address_to_ruby entity} #{text}}"
|
140
|
+
when Gapic::Schema::Field
|
141
|
+
"{#{convert_address_to_ruby entity.parent}##{entity.name} #{text}}"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def convert_address_to_ruby entity
|
146
|
+
file = entity.containing_file
|
147
|
+
api = file.containing_api
|
148
|
+
address = entity.address
|
149
|
+
address = address.join "." if address.is_a? Array
|
150
|
+
address = address.sub file.package, file.ruby_package if file.ruby_package&.present?
|
151
|
+
address.split(".").reject(&:empty?).map(&:camelize).map { |node| api.fix_namespace node }.join("::")
|
152
|
+
end
|
107
153
|
end
|
108
154
|
end
|
109
155
|
end
|
data/lib/gapic/schema/api.rb
CHANGED
@@ -95,6 +95,18 @@ module Gapic
|
|
95
95
|
@docs = docs
|
96
96
|
end
|
97
97
|
|
98
|
+
# Returns the "root" of this schema.
|
99
|
+
# @return [Gapic::Schema::Api]
|
100
|
+
def containing_api
|
101
|
+
parent&.containing_api
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns the file containing this proto entity
|
105
|
+
# @return [Gapic::Schema::File]
|
106
|
+
def containing_file
|
107
|
+
parent&.containing_file
|
108
|
+
end
|
109
|
+
|
98
110
|
# Gets the cleaned up leading comments documentation
|
99
111
|
def docs_leading_comments
|
100
112
|
return nil if @docs.nil?
|
@@ -102,7 +114,7 @@ module Gapic
|
|
102
114
|
|
103
115
|
lines = @docs.leading_comments.each_line.to_a
|
104
116
|
lines.map! { |line| line.start_with?(" ") ? line[1..-1] : line }
|
105
|
-
lines = FormattingUtils.
|
117
|
+
lines = FormattingUtils.format_doc_lines containing_api, lines
|
106
118
|
lines.join
|
107
119
|
end
|
108
120
|
|
@@ -376,6 +388,10 @@ module Gapic
|
|
376
388
|
@services.each { |m| m.parent = self }
|
377
389
|
end
|
378
390
|
|
391
|
+
def containing_file
|
392
|
+
self
|
393
|
+
end
|
394
|
+
|
379
395
|
def lookup address
|
380
396
|
address = address.split(".").reject(&:empty?).join(".")
|
381
397
|
@registry[address]
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
|
24
24
|
gem.required_ruby_version = ">= 2.4"
|
25
25
|
|
26
|
-
gem.add_dependency "gapic-common", "~> 0.
|
26
|
+
gem.add_dependency "gapic-common", "~> 0.2"
|
27
27
|
<%- if gem.iam_dependency? -%>
|
28
28
|
gem.add_dependency "grpc-google-iam-v1", "~> 0.6.9"
|
29
29
|
<%- end -%>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%- assert_locals method -%>
|
2
2
|
# Converts hash and nil to an options object
|
3
|
-
options = Gapic::CallOptions.new
|
3
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
4
4
|
|
5
5
|
# Customize the options with defaults
|
6
6
|
metadata = @config.rpcs.<%= method.name %>.metadata.to_h
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%- assert_locals method -%>
|
2
2
|
@<%= method.service.stub_name %>.call_rpc :<%= method.name %>, request, options: options do |response, operation|
|
3
3
|
<%- if method.lro? -%>
|
4
|
-
response = Gapic::Operation.new response, <%= method.service.lro_client_ivar
|
4
|
+
response = Gapic::Operation.new response, <%= method.service.lro_client_ivar %>, options: options
|
5
5
|
<%- end -%>
|
6
6
|
yield response, operation if block_given?
|
7
7
|
return response
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gapic-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernest Landrito
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-03-
|
13
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|