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.
fnwindowsApiUpdateTask(io: Io) WorkerError!void {
// Store this data in the thread so that it does not need to be part of the
// linker data of the main executable.
varserialized_buffer: Serialized.Buffer = undefined;
serialized_buffer.init();
deferserialized_buffer.batch.cancel(io);
// In this function we bypass the wrapper code inside `Io.lockStderr` /
// `Io.tryLockStderr` in order to avoid clearing the terminal twice.
// We still want to go through the `Io` instance however in case it uses a
// task-switching mutex.
trymaybeUpdateSize(io, trywait(io, global_progress.initial_delay_ns));
errdefer {
constcancel_protection = io.swapCancelProtection(.blocked);
defer_ = io.swapCancelProtection(cancel_protection);
_ = io.vtable.lockStderr(io.userdata, null) catch |err| switch (err) {
error.Canceled => unreachable, // blocked
};
deferio.unlockStderr();
clearWrittenWindowsApi(io) catch {};
}
while (true) {
constbuffer, constnl_n = trycomputeRedraw(io, &serialized_buffer);
if (io.vtable.tryLockStderr(io.userdata, null) catchreturn) |locked_stderr| {
deferio.unlockStderr();
tryclearWrittenWindowsApi(io);
trywindowsApiWriteMarker(io);
global_progress.need_clear = true;
locked_stderr.file_writer.interface.writeAll(buffer) catch |err| switch (err) {
error.WriteFailed => returnlocked_stderr.file_writer.err.?,
};
windowsApiMoveToMarker(io, nl_n) catchreturn;
}
trymaybeUpdateSize(io, trywait(io, global_progress.refresh_rate_ns));
}
}