|
1 | 1 | const std = @import("std");
|
2 | 2 | const help_strings = @import("help_strings");
|
3 |
| -const helpgen_actions = @import("../../helpgen_actions.zig"); |
| 3 | +const KeybindAction = @import("../../input/Binding.zig").Action; |
4 | 4 |
|
5 | 5 | pub fn main() !void {
|
6 | 6 | const output = std.io.getStdOut().writer();
|
7 |
| - try helpgen_actions.generate(output, .markdown, std.heap.page_allocator); |
| 7 | + try genKeybindActions(output); |
| 8 | +} |
| 9 | + |
| 10 | +pub fn genKeybindActions(writer: anytype) !void { |
| 11 | + // Write the header |
| 12 | + try writer.writeAll( |
| 13 | + \\--- |
| 14 | + \\title: Keybinding Action Reference |
| 15 | + \\description: Reference of all Ghostty keybinding actions. |
| 16 | + \\editOnGithubLink: https://github.com/ghostty-org/ghostty/edit/main/src/input/Binding.zig |
| 17 | + \\--- |
| 18 | + \\ |
| 19 | + \\This is a reference of all Ghostty keybinding actions. |
| 20 | + \\ |
| 21 | + \\ |
| 22 | + ); |
| 23 | + |
| 24 | + @setEvalBranchQuota(5_000); |
| 25 | + |
| 26 | + var buffer = std.ArrayList(u8).init(std.heap.page_allocator); |
| 27 | + defer buffer.deinit(); |
| 28 | + |
| 29 | + const fields = @typeInfo(KeybindAction).Union.fields; |
| 30 | + inline for (fields) |field| { |
| 31 | + if (field.name[0] == '_') continue; |
| 32 | + |
| 33 | + // Write previously stored doc comment below all related actions |
| 34 | + if (@hasDecl(help_strings.KeybindAction, field.name)) { |
| 35 | + try writer.writeAll(buffer.items); |
| 36 | + try writer.writeAll("\n"); |
| 37 | + |
| 38 | + buffer.clearRetainingCapacity(); |
| 39 | + } |
| 40 | + |
| 41 | + // Write the field name. |
| 42 | + try writer.writeAll("## `"); |
| 43 | + try writer.writeAll(field.name); |
| 44 | + try writer.writeAll("`\n"); |
| 45 | + |
| 46 | + if (@hasDecl(help_strings.KeybindAction, field.name)) { |
| 47 | + var iter = std.mem.splitScalar( |
| 48 | + u8, |
| 49 | + @field(help_strings.KeybindAction, field.name), |
| 50 | + '\n', |
| 51 | + ); |
| 52 | + while (iter.next()) |s| { |
| 53 | + try buffer.appendSlice(s); |
| 54 | + try buffer.appendSlice("\n"); |
| 55 | + } |
| 56 | + } |
| 57 | + } |
8 | 58 | }
|
0 commit comments