-
Notifications
You must be signed in to change notification settings - Fork 435
impl(generator): regenerate most doc files #15653
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
Conversation
Summary of ChangesHello @scotthart, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the documentation generation capabilities of the generator tool. It introduces a more granular control mechanism, allowing for the regeneration of only Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the generator to regenerate most documentation files by default. This involves introducing a new ScaffoldFiles enum to control which files are generated and updating the main generator logic to call this new functionality. The bulk of the changes are formatting updates to .dox files as a result of this regeneration. My review focuses on the C++ code changes, with a couple of suggestions to improve maintainability and readability.
| std::vector<Destination> files; | ||
| if (scaffold_files == ScaffoldFiles::kDocDir) { | ||
| files = { | ||
| {"doc/environment-variables.dox", GenerateDoxygenEnvironmentPage}, | ||
| {"doc/override-authentication.dox", GenerateOverrideAuthenticationPage}, | ||
| {"doc/override-endpoint.dox", GenerateOverrideEndpointPage}, | ||
| {"doc/override-retry-policies.dox", GenerateOverrideRetryPoliciesPage}, | ||
| {"doc/options.dox", GenerateDoxygenOptionsPage}, | ||
| }; | ||
| } else { | ||
| MakeDirectory(destination + "quickstart/"); | ||
| files = { | ||
| {"README.md", GenerateReadme}, | ||
| {"BUILD.bazel", GenerateBuild}, | ||
| {"CMakeLists.txt", GenerateCMakeLists}, | ||
| {"doc/main.dox", GenerateDoxygenMainPage}, | ||
| {"doc/environment-variables.dox", GenerateDoxygenEnvironmentPage}, | ||
| {"doc/override-authentication.dox", GenerateOverrideAuthenticationPage}, | ||
| {"doc/override-endpoint.dox", GenerateOverrideEndpointPage}, | ||
| {"doc/override-retry-policies.dox", GenerateOverrideRetryPoliciesPage}, | ||
| {"doc/options.dox", GenerateDoxygenOptionsPage}, | ||
| {"quickstart/README.md", GenerateQuickstartReadme}, | ||
| {"quickstart/quickstart.cc", GenerateQuickstartSkeleton}, | ||
| {"quickstart/CMakeLists.txt", GenerateQuickstartCMake}, | ||
| {"quickstart/Makefile", GenerateQuickstartMakefile}, | ||
| {"quickstart/BUILD.bazel", GenerateQuickstartBuild}, | ||
| {"quickstart/.bazelrc", GenerateQuickstartBazelrc}, | ||
| }; | ||
| std::ifstream is(scaffold_templates_path + kWorkspaceTemplate); | ||
| auto const contents = std::string{std::istreambuf_iterator<char>(is), {}}; | ||
| std::ofstream os(destination + "quickstart/WORKSPACE.bazel"); | ||
| GenerateQuickstartWorkspace(os, vars, contents); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is code duplication in this if-else block. The list of documentation files to be generated (environment-variables.dox, override-authentication.dox, etc.) is present in both the if branch (lines 347-351) and the else branch (lines 360-364). To improve maintainability and avoid potential inconsistencies in the future, consider extracting this common list of files into a separate variable and using it in both branches.
| if (!service.omit_client() && | ||
| !std::any_of(kOmittedDocDirs.begin(), kOmittedDocDirs.end(), | ||
| [&](auto s) { | ||
| // TODO(#15652): Remove when service is turned down. | ||
| if (absl::StartsWith(service.product_path(), | ||
| "google/cloud/pubsublite")) { | ||
| return false; | ||
| } | ||
| return absl::StartsWith(service.product_path(), s); | ||
| })) { | ||
| GenerateScaffold( | ||
| scaffold_vars, generator_args.scaffold_templates_path, | ||
| generator_args.output_path, service, | ||
| google::cloud::generator_internal::ScaffoldFiles::kDocDir); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic within this if condition, particularly the lambda passed to std::any_of, is a bit complex due to the special handling for pubsublite. To improve readability, I suggest separating the general check against kOmittedDocDirs from the special case logic for pubsublite.
bool omit_doc_dir = std::any_of(
kOmittedDocDirs.begin(), kOmittedDocDirs.end(),
[&](auto s) { return absl::StartsWith(service.product_path(), s); });
// TODO(#15652): Remove when service is turned down.
if (absl::StartsWith(service.product_path(), "google/cloud/pubsublite")) {
omit_doc_dir = false;
}
if (!service.omit_client() && !omit_doc_dir) {
GenerateScaffold(
scaffold_vars, generator_args.scaffold_templates_path,
generator_args.output_path, service,
google::cloud::generator_internal::ScaffoldFiles::kDocDir);
}
mpeddada1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scotthart what command did we need to run to regenerate these doc files?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15653 +/- ##
==========================================
- Coverage 93.11% 93.10% -0.01%
==========================================
Files 2433 2433
Lines 223810 223817 +7
==========================================
- Hits 208400 208387 -13
- Misses 15410 15430 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| #include "absl/flags/flag.h" | ||
| #include "absl/flags/parse.h" | ||
| #include "absl/strings/match.h" | ||
| #include <google/protobuf/compiler/command_line_interface.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also to double check my understanding, is there were the doc generation logic lives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dox file templates are generated from calling GenerateScaffold. Additional content is injected when update-library-landing-dox.sh is invoked.
| static constexpr std::array<char const*, 4> kOmittedDocDirs = { | ||
| "google/cloud/bigtable", "google/cloud/compute", | ||
| "google/cloud/pubsub", "google/cloud/spanner"}; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you provide some context into why these modules are being excluded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments to document the rationale.
|
|
||
| io::log_h2 "Running doxygen landing-page updates:" | ||
| time { | ||
| features::libraries | xargs -P "$(nproc)" -n 1 ci/generate-markdown/update-library-landing-dox.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: is this where we hook doc generation to the generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Producing the final .dox files is a 2 stage process. The generator produces the dox file with markers for the start/end injection points. This script modified the dox file to inject the information between the injection points. line 80 is the invocation of the generator that produces the dox files.
Regenerate most of the .dox files for generated libraries by default whenever the generator is executed.