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.

renderNodeGrouped

ast.renderNodeGrouped
fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex

File

Code

fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
    switch (node.tag()) {
        .declaration => unreachable,
        .null_literal,
        .undefined_literal,
        .true_literal,
        .false_literal,
        .return_void,
        .zero_literal,
        .one_literal,
        .void_type,
        .noreturn_type,
        .@"anytype",
        .div_trunc,
        .int_cast,
        .const_cast,
        .volatile_cast,
        .as,
        .truncate,
        .bit_cast,
        .float_cast,
        .int_from_float,
        .float_from_int,
        .ptr_from_int,
        .std_mem_zeroes,
        .int_from_ptr,
        .sizeof,
        .alignof,
        .typeof,
        .typeinfo,
        .vector,
        .std_mem_zeroinit,
        .integer_literal,
        .float_literal,
        .string_literal,
        .string_slice,
        .char_literal,
        .enum_literal,
        .identifier,
        .field_access,
        .ptr_cast,
        .type,
        .array_access,
        .align_cast,
        .optional_type,
        .c_pointer,
        .single_pointer,
        .unwrap,
        .deref,
        .not,
        .negate,
        .negate_wrap,
        .bit_not,
        .func,
        .call,
        .array_type,
        .null_sentinel_array_type,
        .int_from_bool,
        .div_exact,
        .offset_of,
        .shuffle,
        .builtin_extern,
        .wrapped_local,
        .mut_str,
        .helper_call,
        .helper_ref,
        .byte_swap,
        .ceil,
        .cos,
        .sin,
        .exp,
        .exp2,
        .exp10,
        .abs,
        .log,
        .log2,
        .log10,
        .round,
        .sqrt,
        .trunc,
        .floor,
        .root_ref,
        .field_builtin,
        .@"switch",
        => {
            // no grouping needed
            return renderNode(c, node);
        },

        .opaque_literal,
        .@"opaque",
        .empty_array,
        .block_single,
        .add,
        .add_wrap,
        .sub,
        .sub_wrap,
        .mul,
        .mul_wrap,
        .div,
        .shl,
        .shr,
        .mod,
        .@"and",
        .@"or",
        .less_than,
        .less_than_equal,
        .greater_than,
        .greater_than_equal,
        .equal,
        .not_equal,
        .bit_and,
        .bit_or,
        .bit_xor,
        .empty_block,
        .array_cat,
        .array_filler,
        .@"if",
        .@"struct",
        .@"union",
        .array_init,
        .vector_zero_init,
        .tuple,
        .container_init,
        .container_init_dot,
        .block,
        .address_of,
        => return c.addNode(.{
            .tag = .grouped_expression,
            .main_token = try c.addToken(.l_paren, "("),
            .data = .{ .node_and_token = .{
                try renderNode(c, node),
                try c.addToken(.r_paren, ")"),
            } },
        }),
        .ellipsis3,
        .switch_prong,
        .warning,
        .var_decl,
        .fail_decl,
        .arg_redecl,
        .alias,
        .var_simple,
        .pub_var_simple,
        .enum_constant,
        .@"while",
        .@"break",
        .break_val,
        .pub_inline_fn,
        .discard,
        .@"continue",
        .@"return",
        .@"comptime",
        .@"defer",
        .asm_simple,
        .while_true,
        .if_not_break,
        .switch_else,
        .add_assign,
        .add_wrap_assign,
        .sub_assign,
        .sub_wrap_assign,
        .mul_assign,
        .mul_wrap_assign,
        .div_assign,
        .shl_assign,
        .shr_assign,
        .mod_assign,
        .bit_and_assign,
        .bit_or_assign,
        .bit_xor_assign,
        .assign,
        .static_assert,
        .@"unreachable",
        => {
            // these should never appear in places where grouping might be needed.
            unreachable;
        },
    }
}