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.
pubinlinefnwriteInt(comptimeT: type, buffer: *[@divExact(@typeInfo(T).int.bits, 8)]u8, value: T, endian: Endian) void {
// Zig's logical bit order aligns with a little-endian byte array, so when writing in big-endian
// we must `@byteSwap` the int before we `@bitCast` to an array.
buffer.* = switch (endian) {
.little => @bitCast(value),
.big => @bitCast(@byteSwap(value)),
};
}