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.

format

Path.format
pub fn format(self: Path, writer: *Io.Writer) Io.Writer.Error!void

File

Code

pub fn format(self: Path, writer: *Io.Writer) Io.Writer.Error!void {
    if (Io.Dir.path.isAbsolute(self.sub_path)) {
        return writer.writeAll(self.sub_path);
    } else if (self.root_dir.path) |p| {
        var bufs: [3][]const u8 = .{ p, Io.Dir.path.sep_str, self.sub_path };
        return writer.writeVecAll(bufs[0..if (self.sub_path.len > 0) 3 else 1]);
    } else if (self.sub_path.len > 0) {
        return writer.writeAll(self.sub_path);
    } else {
        return writer.writeByte('.');
    }
}