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 › Progress › computePrefix Private Function computePrefix Doc Source Private Function std.Progress.computePrefix
fn computePrefix (
buf : []u8 ,
start_i : usize ,
nl_n : usize ,
serialized : Serialized ,
children : []const Children ,
node_index : Node .Index ,
) usize Params File Progress.zig: 1401
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430 fn computePrefix (
buf : []u8 ,
start_i : usize ,
nl_n : usize ,
serialized : Serialized ,
children : []const Children ,
node_index : Node .Index ,
) usize {
var i = start_i ;
const parent_index = serialized .parents [@backingInt (node_index )].unwrap () orelse return i ;
if (serialized .parents [@backingInt (parent_index )] == .none ) return i ;
if (@backingInt (serialized .parents [@backingInt (parent_index )]) == 0 and
serialized .storage [0 ].name [0 ] == 0 )
{
return i ;
}
i = computePrefix (buf , i , nl_n , serialized , children , parent_index );
if (children [@backingInt (parent_index )].sibling == .none ) {
const prefix = " " ;
const upper_bound_len = prefix .len + lineUpperBoundLen (nl_n );
if (i + upper_bound_len > buf .len ) return buf .len ;
buf [i ..][0 ..prefix .len ].* = prefix .*;
i += prefix .len ;
} else {
const upper_bound_len = TreeSymbol .line .maxByteLen () + lineUpperBoundLen (nl_n );
if (i + upper_bound_len > buf .len ) return buf .len ;
i = appendTreeSymbol (.line , buf , i );
}
return i ;
}