Skip to content

Commit 2f88c7b

Browse files
jessfrazjamwaffles
andauthored
refactor(modeling-cmds)!: label optional, dupes now fail (#947)
* refactor(modeling-cmds)!: label finally optional, dupes now fail - label becomes Option<String> instead of empty String, serde updated - test now asserts duplicate Python stub class and enum names Signed-off-by: Jessie Frazelle <[email protected]> * Update modeling-cmds/src/def_enum.rs Co-authored-by: James Waples <[email protected]> * fmt Signed-off-by: Jessie Frazelle <[email protected]> --------- Signed-off-by: Jessie Frazelle <[email protected]> Co-authored-by: James Waples <[email protected]>
1 parent 90e4a24 commit 2f88c7b

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

modeling-cmds/src/def_enum.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ define_modeling_cmd_enum! {
101101
/// This segment will implicitly begin at the current "pen" location.
102102
pub segment: PathSegment,
103103
/// Optional label to associate with the new path segment.
104-
#[serde(default, skip_serializing_if = "String::is_empty")]
105-
pub label: String,
104+
#[serde(default, skip_serializing_if = "Option::is_none")]
105+
pub label: Option<String>,
106106
}
107107

108108
/// Command for extruding a solid 2d.
@@ -140,7 +140,7 @@ define_modeling_cmd_enum! {
140140
/// Which sketch to extrude.
141141
/// Must be a closed 2D solid.
142142
pub target: ModelingCmdId,
143-
/// Reference to extrude to.
143+
/// Reference to extrude to.
144144
/// Extrusion occurs along the target's normal until it is as close to the reference as possible.
145145
pub reference: ExtrudeReference,
146146
/// Which IDs should the new faces have?

modeling-cmds/src/shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ pub enum ExtrudeMethod {
766766
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
767767
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
768768
pub enum ExtrudeReference {
769-
/// Extrudes along the normal of the top face until it is as close to the entity as possible.
769+
/// Extrudes along the normal of the top face until it is as close to the entity as possible.
770770
/// An entity can be a solid, a path, a face, etc.
771771
EntityReference {
772772
/// The UUID of the entity to extrude to.
@@ -785,7 +785,7 @@ pub enum ExtrudeReference {
785785
Point {
786786
/// The point to extrude to.
787787
point: Point3d<LengthUnit>,
788-
}
788+
},
789789
}
790790

791791
/// IDs for the extruded faces.

modeling-cmds/tests/python_stub_dupes.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ fn print_duplicate_stub_names() {
3737
.map(|(n, c)| (n.to_string(), c))
3838
.collect();
3939

40-
eprintln!("duplicate classes: {:?}", dup_classes);
41-
eprintln!("duplicate enums: {:?}", dup_enums);
42-
43-
// This is informational; do not fail test. If we decide to enforce, we can assert emptiness.
40+
assert!(dup_classes.is_empty(), "Duplicate class names: {dup_classes:?}");
41+
assert!(dup_enums.is_empty(), "Duplicate enum names: {dup_enums:?}");
4442
}

0 commit comments

Comments
 (0)