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.

categorizeStmt

Walk.categorizeStmt
fn categorizeStmt(ast: *const Ast, stmt: Ast.Node.Index) StmtCategory

File

Code

fn categorizeStmt(ast: *const Ast, stmt: Ast.Node.Index) StmtCategory {
    switch (ast.nodeTag(stmt)) {
        .builtin_call_two,
        .builtin_call_two_comma,
        .builtin_call,
        .builtin_call_comma,
        => {
            var buf: [2]Ast.Node.Index = undefined;
            const params = ast.builtinCallParams(&buf, stmt).?;
            return categorizeBuiltinCall(ast, ast.nodeMainToken(stmt), params);
        },
        .assign => {
            const lhs, const rhs = ast.nodeData(stmt).node_and_node;
            if (isDiscardIdent(ast, lhs) and ast.nodeTag(rhs) == .identifier) {
                const name_bytes = ast.tokenSlice(ast.nodeMainToken(rhs));
                if (std.mem.eql(u8, name_bytes, "undefined")) {
                    return .discard_undefined;
                } else {
                    return .discard_identifier;
                }
            }
            return .other;
        },
        else => return .other,
    }
}