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 standard library. Private Function
fnbestDescendent(self: *constSelf, first_child_index: usize, first_grandchild_index: usize, target_order: Order) ItemAndIndex {
constsecond_child_index = first_child_index + 1;
if (first_grandchild_index >= self.len) {
// No grandchildren, find the best child (second may not exist)if (second_child_index >= self.len) {
return .{
.item = self.items[first_child_index],
.index = first_child_index,
};
} else {
returnself.bestItemAtIndices(first_child_index, second_child_index, target_order);
}
}
constsecond_grandchild_index = first_grandchild_index + 1;
if (second_grandchild_index >= self.len) {
// One grandchild, so we know there is a second child. Compare first grandchild and second childreturnself.bestItemAtIndices(first_grandchild_index, second_child_index, target_order);
}
constbest_left_grandchild_index = self.bestItemAtIndices(first_grandchild_index, second_grandchild_index, target_order).index;
constthird_grandchild_index = second_grandchild_index + 1;
if (third_grandchild_index >= self.len) {
// Two grandchildren, and we know the best. Compare this to second child.returnself.bestItemAtIndices(best_left_grandchild_index, second_child_index, target_order);
} else {
// Three grandchildren, compare the min of the first two with the thirdreturnself.bestItemAtIndices(best_left_grandchild_index, third_grandchild_index, target_order);
}
}