Skip to content

ruby: YARD documentation warning in google-cloud-compute #7461

Description

@suztomo

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:

  1. 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.
  2. 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

  1. Escapes multi-line braces ((?<!\\)\{(?=[^\s]) -> \{) outside backticks so multiline JSON/range expressions are not parsed as object links.
  2. 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:

  1. Build the local gem in gapic-generator-ruby:

    cd /path/to/gapic-generator-ruby/gapic-generator
    gem build gapic-generator.gemspec
  2. 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.)

  3. 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
  4. Verify CI and YARD checks:

    toys ci --yard --gems google-cloud-compute-v1
    toys ci --test --rubocop --doctest --gems google-cloud-compute-v1

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions