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.
pubfnfindInlineeName(self: *constPdb, inlinee: u32) ?[]constu8 {
// According to LLVM, the high bit *can* be used to indicate that a type index comes from the
// ipi stream in which case that bit needs to be cleared. LLVM doesn't generate data in this
// manner, but we may as well handle it since it just involves a single bitwise and.
// https://llvm.org/docs/PDB/TpiStream.html#type-indices
consttype_index = inlinee & 0x7FFFFFFF;
varreader: Io.Reader = .fixed(self.ipiorelsereturnnull);
constheader = reader.takeStructPointer(pdb.IpiStreamHeader) catchreturnnull;
for (header.type_index_begin..header.type_index_end) |curr_type_index| {
constprefix = reader.takeStructPointer(pdb.LfRecordPrefix) catchreturnnull;
if (prefix.len < 2) returnnull;
reader.discardAll(prefix.len - @sizeOf(u16)) catchreturnnull;
if (curr_type_index == type_index) {
switch (prefix.kind) {
.func_id => {
constfunc: *align(1) pdb.LfFuncId = @ptrCast(prefix);
returnstd.mem.sliceTo(@as([*:0]constu8, @ptrCast(&func.name[0])), 0);
},
.mfunc_id => {
constfunc: *align(1) pdb.LfMFuncId = @ptrCast(prefix);
returnstd.mem.sliceTo(@as([*:0]constu8, @ptrCast(&func.name[0])), 0);
},
else => returnnull,
}
}
}
returnnull;
}