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.

collect_docs

main.collect_docs
fn collect_docs(
    list: *ArrayList(u8),
    ast: *const Ast,
    first_doc_comment: Ast.TokenIndex,
) Oom!void

File

lib/docs/wasm/main.zig:664

Code

fn collect_docs(
    list: *ArrayList(u8),
    ast: *const Ast,
    first_doc_comment: Ast.TokenIndex,
) Oom!void {
    list.clearRetainingCapacity();
    var it = first_doc_comment;
    while (true) : (it += 1) switch (ast.tokenTag(it)) {
        .doc_comment, .container_doc_comment => {
            // It is tempting to trim this string but think carefully about how
            // that will affect the markdown parser.
            const line = ast.tokenSlice(it)[3..];
            try list.appendSlice(gpa, line);
        },
        else => break,
    };
}