- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standard library docs? #2539
Comments
If it helps, you can look at the std lib itself, and see which functions and sub-modules are public: |
As Merlyn suggests, I'd recommend looking through the std files (docgen isn't here yet, #21). Look in If you'd like to take a look at some solutions, a few people have AOC repositories for zig. Just search "advent of code zig". |
This issue did just give me an idea though: what if fn getDef(comptime T: type, field: []const u8) ?builtin.StructField {
const info = @typeInfo(T);
const defs = switch (info) {
builtin.TypeId.Struct => |s| s.defs,
builtin.TypeId.Union => |u| u.defs,
builtin.TypeId.Enum => |e| e.defs,
else => return null,
};
inline for (defs) |def| {
if (mem.eql(u8, def.name, field)) return def;
}
return null;
}
fn methodDocs(comptime T: type, field: []const u8) !?[]const u8 {
const def = getDefInfo(T, field) orelse return error.NoSuchMethod;
return def.docComment;
} |
Are there plans to write a documentation in the following release of Zig ?
|
Hi @akatechis Right now you have to read the source of std to find out the API. For the solution to this I present to you the oldest open issue in the zig project: #21 |
Hi,
Not sure if I just wasn't thorough enough in searching, but I have not been able to find any documentation on the
std
module. I'm trying to learn Zig by writing some advent of code programs, and I am specifically interested in how to open/read files.Perhaps related follow-up question: Is there a way to inspect a module to see what other "submodules" are available? I sometimes like to do exploratory programming to just try things out, and being able to just "look" at an object or module and see what's in there is useful. Something like:
The text was updated successfully, but these errors were encountered: