From cab28c39403c530294f37db555623287d9deeb46 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sun, 21 Jan 2024 19:47:36 -0600 Subject: [PATCH] Generate help strings for keybind actions. --- src/helpgen.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/helpgen.zig b/src/helpgen.zig index 4447346f4..5a9c40b25 100644 --- a/src/helpgen.zig +++ b/src/helpgen.zig @@ -6,6 +6,7 @@ const std = @import("std"); const ziglyph = @import("ziglyph"); const Config = @import("config/Config.zig"); const Action = @import("cli/action.zig").Action; +const KeybindAction = @import("input/Binding.zig").Action; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; @@ -20,6 +21,7 @@ pub fn main() !void { try genConfig(alloc, stdout); try genActions(alloc, stdout); + try genKeybindActions(alloc, stdout); } fn genConfig(alloc: std.mem.Allocator, writer: anytype) !void { @@ -114,6 +116,25 @@ fn genActions(alloc: std.mem.Allocator, writer: anytype) !void { try writer.writeAll("};\n"); } +fn genKeybindActions(alloc: std.mem.Allocator, writer: anytype) !void { + var ast = try std.zig.Ast.parse(alloc, @embedFile("input/Binding.zig"), .zig); + defer ast.deinit(alloc); + + try writer.writeAll( + \\/// keybind actions help + \\pub const KeybindAction = struct { + \\ + \\ + ); + + inline for (@typeInfo(KeybindAction).Union.fields) |field| { + if (field.name[0] == '_') continue; + try genConfigField(alloc, writer, ast, field.name); + } + + try writer.writeAll("};\n"); +} + fn extractDocComments( alloc: std.mem.Allocator, ast: std.zig.Ast,