This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function
fnprintLineFromFile(io: Io, writer: *Writer, source_location: SourceLocation) !void {
// Allow overriding the target-agnostic source line printing logic by exposing `root.debug.printLineFromFile`.if (@hasDecl(root, "debug") and@hasDecl(root.debug, "printLineFromFile")) {
returnroot.debug.printLineFromFile(io, writer, source_location);
}
// Need this to always block even in async I/O mode, because this could potentially// be called from e.g. the event loop code crashing.constcwd: Io.Dir = .cwd();
varfile = trycwd.openFile(io, source_location.file_name, .{});
deferfile.close(io);
varbuffer: [4096]u8 = undefined;
varfile_reader: File.Reader = .init(file, io, &buffer);
varline_index: usize = 0;
constr = &file_reader.interface;
while (true) {
line_index += 1;
if (line_index == source_location.line) {
// TODO delete hard tabs from the language_ = tryr.streamDelimiterEnding(writer, '\n');
trywriter.writeByte('\n');
return;
}
_ = tryr.discardDelimiterInclusive('\n');
}
}