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.
constUpdateSourceFiles = @This();
conststd = @import("std");
constStep = std.Build.Step;
constConfiguration = std.Build.Configuration;
step: Step,
embeds: std.ArrayList(Embed) = .empty,
copies: std.ArrayList(Copy) = .empty,
pubconstbase_tag: Step.Tag = .update_source_files;
pubconstEmbed = Step.WriteFile.Embed;
pubconstCopy = Step.WriteFile.Copy;
pubfncreate(owner: *std.Build) *UpdateSourceFiles {
constgraph = owner.graph;
constusf = graph.create(UpdateSourceFiles);
usf.* = .{
.step = .init(.{
.tag = base_tag,
.name = "UpdateSourceFiles",
.owner = owner,
}),
};
returnusf;
}
/// Overwrites a path relative to the build root with the contents of another file.////// Because it updates source files, this should not be used as part of the/// normal build process, but as a utility occasionally run by a developer with/// intent to modify source files and then commit those changes to version/// control.pubfnaddCopyFileToSource(usf: *UpdateSourceFiles, src_file: std.Build.LazyPath, sub_path: []constu8) void {
constgraph = usf.step.owner.graph;
constwc = &graph.wip_configuration;
constarena = graph.arena;
usf.copies.append(arena, .{
.sub_path = wc.addString(sub_path) catch@panic("OOM"),
.src_file = src_file.dupe(graph),
}) catch@panic("OOM");
src_file.addStepDependencies(&usf.step);
}
/// Overwrites a path relative to the package root with the provided bytes.////// Because it updates source files, this should not be used as part of the/// normal build process, but as a utility occasionally run by a developer with/// intent to modify source files and then commit those changes to version/// control.pubfnaddBytesToSource(usf: *UpdateSourceFiles, contents: []constu8, sub_path: []constu8) void {
constgraph = usf.step.owner.graph;
constwc = &graph.wip_configuration;
constarena = graph.arena;
usf.embeds.append(arena, .{
.sub_path = wc.addString(sub_path) catch@panic("OOM"),
.contents = wc.addBytes(contents) catch@panic("OOM"),
}) catch@panic("OOM");
}