authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-22 23:06:07-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-22 23:06:07-05:00
logfa7072f3f2d7bdb82e2590f93aa702c395e1934d
tree8598ec0e58f0b802fb7b665d53dff84c7b4df897
parentcf39819478e237255109d0343e642db70e88071b

docgen: verify internal links


2 files changed, 127 insertions(+), 85 deletions(-)

doc/docgen.zig+38
......@@ -290,12 +290,19 @@ const Code = struct {
290290 };
291291};
292292
293const Link = struct {
294 url: []const u8,
295 name: []const u8,
296 token: Token,
297};
298
293299const Node = union(enum) {
294300 Content: []const u8,
295301 Nav,
296302 HeaderOpen: HeaderOpen,
297303 SeeAlso: []const SeeAlsoItem,
298304 Code: Code,
305 Link: Link,
299306};
300307
301308const Toc = struct {
......@@ -412,6 +419,31 @@ fn genToc(allocator: &mem.Allocator, tokenizer: &Tokenizer) -> %Toc {
412419 else => return parseError(tokenizer, see_also_tok, "invalid see_also token"),
413420 }
414421 }
422 } else if (mem.eql(u8, tag_name, "link")) {
423 _ = try eatToken(tokenizer, Token.Id.Separator);
424 const name_tok = try eatToken(tokenizer, Token.Id.TagContent);
425 const name = tokenizer.buffer[name_tok.start..name_tok.end];
426
427 const url_name = blk: {
428 const tok = tokenizer.next();
429 switch (tok.id) {
430 Token.Id.BracketClose => break :blk name,
431 Token.Id.Separator => {
432 const explicit_text = try eatToken(tokenizer, Token.Id.TagContent);
433 _ = try eatToken(tokenizer, Token.Id.BracketClose);
434 break :blk tokenizer.buffer[explicit_text.start..explicit_text.end];
435 },
436 else => return parseError(tokenizer, tok, "invalid link token"),
437 }
438 };
439
440 try nodes.append(Node {
441 .Link = Link {
442 .url = try urlize(allocator, url_name),
443 .name = name,
444 .token = name_tok,
445 },
446 });
415447 } else if (mem.eql(u8, tag_name, "code_begin")) {
416448 _ = try eatToken(tokenizer, Token.Id.Separator);
417449 const code_kind_tok = try eatToken(tokenizer, Token.Id.TagContent);
......@@ -661,6 +693,12 @@ fn genHtml(allocator: &mem.Allocator, tokenizer: &Tokenizer, toc: &Toc, out: &io
661693 Node.Content => |data| {
662694 try out.write(data);
663695 },
696 Node.Link => |info| {
697 if (!toc.urls.contains(info.url)) {
698 return parseError(tokenizer, info.token, "url not found: {}", info.url);
699 }
700 try out.print("<a href=\"#{}\">{}</a>", info.url, info.name);
701 },
664702 Node.Nav => {
665703 try out.write(toc.toc);
666704 },
doc/langref.html.in+89-85
......@@ -33,7 +33,7 @@
3333 .file {
3434 text-decoration: underline;
3535 }
36 pre {
36 code {
3737 font-size: 12pt;
3838 }
3939 @media screen and (min-width: 28.75em) {
......@@ -102,10 +102,14 @@ pub fn main() -> %void {
102102 {#code_begin|exe|hello#}
103103const warn = @import("std").debug.warn;
104104
105pub fn main() -> %void {
105pub fn main() -> void {
106106 warn("Hello, world!\n");
107107}
108108 {#code_end#}
109 <p>
110 Note that we also left off the <code class="zig">%</code> from the return type.
111 In Zig, if your main function cannot fail, you may use the <code class="zig">void</code> return type.
112 </p>
109113 {#see_also|Values|@import|Errors|Root Source File#}
110114 {#header_close#}
111115 {#header_open|Source Encoding#}
......@@ -621,7 +625,6 @@ fn divide(a: i32, b: i32) -> i32 {
621625 {#header_close#}
622626 {#header_close#}
623627 {#header_open|Floats#}
624 {#header_close#}
625628 {#header_open|Float Literals#}
626629 {#code_begin|syntax#}
627630const floating_point = 123.0E+77;
......@@ -668,6 +671,7 @@ pub fn main() -> %void {
668671 {#code_end#}
669672 {#see_also|@setFloatMode|Division by Zero#}
670673 {#header_close#}
674 {#header_close#}
671675 {#header_open|Operators#}
672676 {#header_open|Table of Operators#}
673677 <table>
......@@ -690,13 +694,13 @@ pub fn main() -> %void {
690694a += b</code></pre></td>
691695 <td>
692696 <ul>
693 <li><a href="#integers">Integers</a></li>
694 <li><a href="#floats">Floats</a></li>
697 <li>{#link|Integers#}</li>
698 <li>{#link|Floats#}</li>
695699 </ul>
696700 </td>
697701 <td>Addition.
698702 <ul>
699 <li>Can cause <a href="#undef-integer-overflow">overflow</a> for integers.</li>
703 <li>Can cause {#link|overflow|Default Operations#} for integers.</li>
700704 </ul>
701705 </td>
702706 <td>
......@@ -708,7 +712,7 @@ a += b</code></pre></td>
708712a +%= b</code></pre></td>
709713 <td>
710714 <ul>
711 <li><a href="#integers">Integers</a></li>
715 <li>{#link|Integers#}</li>
712716 </ul>
713717 </td>
714718 <td>Wrapping Addition.
......@@ -725,13 +729,13 @@ a +%= b</code></pre></td>
725729a -= b</code></pre></td>
726730 <td>
727731 <ul>
728 <li><a href="#integers">Integers</a></li>
729 <li><a href="#floats">Floats</a></li>
732 <li>{#link|Integers#}</li>
733 <li>{#link|Floats#}</li>
730734 </ul>
731735 </td>
732736 <td>Subtraction.
733737 <ul>
734 <li>Can cause <a href="#undef-integer-overflow">overflow</a> for integers.</li>
738 <li>Can cause {#link|overflow|Default Operations#} for integers.</li>
735739 </ul>
736740 </td>
737741 <td>
......@@ -743,7 +747,7 @@ a -= b</code></pre></td>
743747a -%= b</code></pre></td>
744748 <td>
745749 <ul>
746 <li><a href="#integers">Integers</a></li>
750 <li>{#link|Integers#}</li>
747751 </ul>
748752 </td>
749753 <td>Wrapping Subtraction.
......@@ -759,14 +763,14 @@ a -%= b</code></pre></td>
759763 <td><pre><code class="zig">-a<code></pre></td>
760764 <td>
761765 <ul>
762 <li><a href="#integers">Integers</a></li>
763 <li><a href="#floats">Floats</a></li>
766 <li>{#link|Integers#}</li>
767 <li>{#link|Floats#}</li>
764768 </ul>
765769 </td>
766770 <td>
767771 Negation.
768772 <ul>
769 <li>Can cause <a href="#undef-integer-overflow">overflow</a> for integers.</li>
773 <li>Can cause {#link|overflow|Default Operations#} for integers.</li>
770774 </ul>
771775 </td>
772776 <td>
......@@ -777,7 +781,7 @@ a -%= b</code></pre></td>
777781 <td><pre><code class="zig">-%a<code></pre></td>
778782 <td>
779783 <ul>
780 <li><a href="#integers">Integers</a></li>
784 <li>{#link|Integers#}</li>
781785 </ul>
782786 </td>
783787 <td>
......@@ -795,13 +799,13 @@ a -%= b</code></pre></td>
795799a *= b</code></pre></td>
796800 <td>
797801 <ul>
798 <li><a href="#integers">Integers</a></li>
799 <li><a href="#floats">Floats</a></li>
802 <li>{#link|Integers#}</li>
803 <li>{#link|Floats#}</li>
800804 </ul>
801805 </td>
802806 <td>Multiplication.
803807 <ul>
804 <li>Can cause <a href="#undef-integer-overflow">overflow</a> for integers.</li>
808 <li>Can cause {#link|overflow|Default Operations#} for integers.</li>
805809 </ul>
806810 </td>
807811 <td>
......@@ -813,7 +817,7 @@ a *= b</code></pre></td>
813817a *%= b</code></pre></td>
814818 <td>
815819 <ul>
816 <li><a href="#integers">Integers</a></li>
820 <li>{#link|Integers#}</li>
817821 </ul>
818822 </td>
819823 <td>Wrapping Multiplication.
......@@ -830,19 +834,19 @@ a *%= b</code></pre></td>
830834a /= b</code></pre></td>
831835 <td>
832836 <ul>
833 <li><a href="#integers">Integers</a></li>
834 <li><a href="#floats">Floats</a></li>
837 <li>{#link|Integers#}</li>
838 <li>{#link|Floats#}</li>
835839 </ul>
836840 </td>
837841 <td>Divison.
838842 <ul>
839 <li>Can cause <a href="#undef-integer-overflow">overflow</a> for integers.</li>
840 <li>Can cause <a href="#undef-division-by-zero">division by zero</a> for integers.</li>
841 <li>Can cause <a href="#undef-division-by-zero">division by zero</a> for floats in <a href="#float-operations">FloatMode.Optimized Mode</a>.</li>
843 <li>Can cause {#link|overflow|Default Operations#} for integers.</li>
844 <li>Can cause {#link|Division by Zero#} for integers.</li>
845 <li>Can cause {#link|Division by Zero#} for floats in {#link|FloatMode.Optimized Mode|Floating Point Operations#}.</li>
842846 <li>For non-compile-time-known signed integers, must use
843 <a href="#builtin-divTrunc">@divTrunc</a>,
844 <a href="#builtin-divFloor">@divFloor</a>, or
845 <a href="#builtin-divExact">@divExact</a> instead of <code>/</code>.
847 {#link|@divTrunc#},
848 {#link|@divFloor#}, or
849 {#link|@divExact#} instead of <code>/</code>.
846850 </li>
847851 </ul>
848852 </td>
......@@ -855,17 +859,17 @@ a /= b</code></pre></td>
855859a %= b</code></pre></td>
856860 <td>
857861 <ul>
858 <li><a href="#integers">Integers</a></li>
859 <li><a href="#floats">Floats</a></li>
862 <li>{#link|Integers#}</li>
863 <li>{#link|Floats#}</li>
860864 </ul>
861865 </td>
862866 <td>Remainder Division.
863867 <ul>
864 <li>Can cause <a href="#undef-division-by-zero">division by zero</a> for integers.</li>
865 <li>Can cause <a href="#undef-division-by-zero">division by zero</a> for floats in <a href="#float-operations">FloatMode.Optimized Mode</a>.</li>
868 <li>Can cause {#link|Division by Zero#} for integers.</li>
869 <li>Can cause {#link|Division by Zero#} for floats in {#link|FloatMode.Optimized Mode|Floating Point Operations#}.</li>
866870 <li>For non-compile-time-known signed integers, must use
867 <a href="#builtin-rem">@rem</a> or
868 <a href="#builtin-mod">@mod</a> instead of <code>%</code>.
871 {#link|@rem#} or
872 {#link|@mod#} instead of <code>%</code>.
869873 </li>
870874 </ul>
871875 </td>
......@@ -878,13 +882,13 @@ a %= b</code></pre></td>
878882a &lt;&lt;= b</code></pre></td>
879883 <td>
880884 <ul>
881 <li><a href="#integers">Integers</a></li>
885 <li>{#link|Integers#}</li>
882886 </ul>
883887 </td>
884888 <td>Bit Shift Left.
885889 <ul>
886 <li>See also <a href="#builtin-shlExact">@shlExact</a>.</li>
887 <li>See also <a href="#builtin-shlWithOverflow">@shlWithOverflow</a>.</li>
890 <li>See also {#link|@shlExact#}.</li>
891 <li>See also {#link|@shlWithOverflow#}.</li>
888892 </ul>
889893 </td>
890894 <td>
......@@ -896,12 +900,12 @@ a &lt;&lt;= b</code></pre></td>
896900a &gt;&gt;= b</code></pre></td>
897901 <td>
898902 <ul>
899 <li><a href="#integers">Integers</a></li>
903 <li>{#link|Integers#}</li>
900904 </ul>
901905 </td>
902906 <td>Bit Shift Right.
903907 <ul>
904 <li>See also <a href="#builtin-shrExact">@shrExact</a>.</li>
908 <li>See also {#link|@shrExact#}.</li>
905909 </ul>
906910 </td>
907911 <td>
......@@ -913,7 +917,7 @@ a &gt;&gt;= b</code></pre></td>
913917a &amp;= b</code></pre></td>
914918 <td>
915919 <ul>
916 <li><a href="#integers">Integers</a></li>
920 <li>{#link|Integers#}</li>
917921 </ul>
918922 </td>
919923 <td>Bitwise AND.
......@@ -927,7 +931,7 @@ a &amp;= b</code></pre></td>
927931a |= b</code></pre></td>
928932 <td>
929933 <ul>
930 <li><a href="#integers">Integers</a></li>
934 <li>{#link|Integers#}</li>
931935 </ul>
932936 </td>
933937 <td>Bitwise OR.
......@@ -941,7 +945,7 @@ a |= b</code></pre></td>
941945a ^= b</code></pre></td>
942946 <td>
943947 <ul>
944 <li><a href="#integers">Integers</a></li>
948 <li>{#link|Integers#}</li>
945949 </ul>
946950 </td>
947951 <td>Bitwise XOR.
......@@ -954,7 +958,7 @@ a ^= b</code></pre></td>
954958 <td><pre><code class="zig">~a<code></pre></td>
955959 <td>
956960 <ul>
957 <li><a href="#integers">Integers</a></li>
961 <li>{#link|Integers#}</li>
958962 </ul>
959963 </td>
960964 <td>
......@@ -968,13 +972,13 @@ a ^= b</code></pre></td>
968972 <td><pre><code class="zig">a ?? b</code></pre></td>
969973 <td>
970974 <ul>
971 <li><a href="#nullables">Nullables</a></li>
975 <li>{#link|Nullables#}</li>
972976 </ul>
973977 </td>
974978 <td>If <code>a</code> is <code>null</code>,
975979 returns <code>b</code> ("default value"),
976980 otherwise returns the unwrapped value of <code>a</code>.
977 Note that <code>b</code> may be a value of type <a href="#noreturn">noreturn</a>.
981 Note that <code>b</code> may be a value of type {#link|noreturn#}.
978982 </td>
979983 <td>
980984 <pre><code class="zig">const value: ?u32 = null;
......@@ -986,7 +990,7 @@ unwrapped == 1234</code></pre>
986990 <td><pre><code class="zig">??a</code></pre></td>
987991 <td>
988992 <ul>
989 <li><a href="#nullables">Nullables</a></li>
993 <li>{#link|Nullables#}</li>
990994 </ul>
991995 </td>
992996 <td>
......@@ -1003,13 +1007,13 @@ unwrapped == 1234</code></pre>
10031007a catch |err| b</code></pre></td>
10041008 <td>
10051009 <ul>
1006 <li><a href="#errors">Error Unions</a></li>
1010 <li>{#link|Error Unions|Errors#}</li>
10071011 </ul>
10081012 </td>
10091013 <td>If <code>a</code> is an <code>error</code>,
10101014 returns <code>b</code> ("default value"),
10111015 otherwise returns the unwrapped value of <code>a</code>.
1012 Note that <code>b</code> may be a value of type <a href="#noreturn">noreturn</a>.
1016 Note that <code>b</code> may be a value of type {#link|noreturn#}.
10131017 <code>err</code> is the <code>error</code> and is in scope of the expression <code>b</code>.
10141018 </td>
10151019 <td>
......@@ -1022,7 +1026,7 @@ unwrapped == 1234</code></pre>
10221026 <td><pre><code class="zig">a and b<code></pre></td>
10231027 <td>
10241028 <ul>
1025 <li><a href="#primitive-types">bool</a></li>
1029 <li>{#link|bool|Primitive Types#}</li>
10261030 </ul>
10271031 </td>
10281032 <td>
......@@ -1037,7 +1041,7 @@ unwrapped == 1234</code></pre>
10371041 <td><pre><code class="zig">a or b<code></pre></td>
10381042 <td>
10391043 <ul>
1040 <li><a href="#primitive-types">bool</a></li>
1044 <li>{#link|bool|Primitive Types#}</li>
10411045 </ul>
10421046 </td>
10431047 <td>
......@@ -1052,7 +1056,7 @@ unwrapped == 1234</code></pre>
10521056 <td><pre><code class="zig">!a<code></pre></td>
10531057 <td>
10541058 <ul>
1055 <li><a href="#primitive-types">bool</a></li>
1059 <li>{#link|bool|Primitive Types#}</li>
10561060 </ul>
10571061 </td>
10581062 <td>
......@@ -1066,10 +1070,10 @@ unwrapped == 1234</code></pre>
10661070 <td><pre><code class="zig">a == b<code></pre></td>
10671071 <td>
10681072 <ul>
1069 <li><a href="#integers">Integers</a></li>
1070 <li><a href="#floats">Floats</a></li>
1071 <li><a href="#primitive-types">bool</a></li>
1072 <li><a href="#primitive-types">type</a></li>
1073 <li>{#link|Integers#}</li>
1074 <li>{#link|Floats#}</li>
1075 <li>{#link|bool|Primitive Types#}</li>
1076 <li>{#link|type|Primitive Types#}</li>
10731077 </ul>
10741078 </td>
10751079 <td>
......@@ -1083,7 +1087,7 @@ unwrapped == 1234</code></pre>
10831087 <td><pre><code class="zig">a == null<code></pre></td>
10841088 <td>
10851089 <ul>
1086 <li><a href="#nullables">Nullables</a></li>
1090 <li>{#link|Nullables#}</li>
10871091 </ul>
10881092 </td>
10891093 <td>
......@@ -1098,10 +1102,10 @@ value == null</code></pre>
10981102 <td><pre><code class="zig">a != b<code></pre></td>
10991103 <td>
11001104 <ul>
1101 <li><a href="#integers">Integers</a></li>
1102 <li><a href="#floats">Floats</a></li>
1103 <li><a href="#primitive-types">bool</a></li>
1104 <li><a href="#primitive-types">type</a></li>
1105 <li>{#link|Integers#}</li>
1106 <li>{#link|Floats#}</li>
1107 <li>{#link|bool|Primitive Types#}</li>
1108 <li>{#link|type|Primitive Types#}</li>
11051109 </ul>
11061110 </td>
11071111 <td>
......@@ -1115,8 +1119,8 @@ value == null</code></pre>
11151119 <td><pre><code class="zig">a &gt; b<code></pre></td>
11161120 <td>
11171121 <ul>
1118 <li><a href="#integers">Integers</a></li>
1119 <li><a href="#floats">Floats</a></li>
1122 <li>{#link|Integers#}</li>
1123 <li>{#link|Floats#}</li>
11201124 </ul>
11211125 </td>
11221126 <td>
......@@ -1130,8 +1134,8 @@ value == null</code></pre>
11301134 <td><pre><code class="zig">a &gt;= b<code></pre></td>
11311135 <td>
11321136 <ul>
1133 <li><a href="#integers">Integers</a></li>
1134 <li><a href="#floats">Floats</a></li>
1137 <li>{#link|Integers#}</li>
1138 <li>{#link|Floats#}</li>
11351139 </ul>
11361140 </td>
11371141 <td>
......@@ -1145,8 +1149,8 @@ value == null</code></pre>
11451149 <td><pre><code class="zig">a &lt; b<code></pre></td>
11461150 <td>
11471151 <ul>
1148 <li><a href="#integers">Integers</a></li>
1149 <li><a href="#floats">Floats</a></li>
1152 <li>{#link|Integers#}</li>
1153 <li>{#link|Floats#}</li>
11501154 </ul>
11511155 </td>
11521156 <td>
......@@ -1160,8 +1164,8 @@ value == null</code></pre>
11601164 <td><pre><code class="zig">a &lt;= b<code></pre></td>
11611165 <td>
11621166 <ul>
1163 <li><a href="#integers">Integers</a></li>
1164 <li><a href="#floats">Floats</a></li>
1167 <li>{#link|Integers#}</li>
1168 <li>{#link|Floats#}</li>
11651169 </ul>
11661170 </td>
11671171 <td>
......@@ -1175,13 +1179,13 @@ value == null</code></pre>
11751179 <td><pre><code class="zig">a ++ b<code></pre></td>
11761180 <td>
11771181 <ul>
1178 <li><a href="#arrays">Arrays</a></li>
1182 <li>{#link|Arrays#}</li>
11791183 </ul>
11801184 </td>
11811185 <td>
11821186 Array concatenation.
11831187 <ul>
1184 <li>Only available when <code>a</code> and <code>b</code> are <a href="#comptime">compile-time known</a>.
1188 <li>Only available when <code>a</code> and <code>b</code> are {#link|compile-time known|comptime#}.
11851189 </ul>
11861190 </td>
11871191 <td>
......@@ -1196,13 +1200,13 @@ mem.eql(u32, together, []u32{1,2,3,4})</code></pre>
11961200 <td><pre><code class="zig">a ** b<code></pre></td>
11971201 <td>
11981202 <ul>
1199 <li><a href="#arrays">Arrays</a></li>
1203 <li>{#link|Arrays#}</li>
12001204 </ul>
12011205 </td>
12021206 <td>
12031207 Array multiplication.
12041208 <ul>
1205 <li>Only available when <code>a</code> and <code>b</code> are <a href="#comptime">compile-time known</a>.
1209 <li>Only available when <code>a</code> and <code>b</code> are {#link|compile-time known|comptime#}.
12061210 </ul>
12071211 </td>
12081212 <td>
......@@ -1215,7 +1219,7 @@ mem.eql(u8, pattern, "ababab")</code></pre>
12151219 <td><pre><code class="zig">*a<code></pre></td>
12161220 <td>
12171221 <ul>
1218 <li><a href="#pointers">Pointers</a></li>
1222 <li>{#link|Pointers#}</li>
12191223 </ul>
12201224 </td>
12211225 <td>
......@@ -1504,7 +1508,7 @@ test "pointer child type" {
15041508 Each type has an <strong>alignment</strong> - a number of bytes such that,
15051509 when a value of the type is loaded from or stored to memory,
15061510 the memory address must be evenly divisible by this number. You can use
1507 <a href="#builtin-alignOf">@alignOf</a> to find out this value for any type.
1511 {#link|@alignOf#} to find out this value for any type.
15081512 </p>
15091513 <p>
15101514 Alignment depends on the CPU architecture, but is always a power of two, and
......@@ -1562,9 +1566,9 @@ test "function alignment" {
15621566 {#code_end#}
15631567 <p>
15641568 If you have a pointer or a slice that has a small alignment, but you know that it actually
1565 has a bigger alignment, use <a href="#builtin-alignCast">@alignCast</a> to change the
1569 has a bigger alignment, use {#link|@alignCast#} to change the
15661570 pointer into a more aligned pointer. This is a no-op at runtime, but inserts a
1567 <a href="#undef-incorrect-pointer-alignment">safety check</a>:
1571 {#link|safety check|Incorrect Pointer Alignment#}:
15681572 </p>
15691573 {#code_begin|test_safety|incorrect alignment#}
15701574const assert = @import("std").debug.assert;
......@@ -1589,7 +1593,7 @@ fn foo(bytes: []u8) -> u32 {
15891593 </p>
15901594 <p>As an example, this code produces undefined behavior:</p>
15911595 <pre><code class="zig">*@ptrCast(&amp;u32, f32(12.34))</code></pre>
1592 <p>Instead, use <a href="#builtin-bitCast">@bitCast</a>:
1596 <p>Instead, use {#link|@bitCast#}:
15931597 <pre><code class="zig">@bitCast(u32, f32(12.34))</code></pre>
15941598 <p>As an added benefit, the <code>@bitcast</code> version works at compile-time.</p>
15951599 {#see_also|Slices|Memory#}
......@@ -3391,7 +3395,7 @@ test "fibonacci" {
33913395 The compiler noticed that evaluating this function at compile-time took a long time,
33923396 and thus emitted a compile error and gave up. If the programmer wants to increase
33933397 the budget for compile-time computation, they can use a built-in function called
3394 <a href="#builtin-setEvalBranchQuota">@setEvalBranchQuota</a> to change the default number 1000 to something else.
3398 {#link|@setEvalBranchQuota#} to change the default number 1000 to something else.
33953399 </p>
33963400 <p>
33973401 What if we fix the base case, but put the wrong value in the <code>assert</code> line?
......@@ -3750,7 +3754,7 @@ pub fn main() {
37503754 <code>?fn()</code>, or <code>[]T</code>. It returns the same type as <code>ptr</code>
37513755 except with the alignment adjusted to the new value.
37523756 </p>
3753 <p>A <a href="#undef-incorrect-pointer-alignment">pointer alignment safety check</a> is added
3757 <p>A {#link|pointer alignment safety check|Incorrect Pointer Alignment#} is added
37543758 to the generated code to make sure the pointer is aligned as promised.</p>
37553759
37563760 {#header_close#}
......@@ -3767,7 +3771,7 @@ comptime {
37673771}</code></pre>
37683772 <p>
37693773 The result is a target-specific compile time constant. It is guaranteed to be
3770 less than or equal to <a href="#builtin-sizeOf">@sizeOf(T)</a>.
3774 less than or equal to {#link|@sizeOf(T)|@sizeOf#}.
37713775 </p>
37723776 {#see_also|Alignment#}
37733777 {#header_close#}
......@@ -4109,7 +4113,7 @@ fn add(a: i32, b: i32) -> i32 { return a + b; }
41094113 {#header_open|@intToPtr#}
41104114 <pre><code class="zig">@intToPtr(comptime DestType: type, int: usize) -&gt; DestType</code></pre>
41114115 <p>
4112 Converts an integer to a pointer. To convert the other way, use <a href="#builtin-ptrToInt">@ptrToInt</a>.
4116 Converts an integer to a pointer. To convert the other way, use {#link|@ptrToInt#}.
41134117 </p>
41144118 {#header_close#}
41154119 {#header_open|@IntType#}
......@@ -4286,7 +4290,7 @@ test "call foo" {
42864290 <li><code>fn()</code></li>
42874291 <li><code>?fn()</code></li>
42884292 </ul>
4289 <p>To convert the other way, use <a href="#builtin-intToPtr">@intToPtr</a></p>
4293 <p>To convert the other way, use {#link|@intToPtr#}</p>
42904294
42914295 {#header_close#}
42924296 {#header_open|@rem#}
......@@ -4539,9 +4543,9 @@ pub const TypeId = enum {
45394543 Zig has three build modes:
45404544 </p>
45414545 <ul>
4542 <li><a href="#build-mode-debug">Debug</a> (default)</li>
4543 <li><a href="#build-mode-release-fast">ReleaseFast</a></li>
4544 <li><a href="#build-mode-release-safe">ReleaseSafe</a></li>
4546 <li>{#link|Debug#} (default)</li>
4547 <li>{#link|ReleaseFast#}</li>
4548 <li>{#link|ReleaseSafe#}</li>
45454549 </ul>
45464550 <p>
45474551 To add standard build options to a <code>build.zig</code> file:
......@@ -4592,7 +4596,7 @@ pub fn build(b: &Builder) -> %void {
45924596 detected at compile-time, Zig emits an error. Most undefined behavior that
45934597 cannot be detected at compile-time can be detected at runtime. In these cases,
45944598 Zig has safety checks. Safety checks can be disabled on a per-block basis
4595 with <code>@setDebugSafety</code>. The <a href="#build-mode-release-fast">ReleaseFast</a>
4599 with <code>@setDebugSafety</code>. The {#link|ReleaseFast#}
45964600 build mode disables all safety checks in order to facilitate optimizations.
45974601 </p>
45984602 <p>