From 0e9f86b1db1343b7e57f73906849c88627124a74 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 29 Sep 2019 17:28:30 -0400 Subject: [PATCH] docs: docgen supports release safe exe code examples and make the type names of `@hasDecl` and `@hasField` consistent --- doc/docgen.zig | 2 ++ doc/langref.html.in | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/docgen.zig b/doc/docgen.zig index c3b8d9ebfd..73289e5edc 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -528,6 +528,8 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { const end_tag_name = tokenizer.buffer[end_code_tag.start..end_code_tag.end]; if (mem.eql(u8, end_tag_name, "code_release_fast")) { mode = builtin.Mode.ReleaseFast; + } else if (mem.eql(u8, end_tag_name, "code_release_safe")) { + mode = builtin.Mode.ReleaseSafe; } else if (mem.eql(u8, end_tag_name, "code_link_object")) { _ = try eatToken(tokenizer, Token.Id.Separator); const obj_tok = try eatToken(tokenizer, Token.Id.TagContent); diff --git a/doc/langref.html.in b/doc/langref.html.in index 2e51ad5e6c..5599cc2154 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -7137,7 +7137,7 @@ fn func() void { {#header_close#} {#header_open|@hasDecl#} -
{#syntax#}@hasDecl(comptime container: type, comptime name: []const u8) bool{#endsyntax#}
+
{#syntax#}@hasDecl(comptime Container: type, comptime name: []const u8) bool{#endsyntax#}

Returns whether or not a {#link|struct#}, {#link|enum#}, or {#link|union#} has a declaration matching {#syntax#}name{#endsyntax#}. @@ -7170,7 +7170,7 @@ test "@hasDecl" { {#header_close#} {#header_open|@hasField#} -

{#syntax#}@hasField(comptime T: type, comptime name: []const u8) bool{#endsyntax#}
+
{#syntax#}@hasField(comptime Container: type, comptime name: []const u8) bool{#endsyntax#}

Returns whether the field name of a struct, union, or enum exists.

The result is a compile time constant.