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.
pubfndefaultRebase(w: *Writer, preserve: usize, minimum_len: usize) Error!void {
while (w.buffer.len - w.end < minimum_len) {
{
// TODO: instead of this logic that "hides" data from
// the implementation, introduce a seek index to Writer
constpreserved_head = w.end -| preserve;
constpreserved_tail = w.end;
constpreserved_len = preserved_tail - preserved_head;
w.end = preserved_head;
deferw.end += preserved_len;
assert(0 == tryw.vtable.drain(w, &.{""}, 1));
assert(w.end <= preserved_head + preserved_len);
@memmove(w.buffer[w.end..][0..preserved_len], w.buffer[preserved_head..preserved_tail]);
}
// If the loop condition was false this assertion would have passed
// anyway. Otherwise, give the implementation a chance to grow the
// buffer before asserting on the buffer length.
assert(w.buffer.len - preserve >= minimum_len);
}
}