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 › Parse › expectContainerField Private Function expectContainerField Doc Source Private Function std.zig.Parse.expectContainerField
fn expectContainerField (p : *Parse ) !Node .Index Params File zig/Parse.zig: 900
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939 fn expectContainerField (p : *Parse ) !Node .Index {
_ = p .eatToken (.keyword_comptime );
const main_token = p .tok_i ;
_ = p .eatTokens (&.{ .identifier , .colon });
const type_expr = try p .expectTypeExpr ();
const align_expr = try p .parseByteAlign ();
const value_expr = if (p .eatToken (.equal ) == null ) null else try p .expectExpr ();
if (align_expr == null ) {
return p .addNode (.{
.tag = .container_field_init ,
.main_token = main_token ,
.data = .{ .node_and_opt_node = .{
type_expr ,
.fromOptional (value_expr ),
} },
});
} else if (value_expr == null ) {
return p .addNode (.{
.tag = .container_field_align ,
.main_token = main_token ,
.data = .{ .node_and_node = .{
type_expr ,
align_expr .?,
} },
});
} else {
return p .addNode (.{
.tag = .container_field ,
.main_token = main_token ,
.data = .{ .node_and_extra = .{
type_expr ,
try p .addExtra (Node .ContainerField {
.align_expr = align_expr .?,
.value_expr = value_expr .?,
}),
} },
});
}
}