Zig 0.17.0-dev (Split by item) 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 standard library.
std › Build › findImportPkgHashOrFatal Private Function findImportPkgHashOrFatal Doc Source Private Function std.Build.findImportPkgHashOrFatal
inline fn findImportPkgHashOrFatal (b : *Build , comptime asking_build_zig : type , comptime dep_name : []const u8 ) []const u8 Params b : *Build asking_build_zig : type dep_name : []const u8 File Build.zig: 1912
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935 inline fn findImportPkgHashOrFatal (b : *Build , comptime asking_build_zig : type , comptime dep_name : []const u8 ) []const u8 {
const build_runner = @import ("root" );
const deps = build_runner .dependencies ;
const arena = b .graph .arena ;
const b_pkg_hash , const b_pkg_deps = comptime for (@typeInfo (deps .packages ).@"struct" .decl_names ) |pkg_hash | {
const pkg = @field (deps .packages , pkg_hash );
if (@hasDecl (pkg , "build_zig" ) and pkg .build_zig == asking_build_zig ) break .{ pkg_hash , pkg .deps };
} else .{ "" , deps .root_deps };
if (!mem .eql (u8 , b_pkg_hash , b .pkg_hash )) {
const build_zig_path = b .root .join (arena , "build.zig" ) catch @panic ("OOM" );
panic ("{} is not the struct that corresponds to {f}" , .{
asking_build_zig , build_zig_path ,
});
}
comptime for (b_pkg_deps ) |dep | {
if (mem .eql (u8 , dep [0 ], dep_name )) return dep [1 ];
};
const full_path = b .root .join (arena , "build.zig.zon" ) catch @panic ("OOM" );
panic ("no dependency named {s} in {f}. All packages used in build.zig must be declared in this file" , .{
dep_name , full_path ,
});
}