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 › debug › printLineInfo Private Function printLineInfo Doc Source Private Function std.debug.printLineInfo
fn printLineInfo (
io : Io ,
t : Io .Terminal ,
debug_info : *SelfInfo ,
address : usize ,
symbol : Symbol ,
) Writer .Error !void Params File debug.zig: 1287
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336 fn printLineInfo (
io : Io ,
t : Io .Terminal ,
debug_info : *SelfInfo ,
address : usize ,
symbol : Symbol ,
) Writer .Error !void {
const writer = t .writer ;
t .setColor (.bold ) catch {};
if (symbol .source_location ) |*sl | {
if (sl .column == 0 ) {
try writer .print ("{s}:{d}" , .{ sl .file_name , sl .line });
} else {
try writer .print ("{s}:{d}:{d}" , .{ sl .file_name , sl .line , sl .column });
}
} else {
try writer .writeAll ("???:?:?" );
}
t .setColor (.reset ) catch {};
try writer .writeAll (": " );
t .setColor (.dim ) catch {};
try writer .print ("0x{x} in {s} ({s})" , .{
address ,
symbol .name orelse "???" ,
symbol .compile_unit_name orelse debug_info .getModuleName (io , address ) catch "???" ,
});
t .setColor (.reset ) catch {};
try writer .writeAll ("\n" );
// Show the matching source code line if possible
if (symbol .source_location ) |sl | {
if (printLineFromFile (io , writer , sl )) {
if (sl .column > 0 ) {
// The caret already takes one char
const space_needed = @as (usize , @intCast (sl .column - 1 ));
try writer .splatByteAll (' ' , space_needed );
t .setColor (.green ) catch {};
try writer .writeAll ("^" );
t .setColor (.reset ) catch {};
}
try writer .writeAll ("\n" );
} else |_ | {
// Ignore all errors; it's a better UX to just print the source location without the
// corresponding line number. The user can always open the source file themselves.
}
}
}