use snake case sdk id for member name
There is still a bug in snake_case related to double underscores
This commit is contained in:
parent
578058dfc9
commit
03ef89a362
|
@ -111,8 +111,7 @@ fn generateServices(allocator: *std.mem.Allocator, comptime terminator: []const
|
||||||
// Service struct
|
// Service struct
|
||||||
// name of the field will be snake_case of whatever comes in from
|
// name of the field will be snake_case of whatever comes in from
|
||||||
// sdk_id. Not sure this will simple...
|
// sdk_id. Not sure this will simple...
|
||||||
// TODO: Use sdk_id. Right now I think arn_namespace might be a better answer
|
const constant_name = try snake.fromPascalCase(allocator, sdk_id);
|
||||||
const constant_name = try makeZiggy(allocator, arn_namespace);
|
|
||||||
try constant_names.append(constant_name);
|
try constant_names.append(constant_name);
|
||||||
try writer.print("pub const {s}: struct ", .{constant_name});
|
try writer.print("pub const {s}: struct ", .{constant_name});
|
||||||
_ = try writer.write("{\n");
|
_ = try writer.write("{\n");
|
||||||
|
@ -307,6 +306,4 @@ fn camelCase(allocator: *std.mem.Allocator, name: []const u8) ![]const u8 {
|
||||||
const first_letter = name[0] + ('a' - 'A');
|
const first_letter = name[0] + ('a' - 'A');
|
||||||
return try std.fmt.allocPrint(allocator, "{c}{s}", .{ first_letter, name[1..] });
|
return try std.fmt.allocPrint(allocator, "{c}{s}", .{ first_letter, name[1..] });
|
||||||
}
|
}
|
||||||
fn makeZiggy(allocator: *std.mem.Allocator, id: []const u8) ![]const u8 {
|
|
||||||
return try allocator.dupeZ(u8, id);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,12 @@ pub fn fromPascalCase(allocator: *std.mem.Allocator, name: []const u8) ![]u8 {
|
||||||
target_inx = target_inx + 2;
|
target_inx = target_inx + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (ascii_char == ' ') {
|
||||||
|
rc[target_inx] = '_';
|
||||||
} else {
|
} else {
|
||||||
rc[target_inx] = ascii_char;
|
rc[target_inx] = ascii_char;
|
||||||
|
}
|
||||||
target_inx = target_inx + 1;
|
target_inx = target_inx + 1;
|
||||||
}
|
}
|
||||||
previous_codepoint = codepoint;
|
previous_codepoint = codepoint;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user