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 › docs/ › wasm/ › Decl.zig › append_path
append_path
Decl.append_path
pub fn append_path (decl : *const Decl , list : *ArrayList (u8 )) Oom !void
File
Code
pub fn append_path (decl : *const Decl , list : *ArrayList (u8 )) Oom !void {
const start = list .items .len ;
for (Walk .modules .keys (), Walk .modules .values ()) |pkg_name , pkg_file | {
if (pkg_file == decl .file ) {
try list .ensureUnusedCapacity (gpa , pkg_name .len + 1 );
list .appendSliceAssumeCapacity (pkg_name );
list .appendAssumeCapacity ('.' );
return ;
}
}
const file_path = decl .file .path ();
try list .ensureUnusedCapacity (gpa , file_path .len + 1 );
list .appendSliceAssumeCapacity (file_path );
for (list .items [start ..]) |*byte | switch (byte .*) {
'/' => byte .* = '.' ,
else => continue ,
};
if (std .mem .endsWith (u8 , list .items , ".zig" )) {
list .items .len -= 3 ;
} else {
list .appendAssumeCapacity ('.' );
}
}