Skip to content

Commit 4613056

Browse files
authored
feat(volo-build): add with_comments option for codegen builder (#631)
* feat(volo-build): add with_comments option for codegen builder * chore(volo-grpc): allow large result to avoid breaking change
1 parent a7febd1 commit 4613056

10 files changed

Lines changed: 173 additions & 243 deletions

File tree

Cargo.lock

Lines changed: 145 additions & 241 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

volo-build/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "volo-build"
3-
version = "0.12.0"
3+
version = "0.12.1"
44
edition.workspace = true
55
homepage.workspace = true
66
repository.workspace = true

volo-build/src/config_builder.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ impl InnerBuilder {
178178
}
179179
}
180180
}
181+
182+
pub fn with_comments(self, with_comments: bool) -> Self {
183+
match self {
184+
InnerBuilder::Protobuf(inner) => {
185+
InnerBuilder::Protobuf(inner.with_comments(with_comments))
186+
}
187+
InnerBuilder::Thrift(inner) => InnerBuilder::Thrift(inner.with_comments(with_comments)),
188+
}
189+
}
181190
}
182191

183192
impl ConfigBuilder {
@@ -229,6 +238,7 @@ impl ConfigBuilder {
229238
.dedup(entry.common_option.dedups)
230239
.with_descriptor(entry.common_option.with_descriptor)
231240
.with_field_mask(entry.common_option.with_field_mask)
241+
.with_comments(entry.common_option.with_comments)
232242
.write()?;
233243

234244
Ok(())

volo-build/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ impl<MkB, Parser> Builder<MkB, Parser> {
153153
self.pilota_builder = self.pilota_builder.with_field_mask(with_field_mask);
154154
self
155155
}
156+
157+
pub fn with_comments(mut self, with_comments: bool) -> Self {
158+
self.pilota_builder = self.pilota_builder.with_comments(with_comments);
159+
self
160+
}
156161
}
157162

158163
impl<MkB, P> Builder<MkB, P>

volo-build/src/model.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub struct CommonOption {
2828
pub with_descriptor: bool,
2929
#[serde(default, skip_serializing_if = "is_false")]
3030
pub with_field_mask: bool,
31+
#[serde(default, skip_serializing_if = "is_false")]
32+
pub with_comments: bool,
3133
}
3234

3335
#[derive(Serialize, Deserialize, Debug, Clone)]

volo-build/src/thrift_backend.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ mod tests {
939939
false,
940940
false,
941941
false,
942+
false,
942943
)
943944
}
944945

volo-build/src/workspace.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ where
109109
.split_generated_files(config.common_option.split_generated_files)
110110
.with_descriptor(config.common_option.with_descriptor)
111111
.with_field_mask(config.common_option.with_field_mask)
112+
.with_comments(config.common_option.with_comments)
112113
.pilota_builder
113114
.compile_with_config(idl_services, pilota_build::Output::Workspace(work_dir));
114115
}
@@ -175,4 +176,9 @@ where
175176
self.pilota_builder = self.pilota_builder.with_field_mask(with_field_mask);
176177
self
177178
}
179+
180+
pub fn with_comments(mut self, with_comments: bool) -> Self {
181+
self.pilota_builder = self.pilota_builder.with_comments(with_comments);
182+
self
183+
}
178184
}

volo-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "volo-cli"
3-
version = "0.12.0"
3+
version = "0.12.1"
44
edition.workspace = true
55
homepage.workspace = true
66
repository.workspace = true

volo-cli/src/migrate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ impl CliCommand for Migrate {
5252
split_generated_files: false,
5353
with_descriptor: false,
5454
with_field_mask: false,
55+
with_comments: false,
5556
},
5657
};
5758

volo-grpc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![cfg_attr(not(doctest), doc = include_str!("../README.md"))]
55
#![cfg_attr(docsrs, feature(doc_cfg))]
66
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
7+
#![allow(clippy::result_large_err)]
78

89
pub mod body;
910
pub mod client;

0 commit comments

Comments
 (0)