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.
Zig › std/ › fs/ › path.zig › formatJoin
formatJoin
path.formatJoin
fn formatJoin (paths : []const []const u8 , w : *std .Io .Writer ) std .Io .Writer .Error !void
File
Code
fn formatJoin (paths : []const []const u8 , w : *std .Io .Writer ) std .Io .Writer .Error !void {
const first_path_idx = for (paths , 0 ..) |p , idx | {
if (p .len != 0 ) break idx ;
} else return ;
try w .writeAll (paths [first_path_idx ]);
var prev_path = paths [first_path_idx ];
for (paths [first_path_idx + 1 ..]) |this_path | {
if (this_path .len == 0 ) continue ;
const prev_sep = isSep (prev_path [prev_path .len - 1 ]);
const this_sep = isSep (this_path [0 ]);
if (!prev_sep and !this_sep ) {
try w .writeByte (sep );
}
if (prev_sep and this_sep ) {
try w .writeAll (this_path [1 ..]);
} else {
try w .writeAll (this_path );
}
prev_path = this_path ;
}
}