Zig 0.17.0-dev (Split by item)
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.
Zig › docs/ › wasm/ › main.zig › ErrorIdentifier
ErrorIdentifier
main.ErrorIdentifier
const ErrorIdentifier = packed struct (u64 )
File
Code
const ErrorIdentifier = packed struct (u64 ) {
token_index : Ast .TokenIndex ,
decl_index : Decl .Index ,
fn hasDocs (ei : ErrorIdentifier ) bool {
const decl_index = ei .decl_index ;
const ast = decl_index .get ().file .get_ast ();
const token_index = ei .token_index ;
if (token_index == 0 ) return false ;
return ast .tokenTag (token_index - 1 ) == .doc_comment ;
}
fn html (ei : ErrorIdentifier , base_decl : Decl .Index , out : *ArrayList (u8 )) Oom !void {
const decl_index = ei .decl_index ;
const ast = decl_index .get ().file .get_ast ();
const name = ast .tokenSlice (ei .token_index );
const has_link = base_decl != decl_index ;
try out .appendSlice (gpa , "<dt>" );
try out .appendSlice (gpa , name );
if (has_link ) {
try out .appendSlice (gpa , " <a href=\"#" );
_ = missing_feature_url_escape ;
try decl_index .get ().fqn (out );
try out .appendSlice (gpa , "\">" );
try out .appendSlice (gpa , decl_index .get ().extra_info ().name );
try out .appendSlice (gpa , "</a>" );
}
try out .appendSlice (gpa , "</dt>" );
if (Decl .findFirstDocComment (ast , ei .token_index ).unwrap ()) |first_doc_comment | {
try out .appendSlice (gpa , "<dd>" );
try render_docs (out , decl_index , first_doc_comment , false );
try out .appendSlice (gpa , "</dd>" );
}
}
}