Skip to content

Commit 1014cfd

Browse files
committed
generated docs: progress towards generic types being useful
See #3406
1 parent 47dfaf3 commit 1014cfd

File tree

6 files changed

+527
-85
lines changed

6 files changed

+527
-85
lines changed

lib/std/hash_map.zig

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
3636
size: usize,
3737
max_distance_from_start_index: usize,
3838
allocator: *Allocator,
39-
// this is used to detect bugs where a hashtable is edited while an iterator is running.
39+
40+
/// This is used to detect bugs where a hashtable is edited while an iterator is running.
4041
modification_count: debug_u32,
4142

4243
const Self = @This();

lib/std/meta.zig

+10
Original file line numberDiff line numberDiff line change
@@ -542,3 +542,13 @@ pub fn intToEnum(comptime Tag: type, tag_int: var) IntToEnumError!Tag {
542542
}
543543
return error.InvalidEnumTag;
544544
}
545+
546+
/// Given a type and a name, return the field index according to source order.
547+
/// Returns `null` if the field is not found.
548+
pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int {
549+
inline for (fields(T)) |field, i| {
550+
if (mem.eql(u8, field.name, name))
551+
return comptime_int(i);
552+
}
553+
return null;
554+
}

lib/std/special/docs/index.html

+14-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@
104104
background-color: #FFBB4D;
105105
color: #000;
106106
}
107+
#listFnExamples {
108+
list-style-type: none;
109+
margin: 0;
110+
padding: 0;
111+
}
112+
#listFnExamples li {
113+
padding: 0.5em 0;
114+
white-space: nowrap;
115+
overflow-x: auto;
116+
}
107117
#logo {
108118
width: 8em;
109119
padding: 0.5em 1em;
@@ -289,7 +299,6 @@ <h2>Target</h2>
289299
<pre id="fnProtoCode"></pre>
290300
</div>
291301
<h1 id="hdrName" class="hidden"></h1>
292-
<div id="fnExamples" class="hidden"></div>
293302
<div id="fnNoExamples" class="hidden">
294303
<p>This function is not tested or referenced.</p>
295304
</div>
@@ -357,6 +366,10 @@ <h2>Error Sets</h2>
357366
<ul id="listErrSets">
358367
</ul>
359368
</div>
369+
<div id="fnExamples" class="hidden">
370+
<h2>Examples</h2>
371+
<ul id="listFnExamples"></ul>
372+
</div>
360373
</section>
361374
<div id="helpDialog" class="hidden">
362375
<h1>Keyboard Shortcuts</h1>

0 commit comments

Comments
 (0)