authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-17 13:37:28-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-06-17 13:37:28-07:00
log9370fb8b81f69fb28311c00f0833883acfa93521
tree54abf9602bed1373299557e56fc9fcdf9adb9117
parent366e3c657fe7d898465a0e822f1999f0572f832e
parent7ca052a6fb017882de1ebcf86226f3b2927a11c7
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #14844 from perillo/fix-issue-13280

Fix issue 13280

2 files changed, 279 insertions(+), 74 deletions(-)

doc/docgen.zig+269-64
......@@ -796,28 +796,37 @@ fn writeEscaped(out: anytype, input: []const u8) !void {
796796 }
797797}
798798
799//#define VT_RED "\x1b[31;1m"
800//#define VT_GREEN "\x1b[32;1m"
801//#define VT_CYAN "\x1b[36;1m"
802//#define VT_WHITE "\x1b[37;1m"
803//#define VT_BOLD "\x1b[0;1m"
804//#define VT_RESET "\x1b[0m"
805
806test "term color" {
807 const input_bytes = "A\x1b[32;1mgreen\x1b[0mB";
808 const result = try termColor(std.testing.allocator, input_bytes);
809 defer std.testing.allocator.free(result);
810 try testing.expectEqualSlices(u8, "A<span class=\"t32_1\">green</span>B", result);
799// Returns true if number is in slice.
800fn in(slice: []const u8, number: u8) bool {
801 for (slice) |n| {
802 if (number == n) return true;
803 }
804 return false;
811805}
812806
813807fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
808 // The SRG sequences generates by the Zig compiler are in the format:
809 // ESC [ <foreground-color> ; <n> m
810 // or
811 // ESC [ <n> m
812 //
813 // where
814 // foreground-color is 31 (red), 32 (green), 36 (cyan)
815 // n is 0 (reset), 1 (bold), 2 (dim)
816 //
817 // Note that 37 (white) is currently not used by the compiler.
818 //
819 // See std.debug.TTY.Color.
820 const supported_sgr_colors = [_]u8{ 31, 32, 36 };
821 const supported_sgr_numbers = [_]u8{ 0, 1, 2 };
822
814823 var buf = std.ArrayList(u8).init(allocator);
815824 defer buf.deinit();
816825
817826 var out = buf.writer();
818 var number_start_index: usize = undefined;
819 var first_number: usize = undefined;
820 var second_number: usize = undefined;
827 var sgr_param_start_index: usize = undefined;
828 var sgr_num: u8 = undefined;
829 var sgr_color: u8 = undefined;
821830 var i: usize = 0;
822831 var state: enum {
823832 start,
......@@ -848,7 +857,7 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
848857 },
849858 .lbracket => switch (c) {
850859 '0'...'9' => {
851 number_start_index = i;
860 sgr_param_start_index = i;
852861 state = .number;
853862 },
854863 else => return error.UnsupportedEscape,
......@@ -856,13 +865,12 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
856865 .number => switch (c) {
857866 '0'...'9' => {},
858867 else => {
859 first_number = std.fmt.parseInt(usize, input[number_start_index..i], 10) catch unreachable;
860 second_number = 0;
868 sgr_num = try std.fmt.parseInt(u8, input[sgr_param_start_index..i], 10);
869 sgr_color = 0;
861870 state = .after_number;
862871 i -= 1;
863872 },
864873 },
865
866874 .after_number => switch (c) {
867875 ';' => state = .arg,
868876 'D' => state = .start,
......@@ -877,7 +885,7 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
877885 },
878886 .arg => switch (c) {
879887 '0'...'9' => {
880 number_start_index = i;
888 sgr_param_start_index = i;
881889 state = .arg_number;
882890 },
883891 else => return error.UnsupportedEscape,
......@@ -885,7 +893,15 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
885893 .arg_number => switch (c) {
886894 '0'...'9' => {},
887895 else => {
888 second_number = std.fmt.parseInt(usize, input[number_start_index..i], 10) catch unreachable;
896 // Keep the sequence consistent, foreground color first.
897 // 32;1m is equivalent to 1;32m, but the latter will
898 // generate an incorrect HTML class without notice.
899 sgr_color = sgr_num;
900 if (!in(&supported_sgr_colors, sgr_color)) return error.UnsupportedForegroundColor;
901
902 sgr_num = try std.fmt.parseInt(u8, input[sgr_param_start_index..i], 10);
903 if (!in(&supported_sgr_numbers, sgr_num)) return error.UnsupportedNumber;
904
889905 state = .expect_end;
890906 i -= 1;
891907 },
......@@ -896,10 +912,16 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
896912 while (open_span_count != 0) : (open_span_count -= 1) {
897913 try out.writeAll("</span>");
898914 }
899 if (first_number != 0 or second_number != 0) {
900 try out.print("<span class=\"t{d}_{d}\">", .{ first_number, second_number });
901 open_span_count += 1;
915 if (sgr_num == 0) {
916 if (sgr_color != 0) return error.UnsupportedColor;
917 continue;
902918 }
919 if (sgr_color != 0) {
920 try out.print("<span class=\"sgr-{d}_{d}m\">", .{ sgr_color, sgr_num });
921 } else {
922 try out.print("<span class=\"sgr-{d}m\">", .{sgr_num});
923 }
924 open_span_count += 1;
903925 },
904926 else => return error.UnsupportedEscape,
905927 },
......@@ -1227,41 +1249,39 @@ fn printShell(out: anytype, shell_content: []const u8, escape: bool) !void {
12271249 while (iter.next()) |orig_line| {
12281250 const line = mem.trimRight(u8, orig_line, " ");
12291251 if (!cmd_cont and line.len > 1 and mem.eql(u8, line[0..2], "$ ") and line[line.len - 1] != '\\') {
1230 try out.writeAll(start_line ++ "$ <kbd>");
1252 try out.writeAll("$ <kbd>");
12311253 const s = std.mem.trimLeft(u8, line[1..], " ");
12321254 if (escape) {
12331255 try writeEscaped(out, s);
12341256 } else {
12351257 try out.writeAll(s);
12361258 }
1237 try out.writeAll("</kbd>" ++ end_line ++ "\n");
1259 try out.writeAll("</kbd>" ++ "\n");
12381260 } else if (!cmd_cont and line.len > 1 and mem.eql(u8, line[0..2], "$ ") and line[line.len - 1] == '\\') {
1239 try out.writeAll(start_line ++ "$ <kbd>");
1261 try out.writeAll("$ <kbd>");
12401262 const s = std.mem.trimLeft(u8, line[1..], " ");
12411263 if (escape) {
12421264 try writeEscaped(out, s);
12431265 } else {
12441266 try out.writeAll(s);
12451267 }
1246 try out.writeAll(end_line ++ "\n");
1268 try out.writeAll("\n");
12471269 cmd_cont = true;
12481270 } else if (line.len > 0 and line[line.len - 1] != '\\' and cmd_cont) {
1249 try out.writeAll(start_line);
12501271 if (escape) {
12511272 try writeEscaped(out, line);
12521273 } else {
12531274 try out.writeAll(line);
12541275 }
1255 try out.writeAll("</kbd>" ++ end_line ++ "\n");
1276 try out.writeAll("</kbd>" ++ "\n");
12561277 cmd_cont = false;
12571278 } else {
1258 try out.writeAll(start_line);
12591279 if (escape) {
12601280 try writeEscaped(out, line);
12611281 } else {
12621282 try out.writeAll(line);
12631283 }
1264 try out.writeAll(end_line ++ "\n");
1284 try out.writeAll("\n");
12651285 }
12661286 }
12671287
......@@ -1507,7 +1527,7 @@ fn genHtml(
15071527 const colored_stderr = try termColor(allocator, escaped_stderr);
15081528 const colored_stdout = try termColor(allocator, escaped_stdout);
15091529
1510 try shell_out.print("\n$ ./{s}\n{s}{s}", .{ code.name, colored_stdout, colored_stderr });
1530 try shell_out.print("$ ./{s}\n{s}{s}", .{ code.name, colored_stdout, colored_stderr });
15111531 if (exited_with_signal) {
15121532 try shell_out.print("(process terminated by signal)", .{});
15131533 }
......@@ -1877,7 +1897,193 @@ fn dumpArgs(args: []const []const u8) void {
18771897 print("\n", .{});
18781898}
18791899
1880test "shell parsed" {
1900test "term supported colors" {
1901 const test_allocator = testing.allocator;
1902
1903 {
1904 const input = "A\x1b[31;1mred\x1b[0mB";
1905 const expect = "A<span class=\"sgr-31_1m\">red</span>B";
1906
1907 const result = try termColor(test_allocator, input);
1908 defer test_allocator.free(result);
1909 try testing.expectEqualSlices(u8, expect, result);
1910 }
1911
1912 {
1913 const input = "A\x1b[32;1mgreen\x1b[0mB";
1914 const expect = "A<span class=\"sgr-32_1m\">green</span>B";
1915
1916 const result = try termColor(test_allocator, input);
1917 defer test_allocator.free(result);
1918 try testing.expectEqualSlices(u8, expect, result);
1919 }
1920
1921 {
1922 const input = "A\x1b[36;1mcyan\x1b[0mB";
1923 const expect = "A<span class=\"sgr-36_1m\">cyan</span>B";
1924
1925 const result = try termColor(test_allocator, input);
1926 defer test_allocator.free(result);
1927 try testing.expectEqualSlices(u8, expect, result);
1928 }
1929
1930 {
1931 const input = "A\x1b[1mbold\x1b[0mB";
1932 const expect = "A<span class=\"sgr-1m\">bold</span>B";
1933
1934 const result = try termColor(test_allocator, input);
1935 defer test_allocator.free(result);
1936 try testing.expectEqualSlices(u8, expect, result);
1937 }
1938
1939 {
1940 const input = "A\x1b[2mdim\x1b[0mB";
1941 const expect = "A<span class=\"sgr-2m\">dim</span>B";
1942
1943 const result = try termColor(test_allocator, input);
1944 defer test_allocator.free(result);
1945 try testing.expectEqualSlices(u8, expect, result);
1946 }
1947}
1948
1949test "term output from zig" {
1950 // Use data generated by https://github.com/perillo/zig-tty-test-data,
1951 // with zig version 0.11.0-dev.1898+36d47dd19.
1952 const test_allocator = testing.allocator;
1953
1954 {
1955 // 1.1-with-build-progress.out
1956 const input = "Semantic Analysis [1324] \x1b[25D\x1b[0KLLVM Emit Object... \x1b[20D\x1b[0KLLVM Emit Object... \x1b[20D\x1b[0KLLD Link... \x1b[12D\x1b[0K";
1957 const expect = "";
1958
1959 const result = try termColor(test_allocator, input);
1960 defer test_allocator.free(result);
1961 try testing.expectEqualSlices(u8, expect, result);
1962 }
1963
1964 {
1965 // 2.1-with-reference-traces.out
1966 const input = "\x1b[1msrc/2.1-with-reference-traces.zig:3:7: \x1b[31;1merror: \x1b[0m\x1b[1mcannot assign to constant\n\x1b[0m x += 1;\n \x1b[32;1m~~^~~~\n\x1b[0m\x1b[0m\x1b[2mreferenced by:\n main: src/2.1-with-reference-traces.zig:7:5\n callMain: /usr/local/lib/zig/lib/std/start.zig:607:17\n remaining reference traces hidden; use '-freference-trace' to see all reference traces\n\n\x1b[0m";
1967 const expect =
1968 \\<span class="sgr-1m">src/2.1-with-reference-traces.zig:3:7: </span><span class="sgr-31_1m">error: </span><span class="sgr-1m">cannot assign to constant
1969 \\</span> x += 1;
1970 \\ <span class="sgr-32_1m">~~^~~~
1971 \\</span><span class="sgr-2m">referenced by:
1972 \\ main: src/2.1-with-reference-traces.zig:7:5
1973 \\ callMain: /usr/local/lib/zig/lib/std/start.zig:607:17
1974 \\ remaining reference traces hidden; use '-freference-trace' to see all reference traces
1975 \\
1976 \\</span>
1977 ;
1978
1979 const result = try termColor(test_allocator, input);
1980 defer test_allocator.free(result);
1981 try testing.expectEqualSlices(u8, expect, result);
1982 }
1983
1984 {
1985 // 2.2-without-reference-traces.out
1986 const input = "\x1b[1m/usr/local/lib/zig/lib/std/io/fixed_buffer_stream.zig:128:29: \x1b[31;1merror: \x1b[0m\x1b[1minvalid type given to fixedBufferStream\n\x1b[0m else => @compileError(\"invalid type given to fixedBufferStream\"),\n \x1b[32;1m^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\x1b[0m\x1b[1m/usr/local/lib/zig/lib/std/io/fixed_buffer_stream.zig:116:66: \x1b[36;1mnote: \x1b[0m\x1b[1mcalled from here\n\x1b[0mpub fn fixedBufferStream(buffer: anytype) FixedBufferStream(Slice(@TypeOf(buffer))) {\n; \x1b[32;1m~~~~~^~~~~~~~~~~~~~~~~\n\x1b[0m";
1987 const expect =
1988 \\<span class="sgr-1m">/usr/local/lib/zig/lib/std/io/fixed_buffer_stream.zig:128:29: </span><span class="sgr-31_1m">error: </span><span class="sgr-1m">invalid type given to fixedBufferStream
1989 \\</span> else => @compileError("invalid type given to fixedBufferStream"),
1990 \\ <span class="sgr-32_1m">^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1991 \\</span><span class="sgr-1m">/usr/local/lib/zig/lib/std/io/fixed_buffer_stream.zig:116:66: </span><span class="sgr-36_1m">note: </span><span class="sgr-1m">called from here
1992 \\</span>pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(Slice(@TypeOf(buffer))) {
1993 \\; <span class="sgr-32_1m">~~~~~^~~~~~~~~~~~~~~~~
1994 \\</span>
1995 ;
1996
1997 const result = try termColor(test_allocator, input);
1998 defer test_allocator.free(result);
1999 try testing.expectEqualSlices(u8, expect, result);
2000 }
2001
2002 {
2003 // 2.3-with-notes.out
2004 const input = "\x1b[1msrc/2.3-with-notes.zig:6:9: \x1b[31;1merror: \x1b[0m\x1b[1mexpected type '*2.3-with-notes.Derp', found '*2.3-with-notes.Wat'\n\x1b[0m bar(w);\n \x1b[32;1m^\n\x1b[0m\x1b[1msrc/2.3-with-notes.zig:6:9: \x1b[36;1mnote: \x1b[0m\x1b[1mpointer type child '2.3-with-notes.Wat' cannot cast into pointer type child '2.3-with-notes.Derp'\n\x1b[0m\x1b[1msrc/2.3-with-notes.zig:2:13: \x1b[36;1mnote: \x1b[0m\x1b[1mopaque declared here\n\x1b[0mconst Wat = opaque {};\n \x1b[32;1m^~~~~~~~~\n\x1b[0m\x1b[1msrc/2.3-with-notes.zig:1:14: \x1b[36;1mnote: \x1b[0m\x1b[1mopaque declared here\n\x1b[0mconst Derp = opaque {};\n \x1b[32;1m^~~~~~~~~\n\x1b[0m\x1b[1msrc/2.3-with-notes.zig:4:18: \x1b[36;1mnote: \x1b[0m\x1b[1mparameter type declared here\n\x1b[0mextern fn bar(d: *Derp) void;\n \x1b[32;1m^~~~~\n\x1b[0m\x1b[0m\x1b[2mreferenced by:\n main: src/2.3-with-notes.zig:10:5\n callMain: /usr/local/lib/zig/lib/std/start.zig:607:17\n remaining reference traces hidden; use '-freference-trace' to see all reference traces\n\n\x1b[0m";
2005 const expect =
2006 \\<span class="sgr-1m">src/2.3-with-notes.zig:6:9: </span><span class="sgr-31_1m">error: </span><span class="sgr-1m">expected type '*2.3-with-notes.Derp', found '*2.3-with-notes.Wat'
2007 \\</span> bar(w);
2008 \\ <span class="sgr-32_1m">^
2009 \\</span><span class="sgr-1m">src/2.3-with-notes.zig:6:9: </span><span class="sgr-36_1m">note: </span><span class="sgr-1m">pointer type child '2.3-with-notes.Wat' cannot cast into pointer type child '2.3-with-notes.Derp'
2010 \\</span><span class="sgr-1m">src/2.3-with-notes.zig:2:13: </span><span class="sgr-36_1m">note: </span><span class="sgr-1m">opaque declared here
2011 \\</span>const Wat = opaque {};
2012 \\ <span class="sgr-32_1m">^~~~~~~~~
2013 \\</span><span class="sgr-1m">src/2.3-with-notes.zig:1:14: </span><span class="sgr-36_1m">note: </span><span class="sgr-1m">opaque declared here
2014 \\</span>const Derp = opaque {};
2015 \\ <span class="sgr-32_1m">^~~~~~~~~
2016 \\</span><span class="sgr-1m">src/2.3-with-notes.zig:4:18: </span><span class="sgr-36_1m">note: </span><span class="sgr-1m">parameter type declared here
2017 \\</span>extern fn bar(d: *Derp) void;
2018 \\ <span class="sgr-32_1m">^~~~~
2019 \\</span><span class="sgr-2m">referenced by:
2020 \\ main: src/2.3-with-notes.zig:10:5
2021 \\ callMain: /usr/local/lib/zig/lib/std/start.zig:607:17
2022 \\ remaining reference traces hidden; use '-freference-trace' to see all reference traces
2023 \\
2024 \\</span>
2025 ;
2026
2027 const result = try termColor(test_allocator, input);
2028 defer test_allocator.free(result);
2029 try testing.expectEqualSlices(u8, expect, result);
2030 }
2031
2032 {
2033 // 3.1-with-error-return-traces.out
2034
2035 const input = "error: Error\n\x1b[1m/home/zig/src/3.1-with-error-return-traces.zig:5:5\x1b[0m: \x1b[2m0x20b008 in callee (3.1-with-error-return-traces)\x1b[0m\n return error.Error;\n \x1b[32;1m^\x1b[0m\n\x1b[1m/home/zig/src/3.1-with-error-return-traces.zig:9:5\x1b[0m: \x1b[2m0x20b113 in caller (3.1-with-error-return-traces)\x1b[0m\n try callee();\n \x1b[32;1m^\x1b[0m\n\x1b[1m/home/zig/src/3.1-with-error-return-traces.zig:13:5\x1b[0m: \x1b[2m0x20b153 in main (3.1-with-error-return-traces)\x1b[0m\n try caller();\n \x1b[32;1m^\x1b[0m\n";
2036 const expect =
2037 \\error: Error
2038 \\<span class="sgr-1m">/home/zig/src/3.1-with-error-return-traces.zig:5:5</span>: <span class="sgr-2m">0x20b008 in callee (3.1-with-error-return-traces)</span>
2039 \\ return error.Error;
2040 \\ <span class="sgr-32_1m">^</span>
2041 \\<span class="sgr-1m">/home/zig/src/3.1-with-error-return-traces.zig:9:5</span>: <span class="sgr-2m">0x20b113 in caller (3.1-with-error-return-traces)</span>
2042 \\ try callee();
2043 \\ <span class="sgr-32_1m">^</span>
2044 \\<span class="sgr-1m">/home/zig/src/3.1-with-error-return-traces.zig:13:5</span>: <span class="sgr-2m">0x20b153 in main (3.1-with-error-return-traces)</span>
2045 \\ try caller();
2046 \\ <span class="sgr-32_1m">^</span>
2047 \\
2048 ;
2049
2050 const result = try termColor(test_allocator, input);
2051 defer test_allocator.free(result);
2052 try testing.expectEqualSlices(u8, expect, result);
2053 }
2054
2055 {
2056 // 3.2-with-stack-trace.out
2057 const input = "\x1b[1m/usr/local/lib/zig/lib/std/debug.zig:561:19\x1b[0m: \x1b[2m0x22a107 in writeCurrentStackTrace__anon_5898 (3.2-with-stack-trace)\x1b[0m\n while (it.next()) |return_address| {\n \x1b[32;1m^\x1b[0m\n\x1b[1m/usr/local/lib/zig/lib/std/debug.zig:157:80\x1b[0m: \x1b[2m0x20bb23 in dumpCurrentStackTrace (3.2-with-stack-trace)\x1b[0m\n writeCurrentStackTrace(stderr, debug_info, detectTTYConfig(io.getStdErr()), start_addr) catch |err| {\n \x1b[32;1m^\x1b[0m\n\x1b[1m/home/zig/src/3.2-with-stack-trace.zig:5:36\x1b[0m: \x1b[2m0x20d3b2 in foo (3.2-with-stack-trace)\x1b[0m\n std.debug.dumpCurrentStackTrace(null);\n \x1b[32;1m^\x1b[0m\n\x1b[1m/home/zig/src/3.2-with-stack-trace.zig:9:8\x1b[0m: \x1b[2m0x20b458 in main (3.2-with-stack-trace)\x1b[0m\n foo();\n \x1b[32;1m^\x1b[0m\n\x1b[1m/usr/local/lib/zig/lib/std/start.zig:607:22\x1b[0m: \x1b[2m0x20a965 in posixCallMainAndExit (3.2-with-stack-trace)\x1b[0m\n root.main();\n \x1b[32;1m^\x1b[0m\n\x1b[1m/usr/local/lib/zig/lib/std/start.zig:376:5\x1b[0m: \x1b[2m0x20a411 in _start (3.2-with-stack-trace)\x1b[0m\n @call(.never_inline, posixCallMainAndExit, .{});\n \x1b[32;1m^\x1b[0m\n";
2058 const expect =
2059 \\<span class="sgr-1m">/usr/local/lib/zig/lib/std/debug.zig:561:19</span>: <span class="sgr-2m">0x22a107 in writeCurrentStackTrace__anon_5898 (3.2-with-stack-trace)</span>
2060 \\ while (it.next()) |return_address| {
2061 \\ <span class="sgr-32_1m">^</span>
2062 \\<span class="sgr-1m">/usr/local/lib/zig/lib/std/debug.zig:157:80</span>: <span class="sgr-2m">0x20bb23 in dumpCurrentStackTrace (3.2-with-stack-trace)</span>
2063 \\ writeCurrentStackTrace(stderr, debug_info, detectTTYConfig(io.getStdErr()), start_addr) catch |err| {
2064 \\ <span class="sgr-32_1m">^</span>
2065 \\<span class="sgr-1m">/home/zig/src/3.2-with-stack-trace.zig:5:36</span>: <span class="sgr-2m">0x20d3b2 in foo (3.2-with-stack-trace)</span>
2066 \\ std.debug.dumpCurrentStackTrace(null);
2067 \\ <span class="sgr-32_1m">^</span>
2068 \\<span class="sgr-1m">/home/zig/src/3.2-with-stack-trace.zig:9:8</span>: <span class="sgr-2m">0x20b458 in main (3.2-with-stack-trace)</span>
2069 \\ foo();
2070 \\ <span class="sgr-32_1m">^</span>
2071 \\<span class="sgr-1m">/usr/local/lib/zig/lib/std/start.zig:607:22</span>: <span class="sgr-2m">0x20a965 in posixCallMainAndExit (3.2-with-stack-trace)</span>
2072 \\ root.main();
2073 \\ <span class="sgr-32_1m">^</span>
2074 \\<span class="sgr-1m">/usr/local/lib/zig/lib/std/start.zig:376:5</span>: <span class="sgr-2m">0x20a411 in _start (3.2-with-stack-trace)</span>
2075 \\ @call(.never_inline, posixCallMainAndExit, .{});
2076 \\ <span class="sgr-32_1m">^</span>
2077 \\
2078 ;
2079
2080 const result = try termColor(test_allocator, input);
2081 defer test_allocator.free(result);
2082 try testing.expectEqualSlices(u8, expect, result);
2083 }
2084}
2085
2086test "printShell" {
18812087 const test_allocator = std.testing.allocator;
18822088
18832089 {
......@@ -1885,7 +2091,7 @@ test "shell parsed" {
18852091 \\$ zig build test.zig
18862092 ;
18872093 const expected =
1888 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig</kbd></span>
2094 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig</kbd>
18892095 \\</samp></pre></figure>
18902096 ;
18912097
......@@ -1893,7 +2099,6 @@ test "shell parsed" {
18932099 defer buffer.deinit();
18942100
18952101 try printShell(buffer.writer(), shell_out, false);
1896 std.log.emerg("{s}", .{buffer.items});
18972102 try testing.expectEqualSlices(u8, expected, buffer.items);
18982103 }
18992104 {
......@@ -1902,8 +2107,8 @@ test "shell parsed" {
19022107 \\build output
19032108 ;
19042109 const expected =
1905 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig</kbd></span>
1906 \\<span class="line">build output</span>
2110 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig</kbd>
2111 \\build output
19072112 \\</samp></pre></figure>
19082113 ;
19092114
......@@ -1920,9 +2125,9 @@ test "shell parsed" {
19202125 \\$ ./test
19212126 ;
19222127 const expected =
1923 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig</kbd></span>
1924 \\<span class="line">build output</span>
1925 \\<span class="line">$ <kbd>./test</kbd></span>
2128 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig</kbd>
2129 \\build output
2130 \\$ <kbd>./test</kbd>
19262131 \\</samp></pre></figure>
19272132 ;
19282133
......@@ -1940,10 +2145,10 @@ test "shell parsed" {
19402145 \\output
19412146 ;
19422147 const expected =
1943 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig</kbd></span>
1944 \\<span class="line"></span>
1945 \\<span class="line">$ <kbd>./test</kbd></span>
1946 \\<span class="line">output</span>
2148 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig</kbd>
2149 \\
2150 \\$ <kbd>./test</kbd>
2151 \\output
19472152 \\</samp></pre></figure>
19482153 ;
19492154
......@@ -1960,9 +2165,9 @@ test "shell parsed" {
19602165 \\output
19612166 ;
19622167 const expected =
1963 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig</kbd></span>
1964 \\<span class="line">$ <kbd>./test</kbd></span>
1965 \\<span class="line">output</span>
2168 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig</kbd>
2169 \\$ <kbd>./test</kbd>
2170 \\output
19662171 \\</samp></pre></figure>
19672172 ;
19682173
......@@ -1981,11 +2186,11 @@ test "shell parsed" {
19812186 \\output
19822187 ;
19832188 const expected =
1984 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig \</span>
1985 \\<span class="line"> --build-option</kbd></span>
1986 \\<span class="line">build output</span>
1987 \\<span class="line">$ <kbd>./test</kbd></span>
1988 \\<span class="line">output</span>
2189 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig \
2190 \\ --build-option</kbd>
2191 \\build output
2192 \\$ <kbd>./test</kbd>
2193 \\output
19892194 \\</samp></pre></figure>
19902195 ;
19912196
......@@ -1999,15 +2204,15 @@ test "shell parsed" {
19992204 // intentional space after "--build-option1 \"
20002205 const shell_out =
20012206 \\$ zig build test.zig \
2002 \\ --build-option1 \
2207 \\ --build-option1 \
20032208 \\ --build-option2
20042209 \\$ ./test
20052210 ;
20062211 const expected =
2007 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig \</span>
2008 \\<span class="line"> --build-option1 \</span>
2009 \\<span class="line"> --build-option2</kbd></span>
2010 \\<span class="line">$ <kbd>./test</kbd></span>
2212 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig \
2213 \\ --build-option1 \
2214 \\ --build-option2</kbd>
2215 \\$ <kbd>./test</kbd>
20112216 \\</samp></pre></figure>
20122217 ;
20132218
......@@ -2023,8 +2228,8 @@ test "shell parsed" {
20232228 \\$ ./test
20242229 ;
20252230 const expected =
2026 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig \</span>
2027 \\<span class="line">$ ./test</kbd></span>
2231 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig \
2232 \\$ ./test</kbd>
20282233 \\</samp></pre></figure>
20292234 ;
20302235
......@@ -2041,9 +2246,9 @@ test "shell parsed" {
20412246 \\$1
20422247 ;
20432248 const expected =
2044 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$ <kbd>zig build test.zig</kbd></span>
2045 \\<span class="line">$ <kbd>./test</kbd></span>
2046 \\<span class="line">$1</span>
2249 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$ <kbd>zig build test.zig</kbd>
2250 \\$ <kbd>./test</kbd>
2251 \\$1
20472252 \\</samp></pre></figure>
20482253 ;
20492254
......@@ -2058,7 +2263,7 @@ test "shell parsed" {
20582263 \\$zig build test.zig
20592264 ;
20602265 const expected =
2061 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp><span class="line">$zig build test.zig</span>
2266 \\<figure><figcaption class="shell-cap">Shell</figcaption><pre><samp>$zig build test.zig
20622267 \\</samp></pre></figure>
20632268 ;
20642269
doc/langref.html.in+10-10
......@@ -71,19 +71,19 @@
7171 text-align: left;
7272 font-weight: normal;
7373 }
74 .t0_1, .t37, .t37_1 {
74 .sgr-1m {
7575 font-weight: bold;
7676 }
77 .t2_0 {
77 .sgr-2m {
7878 color: #575757;
7979 }
80 .t31_1 {
80 .sgr-31_1m {
8181 color: #b40000;
8282 }
83 .t32_1 {
83 .sgr-32_1m {
8484 color: green;
8585 }
86 .t36_1 {
86 .sgr-36_1m {
8787 color: #005C7A;
8888 }
8989 .file {
......@@ -114,7 +114,7 @@
114114 line-height: normal;
115115 }
116116 kbd {
117 font-weight: bold;
117 font-weight: normal;
118118 }
119119 .table-wrapper {
120120 width: 100%;
......@@ -232,16 +232,16 @@
232232 table, th, td {
233233 border-color: grey;
234234 }
235 .t2_0 {
235 .sgr-2m {
236236 color: grey;
237237 }
238 .t31_1 {
238 .sgr-31_1m {
239239 color: red;
240240 }
241 .t32_1 {
241 .sgr-32_1m {
242242 color: #00B800;
243243 }
244 .t36_1 {
244 .sgr-36_1m {
245245 color: #0086b3;
246246 }
247247 code {