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
pubfninit(data: []constu8, is_loaded: bool) error{ EndOfStream, MissingPEHeader }!Coff {
if (data.len < pe_pointer_offset + 4) returnerror.EndOfStream;
constheader_offset = mem.readInt(u32, data[pe_pointer_offset..][0..4], .little);
if (data.len < header_offset + 4) returnerror.EndOfStream;
constis_image = mem.eql(u8, data[header_offset..][0..4], pe_signature);
constcoff: Coff = .{
.data = data,
.is_image = is_image,
.is_loaded = is_loaded,
.coff_header_offset = o: {
if (is_image) break :oheader_offset + 4;
break :oheader_offset;
},
};
// Do some basic validation upfrontif (is_image) {
constcoff_header = coff.getHeader();
if (coff_header.size_of_optional_header == 0) returnerror.MissingPEHeader;
}
// JK: we used to check for architecture here and throw an error if not x86 or derivative.// However I am willing to take a leap of faith and let aarch64 have a shot also.returncoff;
}