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.
fnoutputMatch(c: *Compress, dist: u15, len: u8) Writer.Error!void {
// This must come first. Instead of ensuring a full block is never left buffered,
// draining it is defered to allow end of stream to be indicated.
if (c.buffered_tokens.n == block_tokens) {
@branchHint(.unlikely); // LLVM 21 optimizes this branch as the more likely withouttryc.writeBlock(false);
}
constheader: TokenBufferEntryHeader = .{ .kind = .match, .data = dist };
c.buffered_tokens.list[c.buffered_tokens.pos..][0..2].* = @bitCast(header);
c.buffered_tokens.list[c.buffered_tokens.pos + 2] = len;
c.buffered_tokens.pos += 3;
c.buffered_tokens.n += 1;
c.buffered_tokens.lit_freqs[@as(usize, 257) + token.LenCode.fromVal(len).toInt()] += 1;
c.buffered_tokens.dist_freqs[token.DistCode.fromVal(dist).toInt()] += 1;
}