authorgravatar for vallahor91@gmail.comVallahor <vallahor91@gmail.com> 2022-05-25 14:35:27-03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-19 19:10:11-07:00
logcadee07ef41a108a0bf0592c9ed6ab5914fa231d
treefa406582cf227b295ffc8e92adf76a9be3d80630
parent7b11c23da6b19be8c6dafb54bb1a0a0b26ca4938

fix: paths working on windows


1 files changed, 21 insertions(+), 4 deletions(-)

src/Autodoc.zig+21-4
...@@ -292,10 +292,27 @@ const DocData = struct {...@@ -292,10 +292,27 @@ const DocData = struct {
292 if (options.whitespace) |*ws| ws.indent_level += 1;292 if (options.whitespace) |*ws| ws.indent_level += 1;
293 while (it.next()) |kv| : (idx += 1) {293 while (it.next()) |kv| : (idx += 1) {
294 if (options.whitespace) |ws| try ws.outputIndent(w);294 if (options.whitespace) |ws| try ws.outputIndent(w);
295 try w.print("\"{s}\": {d}", .{295 const builtin = @import("builtin");
296 kv.key_ptr.*.sub_file_path,296 if (builtin.target.os.tag == .windows) {
297 kv.value_ptr.*,297 try w.print("\"", .{});
298 });298 for (kv.key_ptr.*.sub_file_path) |c| {
299 if (c == '\\') {
300 try w.print("\\", .{});
301 try w.print("\\", .{});
302 } else {
303 try w.print("{c}", .{c});
304 }
305 }
306 try w.print("\"", .{});
307 try w.print(": {d}", .{
308 kv.value_ptr.*,
309 });
310 } else {
311 try w.print("\"{s}\": {d}", .{
312 kv.key_ptr.*.sub_file_path,
313 kv.value_ptr.*,
314 });
315 }
299 if (idx != self.data.count() - 1) try w.writeByte(',');316 if (idx != self.data.count() - 1) try w.writeByte(',');
300 try w.writeByte('\n');317 try w.writeByte('\n');
301 }318 }