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.
fngetModuleNameInner(address: usize) ?[]constu8 {
switch (builtin.target.os.tag) {
.macos => {
// This function is marked as deprecated; however, it is significantly more performant
// than `dladdr` (since the latter also does a very slow symbol lookup), so let's just
// use it for the better performance since it's still available.
returnstd.mem.span(std.c.dyld_image_path_containing_address(
@ptrFromInt(address),
) orelsereturnnull);
},
else => {
// On other Darwin systems, the function used above is entirely unavailable, so we have
// no choice but to use the slow `dladdr`.
varinfo: std.c.dl_info = undefined;
if (std.c.dladdr(@ptrFromInt(address), &info) == 0) {
returnnull;
}
returnstd.mem.span(info.fname);
},
}
}