Zig 0.17.0-dev (Split by item)

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 library itself.

snapshotIndicatorLine

Run.snapshotIndicatorLine
fn snapshotIndicatorLine(line: FmtIndicatorLine, w: *std.Io.Writer) std.Io.Writer.Error!void

File

Code

fn snapshotIndicatorLine(line: FmtIndicatorLine, w: *std.Io.Writer) std.Io.Writer.Error!void {
    const line_begin_index = if (std.mem.lastIndexOfScalar(u8, line.buf[0..line.index], '\n')) |line_begin|
        line_begin + 1
    else
        0;
    const line_end_index = if (std.mem.findScalar(u8, line.buf[line.index..], '\n')) |line_end|
        (line.index + line_end)
    else
        line.buf.len;

    try w.writeAll(line.buf[line_begin_index..line_end_index]);
    try w.writeByte('\n');
    try w.splatByteAll(' ', line_end_index - line_begin_index);
    try w.writeByte('\n');
    if (line.index >= line.buf.len)
        try w.writeAll("^ (end of file)")
    else
        try w.print("^ ('\\x{x:0>2}')\n", .{line.buf[line.index]});
}