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.
fnhandle_registration_result(res: usize) !void {
switch (linux.errno(res)) {
.SUCCESS => {},
// One or more fds in the array are invalid, or the kernel does not support sparse sets:
.BADF => returnerror.FileDescriptorInvalid,
.BUSY => returnerror.FilesAlreadyRegistered,
.INVAL => returnerror.FilesEmpty,
// Adding `nr_args` file references would exceed the maximum allowed number of files the
// user is allowed to have according to the per-user RLIMIT_NOFILE resource limit and
// the CAP_SYS_RESOURCE capability is not set, or `nr_args` exceeds the maximum allowed
// for a fixed file set (older kernels have a limit of 1024 files vs 64K files):
.MFILE => returnerror.UserFdQuotaExceeded,
// Insufficient kernel resources, or the caller had a non-zero RLIMIT_MEMLOCK soft
// resource limit but tried to lock more memory than the limit permitted (not enforced
// when the process is privileged with CAP_IPC_LOCK):
.NOMEM => returnerror.SystemResources,
// Attempt to register files on a ring already registering files or being torn down:
.NXIO => returnerror.RingShuttingDownOrAlreadyRegisteringFiles,
else => |errno| returnposix.unexpectedErrno(errno),
}
}