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 › Uri › Component › formatRaw Public Function formatRaw Doc Source Public Function std.Uri.Component.formatRaw
pub fn formatRaw (component : Component , w : *Writer ) Writer .Error !void Params File Uri.zig: 61
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 pub fn formatRaw (component : Component , w : *Writer ) Writer .Error !void {
switch (component ) {
.raw => |raw | try w .writeAll (raw ),
.percent_encoded => |percent_encoded | {
var start : usize = 0 ;
var index : usize = 0 ;
while (std .mem .findScalarPos (u8 , percent_encoded , index , '%' )) |percent | {
index = percent + 1 ;
if (percent_encoded .len - index < 2 ) continue ;
const percent_encoded_char =
std .fmt .parseInt (u8 , percent_encoded [index ..][0 ..2 ], 16 ) catch continue ;
try w .print ("{s}{c}" , .{
percent_encoded [start ..percent ],
percent_encoded_char ,
});
start = percent + 3 ;
index = percent + 3 ;
}
try w .writeAll (percent_encoded [start ..]);
},
}
}