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. Private Function
fnfindInstancesDirViaCLSID(gpa: Allocator, io: Io, registry: *Registry) error{ OutOfMemory, PathNotFound }!Dir {
constsetup_configuration_clsid = "{177f0c4a-1cd3-4de7-a32c-71dbbb9fa36d}";
// HKEY_CLASSES_ROOT is not a single key but instead a combination of// HKCU\Software\Classes and HKLM\Software\Classes with HKCU taking precedent// https://learn.microsoft.com/en-us/windows/win32/sysinfo/hkey-classes-root-key//// Instead of a CLASSES_ROOT abstraction, we emulate the behavior with a more// general abstraction, which also means we need to include `Classes` in the path since// we're starting from the `Software` keys instead of the "classes root".//// The advapi32 APIs with `HKEY_CLASSES_ROOT` go through `\REGISTRY\USER\<SID>_Classes`// instead of `\REGISTRY\USER\<SID>\Software\Classes`, but we go through the latter// because it allows us to take advantage of `RtlOpenCurrentUser` to avoid needing to implement// the logic for getting the current user registry path, and it appears that the two keys are// effectively equivalent. Further investigation of the relationship of these keys would probably// be beneficial, though.constsetup_config_key = registry.tryOpenSoftwareKeyWithPrecedence(&.{
.{ .root = .current_user },
.{ .root = .local_machine },
}, L("Classes\\CLSID\\" ++ setup_configuration_clsid)) catch |err| switch (err) {
error.KeyNotFound => returnerror.PathNotFound,
};
defersetup_config_key.close();
constinproc_server = setup_config_key.open(L("InprocServer32")) catchreturnerror.PathNotFound;
constdll_path = inproc_server.getString(gpa, .default, .wtf8) catch |err| switch (err) {
error.NotAString,
error.ValueNameNotFound,
error.StringNotFound,
=> returnerror.PathNotFound,
error.OutOfMemory => |e| returne,
};
defergpa.free(dll_path);
if (!std.fs.path.isAbsolute(dll_path)) returnerror.PathNotFound;
varpath_it = std.fs.path.componentIterator(dll_path);
// the .dll filename_ = path_it.last();
constroot_path = while (path_it.previous()) |dir_component| {
if (std.ascii.eqlIgnoreCase(dir_component.name, "VisualStudio")) {
breakdir_component.path;
}
} else {
returnerror.PathNotFound;
};
constinstances_path = trystd.fs.path.join(gpa, &.{ root_path, "Packages", "_Instances" });
defergpa.free(instances_path);
returnDir.openDirAbsolute(io, instances_path, .{ .iterate = true }) catchreturnerror.PathNotFound;
}