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.
pubconstIconDir = struct {
image_type: ImageType,
/// Note: entries.len will always fit into a u16, since the field containing the/// number of images in an ico file is a u16.entries: []Entry,
allocator: std.mem.Allocator,
pubfndeinit(self: IconDir) void {
self.allocator.free(self.entries);
}
pubconstres_header_byte_len = 6;
pubfngetResDataSize(self: IconDir) u32 {
// maxInt(u16) * Entry.res_byte_len = 917,490 which is well within the u32 range.
// Note: self.entries.len is limited to maxInt(u16)
return@intCast(IconDir.res_header_byte_len + self.entries.len * Entry.res_byte_len);
}
pubfnwriteResData(self: IconDir, writer: *std.Io.Writer, first_image_id: u16) !void {
trywriter.writeInt(u16, 0, .little);
trywriter.writeInt(u16, @backingInt(self.image_type), .little);
// We know that entries.len must fit into a u16trywriter.writeInt(u16, @as(u16, @intCast(self.entries.len)), .little);
varimage_id = first_image_id;
for (self.entries) |entry| {
tryentry.writeResData(writer, image_id);
image_id += 1;
}
}
}