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 › compiler/ › Maker/ › Fetch.zig › Filter
Filter
Fetch.Filter
const Filter = struct
File
Code
const Filter = struct {
include_paths : std .array_hash_map .String (void ) = .empty ,
pub fn includePath (self : *const Filter , sub_path : []const u8 ) bool {
if (self .include_paths .count () == 0 ) return true ;
if (self .include_paths .contains ("" )) return true ;
if (self .include_paths .contains ("." )) return true ;
if (self .include_paths .contains (sub_path )) return true ;
var dirname = sub_path ;
while (std .fs .path .dirname (dirname )) |next_dirname | {
if (self .include_paths .contains (next_dirname )) return true ;
dirname = next_dirname ;
}
return false ;
}
test includePath {
const gpa = std .testing .allocator ;
var filter : Filter = .{};
defer filter .include_paths .deinit (gpa );
try filter .include_paths .put (gpa , "src" , {});
try std .testing .expect (filter .includePath ("src/core/unix/SDL_poll.c" ));
try std .testing .expect (!filter .includePath (".gitignore" ));
}
}