A pretty printer for zig
zig

add README and MIT License

altagos.dev 1afbb8c6 ab1d20dc

verified
+80 -1
+20
LICENSE
··· 1 + MIT License 2 + 3 + Copyright © 2026 Jakob Speer 4 + 5 + Permission is hereby granted, free of charge, to any person obtaining a copy of 6 + this software and associated documentation files (the “Software”), to deal in the 7 + Software without restriction, including without limitation the rights to use, copy, 8 + modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 + and to permit persons to whom the Software is furnished to do so, subject to the 10 + following conditions: 11 + 12 + The above copyright notice and this permission notice shall be included in all 13 + copies or substantial portions of the Software. 14 + 15 + THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 17 + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 18 + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+59
README.md
··· 1 + # pretty 2 + 3 + A compile-time pretty printer for Zig with colored terminal output. 4 + 5 + ## Installation 6 + 7 + Run: 8 + ```sh 9 + zig fetch --save git+https://git.sr.ht/~altagos/pretty#main 10 + ``` 11 + Or manually add to `build.zig.zon`: 12 + ```zig 13 + .dependencies = .{ 14 + .pretty = .{ 15 + .url = "git+https://git.sr.ht/~altagos/pretty#main", 16 + .hash = "<HASH>", 17 + }, 18 + } 19 + ``` 20 + 21 + In `build.zig`: 22 + ```zig 23 + const pretty = b.dependency("pretty", .{ .target = target, .optimize = optimize }); 24 + exe.root_module.addImport("pretty", pretty.module("pretty")); 25 + ``` 26 + 27 + ## Usage 28 + 29 + For a detailed example, see [example/main](./example/main.zig) 30 + 31 + ```zig 32 + const pretty = @import("pretty").pretty; 33 + 34 + std.debug.print("{f}\n", .{pretty(my_value)}); 35 + ``` 36 + 37 + ### With Options 38 + 39 + ```zig 40 + const prettyO = @import("pretty").prettyO; 41 + 42 + std.debug.print("{f}\n", .{prettyO(my_value, .{ 43 + .struct_inline = true, 44 + .array_inline = true, 45 + })}); 46 + ``` 47 + 48 + ### Global Defaults 49 + 50 + ```zig 51 + pub const pretty_options = @import("pretty").Options{ 52 + .skip_root_type_name = true, 53 + .theme = .{ .indent_width = 4 }, 54 + }; 55 + ``` 56 + 57 + ## License 58 + 59 + [MIT License](./LICENSE)
+1 -1
pretty.zig
··· 19 19 pub const Options = struct { 20 20 /// Disable pretty printing. 21 21 /// 22 - /// If enabled will format values using `{any}` 22 + /// If enabled, will format values using `{any}` 23 23 disable: bool = false, 24 24 25 25 /// Show type names