aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVallahor <vallahor91@gmail.com>2022-05-25 14:35:27 -0300
committerAndrew Kelley <andrew@ziglang.org>2022-07-19 19:10:11 -0700
commitcadee07ef41a108a0bf0592c9ed6ab5914fa231d (patch)
treefa406582cf227b295ffc8e92adf76a9be3d80630 /src
parent7b11c23da6b19be8c6dafb54bb1a0a0b26ca4938 (diff)
downloadzig-cadee07ef41a108a0bf0592c9ed6ab5914fa231d.tar.gz
zig-cadee07ef41a108a0bf0592c9ed6ab5914fa231d.zip
fix: paths working on windows
Diffstat (limited to 'src')
-rw-r--r--src/Autodoc.zig25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Autodoc.zig b/src/Autodoc.zig
index e5f95bfade..db462dea92 100644
--- a/src/Autodoc.zig
+++ b/src/Autodoc.zig
@@ -292,10 +292,27 @@ const DocData = struct {
if (options.whitespace) |*ws| ws.indent_level += 1;
while (it.next()) |kv| : (idx += 1) {
if (options.whitespace) |ws| try ws.outputIndent(w);
- try w.print("\"{s}\": {d}", .{
- kv.key_ptr.*.sub_file_path,
- kv.value_ptr.*,
- });
+ const builtin = @import("builtin");
+ if (builtin.target.os.tag == .windows) {
+ try w.print("\"", .{});
+ for (kv.key_ptr.*.sub_file_path) |c| {
+ if (c == '\\') {
+ try w.print("\\", .{});
+ try w.print("\\", .{});
+ } else {
+ try w.print("{c}", .{c});
+ }
+ }
+ try w.print("\"", .{});
+ try w.print(": {d}", .{
+ kv.value_ptr.*,
+ });
+ } else {
+ try w.print("\"{s}\": {d}", .{
+ kv.key_ptr.*.sub_file_path,
+ kv.value_ptr.*,
+ });
+ }
if (idx != self.data.count() - 1) try w.writeByte(',');
try w.writeByte('\n');
}