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.

setColorEnvironmentVariables

Run.setColorEnvironmentVariables
fn setColorEnvironmentVariables(
    conf_run: *const Configuration.Step.Run,
    environ_map: *EnvMap,
    terminal_mode: Io.Terminal.Mode,
) !void

File

Code

fn setColorEnvironmentVariables(
    conf_run: *const Configuration.Step.Run,
    environ_map: *EnvMap,
    terminal_mode: Io.Terminal.Mode,
) !void {
    color: switch (conf_run.flags.color) {
        .manual => {},
        .enable => {
            try environ_map.put("CLICOLOR_FORCE", "1");
            _ = environ_map.swapRemove("NO_COLOR");
        },
        .disable => {
            try environ_map.put("NO_COLOR", "1");
            _ = environ_map.swapRemove("CLICOLOR_FORCE");
        },
        .inherit => switch (terminal_mode) {
            .no_color, .windows_api => continue :color .disable,
            .escape_codes => continue :color .enable,
        },
        .auto => {
            const capture_stderr = conf_run.captured_stderr.value != null or switch (conf_run.flags.stdio) {
                .check => checksContainStderr(conf_run),
                .infer_from_args, .inherit, .zig_test => false,
            };
            if (capture_stderr) {
                continue :color .disable;
            } else {
                continue :color .inherit;
            }
        },
    }
}