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.

endInput

Completes processing of the input and returns the parsed document.

Parser.endInput
pub fn endInput(p: *Parser) Allocator.Error!Document

File

Code

pub fn endInput(p: *Parser) Allocator.Error!Document {
    while (p.pending_blocks.items.len > 0) {
        try p.closeLastBlock();
    }
    // There should be no inline content pending after closing the last open
    // block.
    assert(p.scratch_string.items.len == 0);

    const children = try p.addExtraChildren(@ptrCast(p.scratch_extra.items));
    p.nodes.items(.data)[0] = .{ .container = .{ .children = children } };
    p.scratch_string.items.len = 0;
    p.scratch_extra.items.len = 0;

    try p.extra.shrinkToLen(p.allocator);
    try p.string_bytes.shrinkToLen(p.allocator);

    return .{
        .nodes = p.nodes.toOwnedSlice(),
        .extra = p.extra.toOwnedSliceAssert(),
        .string_bytes = p.string_bytes.toOwnedSliceAssert(),
    };
}