Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Generate inline snippets in yardoc #627

Merged
merged 2 commits into from
Jul 21, 2021

Conversation

dazuma
Copy link
Member

@dazuma dazuma commented Jul 20, 2021

  • Added an autogenerated @example section to each RPC method demonstrating basic usage. The content of the example is the same as the standalone snippet we already have. This section is activated by the config :generate_yardoc_snippets.
  • Mapped the flags ruby-cloud-generate-standalone-snippets and ruby-cloud-generate-yardoc-snippets so we can activate snippet generation from the bazel configs.
  • Removed the document_ai_v1beta3 rake tasks, which were leftover from testing an earlier PR, but are not currently configured to actually work, and indeed are currently causing bundle exec rake gen to crash.
  • Fixed the require path in the generated standalone snippets so it reflects the recommended require root rather than the service-specific require path.
  • Configured vision_v1 to generate both standalone and yardoc snippets, and regenerated to demonstrate the effects of the above.

@dazuma dazuma requested a review from a team as a code owner July 20, 2021 00:24
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 20, 2021
Copy link
Member

@viacheslav-rostovtsev viacheslav-rostovtsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -10,6 +10,7 @@
#
<%= render partial: "service/client/method/docs/error", locals: { method: method } -%>
#
<%= render partial: "service/client/method/docs/snippets", locals: { method: method } -%>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my personal pref would be to have <%- if method.generate_yardoc_snippets? -%> here instead of in the subtemplate because then it can be seen that this part may not be rendered and the question of 'why is there no # after this render' does not come up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are trade-offs. Putting the "if"s here would tend to obfuscate the structure a bit, and the question of the missing # will be there regardless.

"ruby-cloud-yard-strict" => ":gem.:yard_strict",
"ruby-cloud-generic-endpoint" => ":gem.:generic_endpoint",
"ruby-cloud-generate-metadata" => ":generate_metadata",
"ruby-cloud-generate-standalone-snippets" => ":generate_standalone_snippets",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to add all new parameters into the shared/test_resources/api_test_resources.rb and the corresponding test cases because it then becomes easy to look at the whole tree of all the parameters filled.
Don't know if you want to do it or not, I can definitely do it myself later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's do that in a separate PR. I think it could get kinda large.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #630 to remind us of this.

@viacheslav-rostovtsev
Copy link
Member

A similar work should probably be done for the snippets, e.g. update SnippetPresenter to use usable_service_presenter. Should I create a separate issue for that?

@dazuma
Copy link
Member Author

dazuma commented Jul 21, 2021

Yes, good call-out on snippets for the REST clients. I'll file an issue for that and work on it probably early next week.

@dazuma dazuma merged commit 2f2b6bd into googleapis:master Jul 21, 2021
@dazuma dazuma deleted the pr/doc-snippets branch July 21, 2021 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants