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 › Build › addUserInputOption Public Function addUserInputOption Doc Source Public Function std.Build.addUserInputOption
pub fn addUserInputOption (b : *Build , name : []const u8 , value_raw : []const u8 ) error Params b : *Build name : []const u8 value_raw : []const u8 File Build.zig: 1352
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385 pub fn addUserInputOption (b : *Build , name : []const u8 , value_raw : []const u8 ) error {OutOfMemory }!bool {
const graph = b .graph ;
const arena = graph .arena ;
const value = graph .dupeString (value_raw );
const gop = try b .user_input_options .getOrPut (arena , name );
if (!gop .found_existing ) {
gop .key_ptr .* = graph .dupeString (name );
gop .value_ptr .* = .{ .scalar = value };
return false ;
}
// Option already exists.
switch (gop .value_ptr .*) {
.scalar => |s | {
// Turn it into a list.
var list : std .ArrayList ([]const u8 ) = .empty ;
(try list .addManyAsArray (arena , 2 )).* = .{ s , value };
gop .value_ptr .* = .{ .list = list };
},
.list => |*list | try list .append (arena , value ),
.flag => {
log .err ("option -D{s}={s} conflicts with flag -D{s}" , .{ name , value , name });
return true ;
},
.map => |*map | {
_ = map ;
unreachable ; // TODO implement maps as command line arguments
},
.lazy_path => unreachable ,
.lazy_path_list => unreachable ,
}
return false ;
}
Build system implementation detail.