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.
pubfnserveFile(
ws: *WebServer,
request: *http.Server.Request,
path: Cache.Path,
content_type: []constu8,
) !void {
constgraph = ws.graph;
constgpa = graph.cache.gpa;
constio = graph.io;
// The desired API is actually sendfile, which will require enhancing http.Server.
// We load the file with every request so that the user can make changes to the file
// and refresh the HTML page without restarting this server.
constfile_contents = path.root_dir.handle.readFileAlloc(io, path.sub_path, gpa, .limited(10 * 1024 * 1024)) catch |err| {
log.err("failed to read '{f}': {t}", .{ path, err });
returnerror.AlreadyReported;
};
defergpa.free(file_contents);
tryrequest.respond(file_contents, .{
.extra_headers = &.{
.{ .name = "Content-Type", .value = content_type },
cache_control_header,
},
});
}