Skip to content

Commit ff3a6d1

Browse files
authored
fix(internal/librarian/ruby): pass ruby-cloud-summary generator option alongside description (#7114)
Pass `ruby-cloud-summary` generator option with `sc.Description` alongside `ruby-cloud-description` when generating Ruby client libraries. When `ruby-cloud-description` was passed alone without `ruby-cloud-summary`, `gapic-generator-cloud` parsed `summary` directly from `service.yaml` (which preserves internal newlines `\n` from YAML block scalar parsing `|-`). Because `gem.summary` (with `\n`) did not equal `gem.description` (with spaces), `gapic-generator-cloud` evaluated `gem.summary != gem.description` to `true` in [`gapic-generator-cloud/templates/cloud/wrapper_gem/readme.text.erb`](https://github.com/googleapis/gapic-generator-ruby/blob/5c65b2ab4910da4315fe210a831ad258d5097409/gapic-generator-cloud/templates/cloud/wrapper_gem/readme.text.erb#L3-L9), causing the summary text to be rendered twice in wrapper gem `README.md`. ### Code References - [`buildGAPICOpts` in `internal/librarian/ruby/generate.go`](https://github.com/googleapis/librarian/blob/089e2153f7ea740abff54f23c4cbc889c3dea34c/internal/librarian/ruby/generate.go#L164-L167) - [`readme.text.erb` in `gapic-generator-ruby`](https://github.com/googleapis/gapic-generator-ruby/blob/5c65b2ab4910da4315fe210a831ad258d5097409/gapic-generator-cloud/templates/cloud/wrapper_gem/readme.text.erb#L3-L9) - [`GemPresenter` in `gapic-generator-ruby`](https://github.com/googleapis/gapic-generator-ruby/blob/5c65b2ab4910da4315fe210a831ad258d5097409/gapic-generator/lib/gapic/presenters/gem_presenter.rb#L118-L149) ### Verification Ran `librarian generate google-cloud-asset`: ```diff --- a/google-cloud-asset/README.md +++ b/google-cloud-asset/README.md @@ -1,8 +1,8 @@ # Ruby Client for the Cloud Asset API -The Cloud Asset API manages the history and inventory of Google Cloud resources. +The Cloud Asset API manages the history and inventory of Google Cloud +resources. -The Cloud Asset API manages the history and inventory of Google Cloud resources. Actual client classes for the various versions of this API are defined in ``` The duplicate summary line is removed and rendered exactly once. Fixes #7113
1 parent fa48762 commit ff3a6d1

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

internal/librarian/ruby/generate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ func buildGAPICOpts(api *config.API, library *config.Library, googleapisDir stri
162162
opts = append(opts, "service-yaml="+filepath.Join(googleapisDir, sc.ServiceConfig))
163163
}
164164
if sc != nil && sc.Description != "" {
165-
opts = append(opts, "ruby-cloud-description="+escapeRubyCloudOptValue(sc.Description))
165+
desc := escapeRubyCloudOptValue(sc.Description)
166+
opts = append(opts, "ruby-cloud-description="+desc, "ruby-cloud-summary="+desc)
166167
}
167168
if gc != "" {
168169
opts = append(opts, "grpc-service-config="+filepath.Join(googleapisDir, gc))

internal/librarian/ruby/generate_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func TestBuildGAPICOpts(t *testing.T) {
5656
"ruby-cloud-gem-name=google-cloud-secret_manager-v1",
5757
"service-yaml=" + filepath.Join(googleapisDir, "google/cloud/secretmanager/v1/secretmanager_v1.yaml"),
5858
"ruby-cloud-description=Stores sensitive data such as API keys\\, passwords\\, and certificates.\nProvides convenience while improving security.",
59+
"ruby-cloud-summary=Stores sensitive data such as API keys\\, passwords\\, and certificates.\nProvides convenience while improving security.",
5960
"grpc-service-config=" + filepath.Join(googleapisDir, "google/cloud/secretmanager/v1/secretmanager_grpc_service_config.json"),
6061
"ruby-cloud-generate-transports=grpc;rest",
6162
"ruby-cloud-rest-numeric-enums=true",
@@ -73,6 +74,7 @@ func TestBuildGAPICOpts(t *testing.T) {
7374
"ruby-cloud-gem-name=google-cloud-compute-v1",
7475
"service-yaml=" + filepath.Join(googleapisDir, "google/cloud/compute/v1/compute_v1.yaml"),
7576
"ruby-cloud-description=Compute Engine is an infrastructure as a service (IaaS) product that offers self-managed virtual machine (VM) instances and bare metal instances.",
77+
"ruby-cloud-summary=Compute Engine is an infrastructure as a service (IaaS) product that offers self-managed virtual machine (VM) instances and bare metal instances.",
7678
"ruby-cloud-generate-transports=rest",
7779
"ruby-cloud-rest-numeric-enums=true",
7880
},
@@ -94,6 +96,7 @@ func TestBuildGAPICOpts(t *testing.T) {
9496
"ruby-cloud-gem-name=google-cloud-secret_manager",
9597
"service-yaml=" + filepath.Join(googleapisDir, "google/cloud/secretmanager/v1/secretmanager_v1.yaml"),
9698
"ruby-cloud-description=Stores sensitive data such as API keys\\, passwords\\, and certificates.\nProvides convenience while improving security.",
99+
"ruby-cloud-summary=Stores sensitive data such as API keys\\, passwords\\, and certificates.\nProvides convenience while improving security.",
97100
"grpc-service-config=" + filepath.Join(googleapisDir, "google/cloud/secretmanager/v1/secretmanager_grpc_service_config.json"),
98101
"ruby-cloud-generate-transports=grpc;rest",
99102
"ruby-cloud-rest-numeric-enums=true",
@@ -115,6 +118,7 @@ func TestBuildGAPICOpts(t *testing.T) {
115118
"ruby-cloud-gem-name=google-cloud-secret_manager",
116119
"service-yaml=" + filepath.Join(googleapisDir, "google/cloud/secretmanager/v1/secretmanager_v1.yaml"),
117120
"ruby-cloud-description=Stores sensitive data such as API keys\\, passwords\\, and certificates.\nProvides convenience while improving security.",
121+
"ruby-cloud-summary=Stores sensitive data such as API keys\\, passwords\\, and certificates.\nProvides convenience while improving security.",
118122
"grpc-service-config=" + filepath.Join(googleapisDir, "google/cloud/secretmanager/v1/secretmanager_grpc_service_config.json"),
119123
"ruby-cloud-generate-transports=grpc;rest",
120124
"ruby-cloud-rest-numeric-enums=true",

0 commit comments

Comments
 (0)