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.
pubfnfilepathWithExtension(allocator: Allocator, path: []constu8, ext: []constu8) ![]constu8 {
varbuf: std.ArrayList(u8) = .empty;
errdeferbuf.deinit(allocator);
if (std.fs.path.dirname(path)) |dirname| {
varend_pos = dirname.len;
// We want to ensure that we write a path separator at the end, so if the dirname
// doesn't end with a path sep then include the char after the dirname
// which must be a path sep.
if (!std.fs.path.isSep(dirname[dirname.len - 1])) end_pos += 1;
trybuf.appendSlice(allocator, path[0..end_pos]);
}
trybuf.appendSlice(allocator, std.fs.path.stem(path));
trybuf.appendSlice(allocator, ext);
returntrybuf.toOwnedSlice(allocator);
}