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
pubfnbyteAlignBlocks(b: *BitWriter) Writer.Error!void {
if (b.buffered_n == 0) return;
// There are two methods to do this:// 1. A store block (5 or 6 bytes)// 2. Outputting empty 10-bit fixed blocks until aligned//// Fixed blocks advance the bit alignment by two, and so can only used for even numbers// requiring a maximum of four bytes (three blocks = 30 bits) to which is always more// efficient than store blocks.if (b.buffered_n & 1 == 0) {
constsplat = (8 - @as(u5, b.buffered_n)) >> 1;
constbits = splat * 10;
// fixed eos code is 0, so the only bits are for the block headerconstpattern: u32 = BlockHeader.int(.{ .kind = .fixed, .final = false });
constsplatted = ((pattern << 20) | (pattern << 10) | pattern) >> (30 - bits);
tryb.write(splatted, bits);
} else {
tryb.write(BlockHeader.int(.{ .kind = .stored, .final = false }), 3);
tryb.output.rebase(0, 5);
b.byteAlign();
b.output.writeInt(u16, 0x0000, .little) catchunreachable;
b.output.writeInt(u16, 0xffff, .little) catchunreachable;
}
assert(b.buffered_n == 0);
}
Byte align using only empty flate blocks