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
fnparseUNC(comptimeT: type, path: []constT) WindowsUNC(T) {
assert(path.len >= 2andPathType.windows.isSep(T, path[0]) andPathType.windows.isSep(T, path[1]));
constany_sep = switch (T) {
u8 => "/\\",
u16 => std.unicode.wtf8ToWtf16LeStringLiteral("/\\"),
else => @compileError("only u8 (WTF-8) and u16 (WTF-16LE) are supported"),
};
// For the server, the first path separator after the initial two is always// the terminator of the server name, even if that means the server name is// zero-length.constserver_end = mem.findAnyPos(T, path, 2, any_sep) orelsereturn .{
.server = path[2..path.len],
.sep_after_server = false,
.share = path[path.len..path.len],
.sep_after_share = false,
};
// For the share, there can be any number of path separators between the server// and the share, so we want to skip over all of them instead of just looking for// the first one.varit = mem.tokenizeAny(T, path[server_end + 1 ..], any_sep);
constshare = it.next() orelsereturn .{
.server = path[2..server_end],
.sep_after_server = true,
.share = path[server_end + 1 .. server_end + 1],
.sep_after_share = false,
};
return .{
.server = path[2..server_end],
.sep_after_server = true,
.share = share,
.sep_after_share = it.index != it.buffer.len,
};
}
Asserts that
pathstarts with two path separators