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.
fndecl_fields_fallible(decl_index: Decl.Index) ![]Ast.Node.Index {
constdecl = decl_index.get();
constast = decl.file.get_ast();
switch (decl.categorize()) {
.type_function => {
// If the type function returns a reference to another type function, get the fields from thereif (decl.get_type_fn_return_type_fn()) |function_decl| {
returndecl_fields_fallible(function_decl);
}
// If the type function returns a container, such as a `struct`, read that container's fieldsif (decl.get_type_fn_return_expr()) |return_expr| {
switch (ast.nodeTag(return_expr)) {
.container_decl, .container_decl_trailing, .container_decl_two, .container_decl_two_trailing, .container_decl_arg, .container_decl_arg_trailing => {
returnast_decl_fields_fallible(ast, return_expr);
},
else => {},
}
}
return &.{};
},
else => {
constvalue_node = decl.value_node() orelsereturn &.{};
returnast_decl_fields_fallible(ast, value_node);
},
}
}