Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Function

isOneLineContainerDecl

Private Function
std.zig.Ast.Render.isOneLineContainerDecl
fn isOneLineContainerDecl(
    tree: Ast,
    container_decl: Ast.full.ContainerDecl,
    lbrace: Ast.TokenIndex,
    rbrace: Ast.TokenIndex,
) bool

Params

  • tree: Ast
  • container_decl: Ast.full.ContainerDecl
  • lbrace: Ast.TokenIndex
  • rbrace: Ast.TokenIndex

File

zig/Ast/Render.zig:2310
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
fn isOneLineContainerDecl(
    tree: Ast,
    container_decl: Ast.full.ContainerDecl,
    lbrace: Ast.TokenIndex,
    rbrace: Ast.TokenIndex,
) bool {
    // We print all the members in one-line unless one of the following conditions are true:

    // 1. The container has comments or multiline strings.
    if (hasComment(tree, lbrace, rbrace) or hasMultilineString(tree, lbrace, rbrace)) {
        return false;
    }

    // 2. The container has a container comment.
    if (tree.tokenTag(lbrace + 1) == .container_doc_comment) return false;

    // 3. A member of the container has a doc comment.
    if (hasDocComment(tree, lbrace + 1, rbrace))
        return false;

    // 4. The container has non-field members.
    for (container_decl.ast.members) |member| {
        if (tree.fullContainerField(member) == null) return false;
    }

    return true;
}