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. Public Function
pubfnnext(self: *RangeIterator) error{InvalidDebugInfo}!?Range {
while (tryself.annotations.next()) |annotation| {
switch (annotation) {
.change_code_offset => |delta| {
self.curr.code_offset += delta;
},
.change_code_length => |length| {
if (self.prev) |*prev| prev.code_length = prev.code_lengthorelselength;
self.curr.code_offset += length;
},
// LLVM has code to emit these, but I wasn't able to figure out how trigger it// so this logic is untested.
.change_file => |file_id| {
self.curr.file_id = file_id;
},
// LLVM never emits this opcode, but it's clear enough how to interpret it so we// may as well handle it in case they emit it in the future
.change_code_length_and_code_offset => |info| {
self.curr.code_length = info.length;
self.curr.code_offset += info.delta;
},
.change_line_offset => |delta| {
self.curr.line_offset += delta;
},
.change_code_offset_and_line_offset => |info| {
self.curr.code_offset += info.code_delta;
self.curr.line_offset += info.line_delta;
},
// Not emitted by LLVM at the time of writing, and we don't want to add support// without a test case. Safe to ignore since we don't use this info right now.
.change_line_end_delta,
.change_column_start,
.change_column_end_delta,
.change_column_end,
=> {},
// Not emitted by LLVM at the time of writing. Various sources conflict on how// these opcodes should be interpreted, so we make no attempt to handle them.
.code_offset,
.change_code_offset_base,
.change_range_kind,
=> {
self.annotations = .empty;
self.prev = null;
returnnull;
},
}
// If we have a new code offset, return the previous range if it exists, resolving// its length if necessary.switch (annotation) {
.change_code_offset,
.change_code_offset_and_line_offset,
.change_code_length_and_code_offset,
=> {},
else => continue,
}
deferself.prev = self.curr;
constprev = self.prevorelsecontinue;
returnprev.resolve(self.curr.code_offset);
}
// If we've processed all the binary operations but still have a previous range leftover// with a known length, return it.constprev = self.prevorelsereturnnull;
deferself.prev = null;
returnprev.resolve(null);
}