This issue tracks the YARD documentation warnings in google-cloud-compute-v1.
Part of #7452.
Current Situation
When running toys ci --yard --gems google-cloud-compute-v1 (or bundle exec rake yard), YARD documentation generation fails with Yardoc encountered errors due to warnings in proto_docs/google/cloud/compute/v1/compute.rb:
-
Unescaped JSON/Brace Structures (interpreted as broken YARD links):
[warn]: In file proto_docs/google/cloud/compute/v1/compute.rb: Cannot resolve link to name: from text: ...
- Occurs in
Google::Cloud::Compute::V1::InstanceGroupManager#all_instances_config and Google::Cloud::Compute::V1::RegionInstanceGroupManager#all_instances_config from literal {name: "app1", ...} in proto docstrings.
[warn]: In file proto_docs/google/cloud/compute/v1/compute.rb: Cannot resolve link to min: from text: ...
- Occurs in
Google::Cloud::Compute::V1::InterconnectAttachmentConfigurationConstraints#bgp_peer_asn_ranges and Google::Cloud::Compute::V1::InterconnectRemoteLocationConstraints from multiline {min: ...} structures in proto docstrings.
-
Unknown Tag Warnings:
[warn]: Unknown tag @pattern
- Occurs in
Google::Cloud::Compute::V1::InstanceGroupManager#base_instance_name from proto comments containing @pattern: ....
[warn]: Unknown tag @required
- Occurs in
Google::Cloud::Compute::V1::InstanceReference#instance from proto comments containing @required: ....
Impact
In google-cloud-compute-v1/Rakefile, YARD is configured by default with --fail-on-warning:
YARD::Rake::YardocTask.new do |y|
y.options << "--fail-on-warning"
end
Consequently, while toys ci --test --rubocop --doctest passes cleanly, any run including --yard fails.
Resolution
PR submitted: googleapis/gapic-generator-ruby#1337
- Escapes multi-line braces (
(?<!\\)\{(?=[^\s]) -> \{) outside backticks so multiline JSON/range expressions are not parsed as object links.
- Sanitizes unknown doc tags (
(?<=\A|\s)@tag outside backticks -> `@tag`) so proto comments like @pattern or @required are not parsed as unrecognized YARD tags.
How to Confirm a Change in gapic-generator-ruby with Librarian Locally
Librarian executes protoc-gen-ruby_cloud from its Ruby tools cache directory (~/.cache/librarian/bin/ruby_tools). To test local changes made in gapic-generator-ruby against Librarian generation without publishing a new gem release:
-
Build the local gem in gapic-generator-ruby:
cd /path/to/gapic-generator-ruby/gapic-generator
gem build gapic-generator.gemspec
-
Install the built gem into Librarian's Ruby tools cache directory:
gem install gapic-generator-*.gem \
--install-dir ~/.cache/librarian/bin/ruby_tools \
--bindir ~/.cache/librarian/bin/ruby_tools/bin \
--no-document
(If changes were also made to gapic-generator-cloud, build and install gapic-generator-cloud.gemspec into the same directory.)
-
Run Librarian generation in google-cloud-ruby:
cd /path/to/google-cloud-ruby
librarian generate --all
# Or for a specific gem:
librarian generate --target google-cloud-compute-v1
-
Verify CI and YARD checks:
toys ci --yard --gems google-cloud-compute-v1
toys ci --test --rubocop --doctest --gems google-cloud-compute-v1
This issue tracks the YARD documentation warnings in
google-cloud-compute-v1.Part of #7452.
Current Situation
When running
toys ci --yard --gems google-cloud-compute-v1(orbundle exec rake yard), YARD documentation generation fails withYardoc encountered errors due to warningsinproto_docs/google/cloud/compute/v1/compute.rb:Unescaped JSON/Brace Structures (interpreted as broken YARD links):
[warn]: In file proto_docs/google/cloud/compute/v1/compute.rb: Cannot resolve link to name: from text: ...Google::Cloud::Compute::V1::InstanceGroupManager#all_instances_configandGoogle::Cloud::Compute::V1::RegionInstanceGroupManager#all_instances_configfrom literal{name: "app1", ...}in proto docstrings.[warn]: In file proto_docs/google/cloud/compute/v1/compute.rb: Cannot resolve link to min: from text: ...Google::Cloud::Compute::V1::InterconnectAttachmentConfigurationConstraints#bgp_peer_asn_rangesandGoogle::Cloud::Compute::V1::InterconnectRemoteLocationConstraintsfrom multiline{min: ...}structures in proto docstrings.Unknown Tag Warnings:
[warn]: Unknown tag @patternGoogle::Cloud::Compute::V1::InstanceGroupManager#base_instance_namefrom proto comments containing@pattern: ....[warn]: Unknown tag @requiredGoogle::Cloud::Compute::V1::InstanceReference#instancefrom proto comments containing@required: ....Impact
In
google-cloud-compute-v1/Rakefile, YARD is configured by default with--fail-on-warning:Consequently, while
toys ci --test --rubocop --doctestpasses cleanly, any run including--yardfails.Resolution
PR submitted: googleapis/gapic-generator-ruby#1337
(?<!\\)\{(?=[^\s])->\{) outside backticks so multiline JSON/range expressions are not parsed as object links.(?<=\A|\s)@tagoutside backticks ->`@tag`) so proto comments like@patternor@requiredare not parsed as unrecognized YARD tags.How to Confirm a Change in gapic-generator-ruby with Librarian Locally
Librarian executes
protoc-gen-ruby_cloudfrom its Ruby tools cache directory (~/.cache/librarian/bin/ruby_tools). To test local changes made ingapic-generator-rubyagainst Librarian generation without publishing a new gem release:Build the local gem in
gapic-generator-ruby:cd /path/to/gapic-generator-ruby/gapic-generator gem build gapic-generator.gemspecInstall the built gem into Librarian's Ruby tools cache directory:
(If changes were also made to
gapic-generator-cloud, build and installgapic-generator-cloud.gemspecinto the same directory.)Run Librarian generation in
google-cloud-ruby:Verify CI and YARD checks: