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 › compiler/ › Maker/ › Fetch.zig › srcLoc
srcLoc
Fetch.srcLoc
fn srcLoc (
f : *Fetch ,
tok : std .zig .Ast .TokenIndex ,
) Allocator .Error !ErrorBundle .SourceLocationIndex
File
Code
fn srcLoc (
f : *Fetch ,
tok : std .zig .Ast .TokenIndex ,
) Allocator .Error !ErrorBundle .SourceLocationIndex {
const ast = f .parent_manifest_ast orelse return .none ;
const eb = &f .error_bundle ;
const start_loc = ast .tokenLocation (0 , tok );
const src_path = try eb .printString ("{f}" ++ fs .path .sep_str ++ Manifest .basename , .{f .parent_package_root });
const msg_off = 0 ;
return eb .addSourceLocation (.{
.src_path = src_path ,
.span_start = ast .tokenStart (tok ),
.span_end = @intCast (ast .tokenStart (tok ) + ast .tokenSlice (tok ).len ),
.span_main = ast .tokenStart (tok ) + msg_off ,
.line = @intCast (start_loc .line ),
.column = @intCast (start_loc .column ),
.source_line = try eb .addString (ast .source [start_loc .line_start ..start_loc .line_end ]),
});
}