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.
fnserveDocsFile(
request: *std.http.Server.Request,
context: *Context,
name: []constu8,
content_type: []constu8,
) !void {
constgpa = context.gpa;
constio = context.io;
// The desired API is actually sendfile, which will require enhancing std.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 = trycontext.lib_dir.readFileAlloc(io, name, gpa, .limited(10 * 1024 * 1024));
defergpa.free(file_contents);
tryrequest.respond(file_contents, .{
.extra_headers = &.{
.{ .name = "content-type", .value = content_type },
cache_control_header,
},
});
}