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.

isOneLineFnProto

Render.isOneLineFnProto
fn isOneLineFnProto(
    tree: Ast,
    fn_proto: Ast.full.FnProto,
    lparen: Ast.TokenIndex,
    rparen: Ast.TokenIndex,
) bool

File

lib/std/zig/Ast/Render.zig:1739

Code

fn isOneLineFnProto(
    tree: Ast,
    fn_proto: Ast.full.FnProto,
    lparen: Ast.TokenIndex,
    rparen: Ast.TokenIndex,
) bool {
    const trailing_comma = tree.tokenTag(rparen - 1) == .comma;
    if (trailing_comma or hasComment(tree, lparen, rparen))
        return false;

    // Check that there are no doc comments
    var after_last_param = lparen + 1;
    for (fn_proto.ast.params) |expr| {
        // Looking before each param is insufficient since anytype is not included in `params`
        if (hasDocComment(tree, after_last_param, tree.firstToken(expr)))
            return false;
        after_last_param = tree.lastToken(expr) + 1;
    }
    return !hasDocComment(tree, after_last_param, rparen);
}