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.
pubfnQueryObjectName(handle: windows.HANDLE, out_buffer: []u16) QueryObjectNameError![]u16 {
constout_buffer_aligned = std.mem.alignInSlice(out_buffer, @alignOf(windows.OBJECT.NAME_INFORMATION)) orelsereturnerror.NameTooLong;
constinfo: *windows.OBJECT.NAME_INFORMATION = @ptrCast(out_buffer_aligned);
// buffer size is specified in bytesconstout_buffer_len = std.math.cast(windows.ULONG, out_buffer_aligned.len * 2) orelsestd.math.maxInt(windows.ULONG);
// last argument would return the length required for full_buffer, not exposed herereturnswitch (windows.ntdll.NtQueryObject(handle, .Name, info, out_buffer_len, null)) {
.SUCCESS => {
// info.Name from ObQueryNameString is documented to be empty if the object
// was "unnamed", not sure if this can happen for file handles
returnif (info.Name.isEmpty()) error.Unexpectedelseinfo.Name.slice();
},
.ACCESS_DENIED => error.AccessDenied,
.INVALID_HANDLE => error.InvalidHandle,
// triggered when the buffer is too small for the OBJECT_NAME_INFORMATION object (.INFO_LENGTH_MISMATCH),
// or if the buffer is too small for the file path returned (.BUFFER_OVERFLOW, .BUFFER_TOO_SMALL)
.INFO_LENGTH_MISMATCH, .BUFFER_OVERFLOW, .BUFFER_TOO_SMALL => error.NameTooLong,
else => |e| windows.unexpectedStatus(e),
};
}