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.
pubfngetByIdentifier(identifier: u16) !CodePage {
// There's probably a more efficient way to do this (e.g. ComptimeHashMap?) but
// this should be fine, especially since this function likely won't be called much.
constinfo = @typeInfo(CodePage).@"enum";
inlinefor (info.field_names, info.field_values) |field_name, field_value| {
if (identifier == field_value) {
return@field(CodePage, field_name);
}
}
returnerror.InvalidCodePage;
}