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.

failDeclExtra

Translator.failDeclExtra
pub fn failDeclExtra(
    t: *Translator,
    scope: *Scope,
    loc: aro.Source.Location,
    name: []const u8,
    comptime format: []const u8,
    args: anytype,
) Error!void

File

lib/compiler/translate-c/Translator.zig:199

Code

pub fn failDeclExtra(
    t: *Translator,
    scope: *Scope,
    loc: aro.Source.Location,
    name: []const u8,
    comptime format: []const u8,
    args: anytype,
) Error!void {
    // location
    // pub const name = @compileError(msg);
    const fail_msg = try std.fmt.allocPrint(t.arena, format, args);
    const fail_decl = try ZigTag.fail_decl.create(t.arena, .{
        .actual = name,
        .mangled = fail_msg,
        .local = scope.id != .root,
    });

    const str = try t.locStr(loc);
    const location_comment = try std.fmt.allocPrint(t.arena, "// {s}", .{str});
    const loc_node = try ZigTag.warning.create(t.arena, location_comment);

    if (scope.id == .root) {
        try t.addTopLevelDecl(name, fail_decl);
        try scope.appendNode(loc_node);
    } else {
        try scope.appendNode(fail_decl);
        try scope.appendNode(loc_node);

        const bs = try scope.findBlockScope(t);
        try bs.discardVariable(name);
    }
}