Skip to content

Commit 8ea74c2

Browse files
authored
cleanup(sidekick): add missing documentation for rust code (#5565)
Documentation is added to the rust code generation templates to document the new function in message templates and to the builder modules to ensure they are documented. This also updates the Rust code generation templates to add allow(missing_docs) annotations to structs, enums, fields, and variants that do not have doc comments derived from upstream definitions, in order to facilitate easier linting of the generated code for real issues with missing documentation. Fixes #5564
1 parent cc11db5 commit 8ea74c2

6 files changed

Lines changed: 26 additions & 0 deletions

File tree

internal/sidekick/rust/templates/common/enum.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ limitations under the License.
1717
{{#Codec.DocLines}}
1818
{{{.}}}
1919
{{/Codec.DocLines}}
20+
{{^Codec.DocLines}}
21+
/// Enum for [{{Codec.Name}}].
22+
{{/Codec.DocLines}}
2023
///
2124
/// # Working with unknown values
2225
///
@@ -42,6 +45,9 @@ pub enum {{Codec.Name}} {
4245
{{#Codec.DocLines}}
4346
{{{.}}}
4447
{{/Codec.DocLines}}
48+
{{^Codec.DocLines}}
49+
#[allow(missing_docs)]
50+
{{/Codec.DocLines}}
4551
{{#Deprecated}}
4652
#[deprecated]
4753
{{/Deprecated}}

internal/sidekick/rust/templates/common/message.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ limitations under the License.
1818
{{#Codec.DocLines}}
1919
{{{.}}}
2020
{{/Codec.DocLines}}
21+
{{^Codec.DocLines}}
22+
#[allow(missing_docs)]
23+
{{/Codec.DocLines}}
2124
{{> /templates/common/feature_gate}}
2225
#[derive(Clone, Default, PartialEq)]
2326
#[non_exhaustive]
@@ -35,6 +38,9 @@ pub struct {{Codec.Name}} {
3538
{{#Codec.DocLines}}
3639
{{{.}}}
3740
{{/Codec.DocLines}}
41+
{{^Codec.DocLines}}
42+
#[allow(missing_docs)]
43+
{{/Codec.DocLines}}
3844
{{#Deprecated}}
3945
#[deprecated]
4046
{{/Deprecated}}
@@ -45,6 +51,9 @@ pub struct {{Codec.Name}} {
4551
{{#Codec.DocLines}}
4652
{{{.}}}
4753
{{/Codec.DocLines}}
54+
{{^Codec.DocLines}}
55+
#[allow(missing_docs)]
56+
{{/Codec.DocLines}}
4857
pub {{Codec.FieldName}}: std::option::Option<{{{Codec.FieldType}}}>,
4958
{{/OneOfs}}
5059

@@ -53,6 +62,7 @@ pub struct {{Codec.Name}} {
5362

5463
{{> /templates/common/feature_gate}}
5564
impl {{Codec.Name}} {
65+
/// Creates a new default instance.
5666
pub fn new() -> Self {
5767
std::default::Default::default()
5868
}

internal/sidekick/rust/templates/common/oneof.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ limitations under the License.
1717
{{#Codec.DocLines}}
1818
{{{.}}}
1919
{{/Codec.DocLines}}
20+
{{^Codec.DocLines}}
21+
#[allow(missing_docs)]
22+
{{/Codec.DocLines}}
2023
{{> /templates/common/feature_gate}}
2124
#[derive(Clone, Debug, PartialEq)]
2225
#[non_exhaustive]
@@ -25,6 +28,9 @@ pub enum {{Codec.EnumName}} {
2528
{{#Codec.DocLines}}
2629
{{{.}}}
2730
{{/Codec.DocLines}}
31+
{{^Codec.DocLines}}
32+
#[allow(missing_docs)]
33+
{{/Codec.DocLines}}
2834
{{#Deprecated}}
2935
#[deprecated]
3036
{{/Deprecated}}

internal/sidekick/rust/templates/crate/src/builder.rs.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
{{/Codec.BoilerPlate}}
2020
{{#Codec.Services}}
2121

22+
/// Request and client builders for [{{Codec.Name}}][crate::client::{{Codec.Name}}].
2223
{{#Codec.PerServiceFeatures}}
2324
#[cfg(feature = "{{Codec.FeatureName}}")]
2425
#[cfg_attr(docsrs, doc(cfg(feature = "{{Codec.FeatureName}}")))]

internal/sidekick/rust/templates/crate/src/lib.rs.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,6 @@ pub(crate) use google_cloud_gax::response::Response;
159159
{{/Codec.HasServices}}
160160
{{#Codec.ExtraModules}}
161161

162+
#[allow(missing_docs)]
162163
pub mod {{{.}}};
163164
{{/Codec.ExtraModules}}

internal/sidekick/rust/templates/grpc-mock/src/lib.rs.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ limitations under the License.
1818
//{{{.}}}
1919
{{/Codec.BoilerPlate}}
2020

21+
#![allow(missing_docs)]
22+
2123
{{#Codec.QuickstartService}}
2224
//! End-to-end mocks for the `{{Package}}.{{Name}}` gRPC service.
2325
//!

0 commit comments

Comments
 (0)