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.
constInstallDir = @This();
conststd = @import("std");
constmem = std.mem;
constfs = std.fs;
constStep = std.Build.Step;
constLazyPath = std.Build.LazyPath;
step: Step,
options: Options,
pubconstbase_tag: Step.Tag = .install_dir;
pubconstOptions = struct {
source_dir: LazyPath,
install_dir: std.Build.InstallDir,
install_subdir: []constu8,
/// File paths which end in any of these suffixes will be excluded/// from being installed.exclude_extensions: []const []constu8 = &.{},
/// Only file paths which end in any of these suffixes will be included/// in installation. `null` means all suffixes are valid for this option./// `exclude_extensions` take precedence over `include_extensions`include_extensions: ?[]const []constu8 = null,
/// File paths which end in any of these suffixes will result in/// empty files being installed. This is mainly intended for large/// test.zig files in order to prevent needless installation bloat./// However if the files were not present at all, then/// `@import("test.zig")` would be a compile error.blank_extensions: []const []constu8 = &.{},
fndupe(opts: Options, graph: *conststd.Build.Graph) Options {
return .{
.source_dir = opts.source_dir.dupe(graph),
.install_dir = opts.install_dir.dupe(graph),
.install_subdir = graph.dupeString(opts.install_subdir),
.exclude_extensions = graph.dupeStrings(opts.exclude_extensions),
.include_extensions = if (opts.include_extensions) |incs| graph.dupeStrings(incs) elsenull,
.blank_extensions = graph.dupeStrings(opts.blank_extensions),
};
}
};
pubfncreate(owner: *std.Build, options: Options) *InstallDir {
constinstall_dir = owner.allocator.create(InstallDir) catch@panic("OOM");
constgraph = owner.graph;
install_dir.* = .{
.step = Step.init(.{
.tag = base_tag,
.name = owner.fmt("install {f}/", .{options.source_dir}),
.owner = owner,
}),
.options = options.dupe(graph),
};
options.source_dir.addStepDependencies(&install_dir.step);
returninstall_dir;
}