Skip to content
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

Document standard library organization #5792

Open
marler8997 opened this issue Jul 4, 2020 · 3 comments
Open

Document standard library organization #5792

marler8997 opened this issue Jul 4, 2020 · 3 comments
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. docs standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@marler8997
Copy link
Contributor

marler8997 commented Jul 4, 2020

Even though I've used the standard library a fair amount, I'm still unsure of where to find things when I need them and where to add things when I make contributions. I've searched for a document that describes where things go but haven't found one, and I've also encountered differences in opinion about where things are meant to go.

I'd like to see documentation that explains the purpose for each module in the standard library. Things like:

  • std.c: external symbol declarations for libc
  • std.os.windows.bits: constant/struct type declarations used throughout the windows API
  • std.os.windows: wraps the windows APIs to make them more zig friendly
  • std.os.windows.kernel32: external symbol declarations for kernel32.dll
  • std.fs.file: platform-independent API for managing files

Since this information changes, it's probably best to put it somewhere inside the zig repository. Maybe it should be put in std.zig as apart of the documentation comments that are rendered into the standard library docs.

@nmichaels
Copy link
Contributor

I think the best place to put this kind of documentation is in top-level doc comments (#2288). Each file can document its purpose, and the doc generation process can compile a list.

@Vexu Vexu added contributor friendly This issue is limited in scope and/or knowledge of Zig internals. docs standard library This issue involves writing Zig code for the standard library. labels Jul 4, 2020
@Vexu Vexu added this to the 0.7.0 milestone Jul 4, 2020
@nmichaels
Copy link
Contributor

Alternatively, doc comments in std.zig for each exported symbol would also get us something good, though it's not quite as connected to the content.

@marler8997
Copy link
Contributor Author

marler8997 commented Jul 6, 2020

I realized today we have top-level doc comments:

//! this modules does X

So it looks like this issue can be solved by just going through modules in the standard library and adding top-level doc comments.

Executive Summary?

One thought I had is it could be nice to have an executive summary of all the modules in a single place so users can find what they need without needing to open/search through every file/module. We could do this by using a convention that each module include a short summary of what it contains in the first line of its top-level comment and pull this summary from each module during doc generation. This is the same convention git uses for the commit messages (1st line is a summary). So it would look something like this.

std/c.zig

//! external symbol declarations for libc
//!
//! more documentatation for this module...

std/os/bits.zig

//! platform-dependent types and values used for os-specific APIs
//!
//! more documentatation for this module...

The executive summary would include a list of all the modules and the first-line of their top-level doc comment:

  • std/c.zig: external symbol declarations for libc
  • std/os/bits.zig: platform-dependent types and values used for os-specific APIs
  • ...

@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. docs standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

4 participants