-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
proposal: cmd/doc: module documentation #35544
Comments
cc @dmitshur |
Thanks for making this proposal. I have considered this problem space in the past and wrote a proposal draft related to "module comments", but upon review and thinking more about it, I've realized there were reasons not to propose the change at that time. There may be useful and relevant information in my proposal draft, so I've posted it so that it is available for reading. See issue #35546. |
I created this proposal to resolve a question I had from the new pkg.go.dev site:
I felt like for a web ui, use of
Currently package docs frequently do both, especially at the repo root. With this, a package would document how the exported symbols are to be used, which ones are important, maybe some code samples, and relationships with other packages. E.g. A module should document why you should use the features within. It should describe what it was built to do, call out important packages and note shared features/concern between packages. E.g. This works better for complex libraries that have many packages, like The other feature is the ability to list out the packages in a module. There may be a way to do this with |
Go programs import packages. It makes sense to ask for the documentation for a package. It is a mistake to place emphasis on the module. Focus on the package. Especially for a single-package module, the documentation has always been on the package and it should remain there. A large module like cloud.google.com/go may benefit from a brief overview in a README, and that seems fine. I'm reluctant to formalize module documentation any more than that. |
My goal is to standardize a location to document why they are versioned together, and interface(s) to consume this data. This is frequently information that I want to extract from a module, without cloning or poking around in
What is your view on empty
pkg.go.dev is formalizing this, and in a way that is not very compatible with CLI tools. Is the path that the language would like to take? I am a very large fan of |
Is any additional information required, or is this proposal on |
It's still very unclear what it means to "document a module". This is why we didn't move forward with #35546. I understand your point that pkg.go.dev is making this unclear as well. (For example, https://pkg.go.dev/golang.org/x/crypto/ssh/terminal?tab=overview shows the module-level README but isn't really about the terminal package despite the framing.) It's all still up in the air. I'm not sure there's more information needed or available right now to move forward, but I've moved this into the active proposal list so we keep looking at it. |
Moving it into the active proposal list did mean we kept looking at it, but I still don't see that there's much to do here. Even if we added a module comment like the original suggestion, it would be awkward to have to run Putting on hold until we have a better idea of what any of this means. |
Makes sense; the impetus for this proposal is the recently released pkg section of the discovery site. I think some decision about module documentation should be made before that site hits GA. That being said, I agree nobody is hankering for this information via |
What did you see today?
Currently there is no place to put module level documentation that is consumable via the toolchain.
What would you like to see?
We should standardise a doc string format that reads like the
// Package xxx ...
syntax. This will follow the current godoc rules and allow for code blocks, etc.:We should add a new
-m
flag to putgo doc
in module mode, much likego list -m
vsgo list
. This will only accept module import paths not packages, again likego list
, and will display the module doc string, and full package listing.What alternatives did you consider?
README
The forthcoming discovery service, #33654, currently uses the repo's README for top level documentation, since this is a fairly strong pseudo-convention for most repos. Unfortunately, while this works well for a web ui, this syntax may not be as readable on the command line, or format well with godoc.
versions
It may be useful to list all known versions, but this implies that the list is up to date, and I would rather not impose a full
go get
flow. This could be gated behind-all
or a new flag.packages
noise
For complex packages, say
k8s.io/kubernetes
, listing all the packages may be really noisy. As such it may be useful to gate this data behind-all
. That being said many protobuf generated packages suffer from the same noise.stutter
The current syntax also suffers from stutter, because all package lines start
package xxx // import ...
. This format borrows from the package declaration syntax to be more legible to readers. It also feels like the type declarations that can be found in regular godoc:submodules
While they are not contained within the module, many customers may be confused about why they cannot find the
cloud.google.com/go/datastore
package within thecloud.google.com/go
module. This could be displayed like so, in addition to being guarded behind-all
or a custom flag:The text was updated successfully, but these errors were encountered: