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 library itself.

LazyIncludePaths

main.LazyIncludePaths
const LazyIncludePaths = struct

File

Code

const LazyIncludePaths = struct {
    arena: Allocator,
    io: Io,
    auto_includes_option: cli.Options.AutoIncludes,
    zig_lib_dir: []const u8,
    target_machine_type: std.coff.IMAGE.FILE.MACHINE,
    resolved_include_paths: ?[]const []const u8 = null,

    pub fn get(
        self: *LazyIncludePaths,
        error_handler: *ErrorHandler,
        environ_map: *const std.process.Environ.Map,
    ) ![]const []const u8 {
        const io = self.io;

        if (self.resolved_include_paths == null) {
            self.resolved_include_paths = getIncludePaths(
                self.arena,
                io,
                self.auto_includes_option,
                self.zig_lib_dir,
                self.target_machine_type,
                environ_map,
            ) catch |err| switch (err) {
                error.OutOfMemory => |e| return e,
                else => |e| {
                    switch (e) {
                        error.UnsupportedAutoIncludesMachineType => {
                            try error_handler.emitMessage(self.arena, io, .err, "automatic include path detection is not supported for target '{s}'", .{@tagName(self.target_machine_type)});
                        },
                        error.MsvcIncludesNotFound => {
                            try error_handler.emitMessage(self.arena, io, .err, "MSVC include paths could not be automatically detected", .{});
                        },
                        error.MingwIncludesNotFound => {
                            try error_handler.emitMessage(self.arena, io, .err, "MinGW include paths could not be automatically detected", .{});
                        },
                    }
                    try error_handler.emitMessage(self.arena, io, .note, "to disable auto includes, use the option /:auto-includes none", .{});
                    std.process.exit(1);
                },
            };
        }

        return self.resolved_include_paths.?;
    }
}