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.

hasComment

Returns true if there exists a line comment between any of the tokens from start_token to end_token. This is used to determine if e.g. a fn_proto should be wrapped and have a trailing comma inserted even if there is none in the source.

Render.hasComment
fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool

File

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

Code

fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
    for (start_token..end_token) |i| {
        const token: Ast.TokenIndex = @intCast(i);
        const start = tree.tokenStart(token) + tree.tokenSlice(token).len;
        const end = tree.tokenStart(token + 1);
        if (mem.findScalar(u8, tree.source[start..end], '/') != null) return true;
    }

    return false;
}