This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.
fntestTokenize(source: [:0]constu8, expected_token_tags: []constToken.Tag) !void {
vartokenizer = Tokenizer.init(source);
for (expected_token_tags) |expected_token_tag| {
consttoken = tokenizer.next();
trystd.testing.expectEqual(expected_token_tag, token.tag);
}
// Last token should always be eof, even when the last token was invalid,
// in which case the tokenizer is in an invalid state, which can only be
// recovered by opinionated means outside the scope of this implementation.
constlast_token = tokenizer.next();
trystd.testing.expectEqual(Token.Tag.eof, last_token.tag);
trystd.testing.expectEqual(source.len, last_token.loc.start);
trystd.testing.expectEqual(source.len, last_token.loc.end);
}