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 › llvm › Builder › Metadata › DIFlags › format Public Function format Doc Source Public Function std.zig.llvm.Builder.Metadata.DIFlags.format
pub fn format (self : DIFlags , w : *Writer ) Writer .Error !void Params File zig/llvm/Builder.zig: 9344
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363 pub fn format (self : DIFlags , w : *Writer ) Writer .Error !void {
var need_pipe = false ;
const info = @typeInfo (DIFlags ).@"struct" ;
inline for (info .field_names , info .field_types ) |field_name , field_type | {
switch (@typeInfo (field_type )) {
.bool => if (@field (self , field_name )) {
if (need_pipe ) try w .writeAll (" | " ) else need_pipe = true ;
try w .print ("DIFlag{s}" , .{field_name });
},
.@"enum" => if (@field (self , field_name ) != .Zero ) {
if (need_pipe ) try w .writeAll (" | " ) else need_pipe = true ;
try w .print ("DIFlag{s}" , .{@tagName (@field (self , field_name ))});
},
.int => assert (@field (self , field_name ) == 0 ),
else => @compileError ("bad field type: " ++ field_name ++ ": " ++
@typeName (field_type )),
}
}
if (!need_pipe ) try w .writeByte ('0' );
}