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.

decl_fn_proto_html

main.decl_fn_proto_html
export fn decl_fn_proto_html(decl_index: Decl.Index, linkify_fn_name: bool) String

File

lib/docs/wasm/main.zig:520

Code

export fn decl_fn_proto_html(decl_index: Decl.Index, linkify_fn_name: bool) String {
    const decl = decl_index.get();
    const ast = decl.file.get_ast();
    const proto_node = switch (ast.nodeTag(decl.ast_node)) {
        .fn_decl => ast.nodeData(decl.ast_node).node_and_node[0],

        .fn_proto,
        .fn_proto_one,
        .fn_proto_simple,
        .fn_proto_multi,
        => decl.ast_node,

        else => unreachable,
    };

    string_result.clearRetainingCapacity();
    fileSourceHtml(decl.file, &string_result, proto_node, .{
        .skip_doc_comments = true,
        .skip_comments = true,
        .collapse_whitespace = true,
        .fn_link = if (linkify_fn_name) decl_index else .none,
    }) catch |err| {
        std.debug.panic("unable to render source: {s}", .{@errorName(err)});
    };
    return String.init(string_result.items);
}