Documentation
¶
Overview ¶
Package gosource reads doc comments out of Go source so reflected schemas can carry prose.
Reflection sees structure and nothing else: Go's runtime does not retain doc comments, so a purely reflective OpenAPI schema is structurally complete and entirely undocumented. The alternative the ecosystem settled on — encoding documentation into struct tags or magic comments — puts a second, unchecked language in the source. This package takes the third option: the doc comment stays an ordinary doc comment, and the generator reads it from the source it is already sitting in.
Only the generator needs this. A shipped binary serves a contract that was compiled with the comments already folded in, so nothing here runs at runtime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Docs ¶
type Docs struct {
// contains filtered or unexported fields
}
Docs is a lookup from Go type and field to doc comment.
It implements tapesoapi.TypeDocs, which is the only thing the reflector needs from it.
func Load ¶
Load scans a module rooted at dir and indexes its doc comments.
The module path comes from go.mod, so the keys match the PkgPath reflection reports — which is what lets a reflected type find its own comments without the caller maintaining a mapping.