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.
fnnodeMayAppendToErrorTrace(tree: *constAst, start_node: Ast.Node.Index) bool {
varnode = start_node;
while (true) {
switch (tree.nodeTag(node)) {
// These don't have the opportunity to call any runtime functions.
.error_value,
.identifier,
.@"comptime",
=> returnfalse,
// Forward the question to the LHS sub-expression.
.@"try",
.@"nosuspend",
=> node = tree.nodeData(node).node,
.grouped_expression,
.unwrap_optional,
=> node = tree.nodeData(node).node_and_token[0],
// Anything that does not eval to an error is guaranteed to pop any
// additions to the error trace, so it effectively does not append.
else => returnnodeMayEvalToError(tree, start_node) != .never,
}
}
}