Zig 0.17.0-dev (Split by item)

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.

CpuinfoParser

linux.CpuinfoParser
fn CpuinfoParser(comptime impl: anytype) type

File

lib/std/zig/system/linux.zig:429

Code

fn CpuinfoParser(comptime impl: anytype) type {
    return struct {
        fn parse(arch: Target.Cpu.Arch, reader: *Io.Reader) !?Target.Cpu {
            var obj: impl = .{};
            while (try reader.takeDelimiter('\n')) |line| {
                const colon_pos = mem.findScalar(u8, line, ':') orelse continue;
                const key = mem.trimEnd(u8, line[0..colon_pos], " \t");
                const value = mem.trimStart(u8, line[colon_pos + 1 ..], " \t");
                if (!try obj.line_hook(key, value)) break;
            }
            return obj.finalize(arch);
        }
    };
}