From 1afbb8c6eb8c82076e1afa039e6f33260cfb6ef0 Mon Sep 17 00:00:00 2001 From: Altagos Date: Tue, 27 Jan 2026 14:08:53 +0100 Subject: [PATCH] add README and MIT License --- LICENSE | 20 ++++++++++++++++++ README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ pretty.zig | 2 +- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..54293d6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright © 2026 Jakob Speer + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in the +Software without restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..edebecc --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +# pretty + +A compile-time pretty printer for Zig with colored terminal output. + +## Installation + +Run: +```sh +zig fetch --save git+https://git.sr.ht/~altagos/pretty#main +``` +Or manually add to `build.zig.zon`: +```zig +.dependencies = .{ + .pretty = .{ + .url = "git+https://git.sr.ht/~altagos/pretty#main", + .hash = "", + }, +} +``` + +In `build.zig`: +```zig +const pretty = b.dependency("pretty", .{ .target = target, .optimize = optimize }); +exe.root_module.addImport("pretty", pretty.module("pretty")); +``` + +## Usage + +For a detailed example, see [example/main](./example/main.zig) + +```zig +const pretty = @import("pretty").pretty; + +std.debug.print("{f}\n", .{pretty(my_value)}); +``` + +### With Options + +```zig +const prettyO = @import("pretty").prettyO; + +std.debug.print("{f}\n", .{prettyO(my_value, .{ + .struct_inline = true, + .array_inline = true, +})}); +``` + +### Global Defaults + +```zig +pub const pretty_options = @import("pretty").Options{ + .skip_root_type_name = true, + .theme = .{ .indent_width = 4 }, +}; +``` + +## License + +[MIT License](./LICENSE) diff --git a/pretty.zig b/pretty.zig index e3678e9..e6ad4c6 100644 --- a/pretty.zig +++ b/pretty.zig @@ -19,7 +19,7 @@ else pub const Options = struct { /// Disable pretty printing. /// - /// If enabled will format values using `{any}` + /// If enabled, will format values using `{any}` disable: bool = false, /// Show type names -- 2.51.2