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 library itself.
Zig › std/ › Progress.zig › computePrefix
computePrefix
Progress.computePrefix
fn computePrefix (
buf : []u8 ,
start_i : usize ,
nl_n : usize ,
serialized : Serialized ,
children : []const Children ,
node_index : Node .Index ,
) usize
File
Code
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 ;
}