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 standard library.
std › zig › PkgConfig › init Public Function init Doc Source 24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 pub fn init (arena : Allocator , stdout : []const u8 , diagnostic : ?*Diagnostic ) InitError !PkgConfig {
var list : std .ArrayList (Pkg ) = .empty ;
var line_it = mem .tokenizeAny (u8 , stdout , "\r\n" );
var line_index : usize = 0 ;
while (line_it .next ()) |line | : (line_index += 1 ) {
if (mem .trim (u8 , line , " \t" ).len == 0 ) continue ;
var tok_it = mem .tokenizeAny (u8 , line , " \t" );
try list .append (arena , .{
.name = tok_it .next () orelse {
if (diagnostic ) |d | d .* = .{
.invalid_line_index = line_index ,
.invalid_line = line ,
};
return error .InvalidPkgConfigOutput ;
},
.desc = tok_it .rest (),
});
}
try list .shrinkToLen (arena );
return .{ .all = list .toOwnedSliceAssert () };
}
Parses the output of
pkg-config --list-all.