From b60f2d0c9fa1d31c817ed39f87cf7619ff742dd3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 3 Apr 2019 17:39:07 -0400 Subject: [PATCH] langref: rework the theming and layout * Instead of the only color scheme being dark, the language reference now has a light theme by default, and respects the user's light/dark preference via prefers-color-scheme media query. Most browsers don't support this yet, so we just have to wait patiently for the future to arrive. closes #2172. * Instead of a side bar index, the index is inline with the rest of the content. This is simpler and more friendly to all user agents, and means we don't need the media query for mobile devices. It also makes back-references work, so now headers link to the table of contents and the table of contents links to headers. --- doc/docgen.zig | 20 +++++-- doc/langref.html.in | 133 +++++++++++++++++++++++++++----------------- 2 files changed, 97 insertions(+), 56 deletions(-) diff --git a/doc/docgen.zig b/doc/docgen.zig index 63f46ccb6dc00b7c74842f98439a2b6486f05c5e..02a1458dc13bba9ab485473f33bfe28cdef38355 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -385,7 +385,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { last_action = Action.Open; } try toc.writeByteNTimes(' ', 4 + header_stack_size * 4); - try toc.print("
  • {}", urlized, content); + try toc.print("
  • {}", urlized, urlized, content); } else if (mem.eql(u8, tag_name, "header_close")) { if (header_stack_size == 0) { return parseError(tokenizer, tag_token, "unbalanced close header"); @@ -706,10 +706,10 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 { } const builtin_types = [][]const u8{ - "f16", "f32", "f64", "f128", "c_longdouble", "c_short", - "c_ushort", "c_int", "c_uint", "c_long", "c_ulong", "c_longlong", - "c_ulonglong", "c_char", "c_void", "void", "bool", "isize", - "usize", "noreturn", "type", "anyerror", "comptime_int", "comptime_float", + "f16", "f32", "f64", "f128", "c_longdouble", "c_short", + "c_ushort", "c_int", "c_uint", "c_long", "c_ulong", "c_longlong", + "c_ulonglong", "c_char", "c_void", "void", "bool", "isize", + "usize", "noreturn", "type", "anyerror", "comptime_int", "comptime_float", }; fn isType(name: []const u8) bool { @@ -965,7 +965,15 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try out.write(""); }, Node.HeaderOpen => |info| { - try out.print("{}\n", info.n, info.url, info.url, info.name, info.n); + try out.print( + "{}ΒΆ\n", + info.n, + info.url, + info.url, + info.name, + info.url, + info.n, + ); }, Node.SeeAlso => |items| { try out.write("

    See also: