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 › zig › llvm › Builder › printEscapedString Private Function printEscapedString Doc Source Private Function std.zig.llvm.Builder.printEscapedString
fn printEscapedString (slice : []const u8 , quotes : QuoteBehavior , w : *Writer ) Writer .Error !void Params File zig/llvm/Builder.zig: 11897
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909 fn printEscapedString (slice : []const u8 , quotes : QuoteBehavior , w : *Writer ) Writer .Error !void {
const need_quotes = switch (quotes ) {
.always_quote => true ,
.quote_unless_valid_identifier => !isValidIdentifier (slice ),
};
if (need_quotes ) try w .writeByte ('"' );
for (slice ) |byte | switch (byte ) {
'\\' => try w .writeAll ("\\\\" ),
' ' ...'"' - 1 , '"' + 1 ...'\\' - 1 , '\\' + 1 ...'~' => try w .writeByte (byte ),
else => try w .print ("\\{X:0>2}" , .{byte }),
};
if (need_quotes ) try w .writeByte ('"' );
}