| ... | @@ -219,22 +219,29 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -219,22 +219,29 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 219 | (d.handle.openDir(self.doc_location.basename, .{}) catch unreachable) | 219 | (d.handle.openDir(self.doc_location.basename, .{}) catch unreachable) |
| 220 | else | 220 | else |
| 221 | (self.module.zig_cache_artifact_directory.handle.openDir(self.doc_location.basename, .{}) catch unreachable); | 221 | (self.module.zig_cache_artifact_directory.handle.openDir(self.doc_location.basename, .{}) catch unreachable); |
| 222 | const data_js_f = output_dir.createFile("data.js", .{}) catch unreachable; | 222 | { |
| 223 | defer data_js_f.close(); | 223 | const data_js_f = output_dir.createFile("data.js", .{}) catch unreachable; |
| 224 | const out = data_js_f.writer(); | 224 | defer data_js_f.close(); |
| 225 | out.print( | 225 | var buffer = std.io.bufferedWriter(data_js_f.writer()); |
| 226 | \\ /** @type {{DocData}} */ | 226 | |
| 227 | \\ var zigAnalysis= | 227 | const out = buffer.writer(); |
| 228 | , .{}) catch unreachable; | 228 | out.print( |
| 229 | std.json.stringify( | 229 | \\ /** @type {{DocData}} */ |
| 230 | data, | 230 | \\ var zigAnalysis= |
| 231 | .{ | 231 | , .{}) catch unreachable; |
| 232 | .whitespace = .{}, | 232 | std.json.stringify( |
| 233 | .emit_null_optional_fields = false, | 233 | data, |
| 234 | }, | 234 | .{ |
| 235 | out, | 235 | .whitespace = .{}, |
| 236 | ) catch unreachable; | 236 | .emit_null_optional_fields = false, |
| 237 | out.print(";", .{}) catch unreachable; | 237 | }, |
| | 238 | out, |
| | 239 | ) catch unreachable; |
| | 240 | out.print(";", .{}) catch unreachable; |
| | 241 | |
| | 242 | // last thing (that can fail) that we do is flush |
| | 243 | buffer.flush() catch unreachable; |
| | 244 | } |
| 238 | // copy main.js, index.html | 245 | // copy main.js, index.html |
| 239 | const docs = try self.module.comp.zig_lib_directory.join(self.arena, &.{ "docs", std.fs.path.sep_str }); | 246 | const docs = try self.module.comp.zig_lib_directory.join(self.arena, &.{ "docs", std.fs.path.sep_str }); |
| 240 | var docs_dir = std.fs.openDirAbsolute(docs, .{}) catch unreachable; | 247 | var docs_dir = std.fs.openDirAbsolute(docs, .{}) catch unreachable; |