Documentation
¶
Overview ¶
Package sourcedocs is experimental: its API and documented formats may change in a minor release; see https://nsgo.games/docs/stability/.
Package sourcedocs extracts Go doc comments from source directories into the description map jsonschema.Options.Docs takes. Keeping source-reading doc extraction in this tooling subpackage lets runtime game builds import pkg/jsonschema without linking go/parser, go/ast, go/scanner, or go/token.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PackageDocs ¶
PackageDocs reads the doc comments of the Go package in dir (its non-test .go files) into the map jsonschema.Options.Docs takes: each type's comment under its name, and each struct field's under "Type.Field".
A field with no comment of its own takes the comment of the nearest commented field before it in the same struct when that comment names it, as in "X and Y are the world coordinates", so a pair documented together gets the same description. A comment's lines are joined into paragraphs separated by a blank line.
Example ¶
package main
import (
"fmt"
"github.com/nsgo-dev/game/pkg/jsonschema/sourcedocs"
)
func main() {
docs, err := sourcedocs.PackageDocs("testdata/docpkg")
if err != nil {
panic(err)
}
fmt.Println(docs["Point.Label"])
}
Output: Label names it.
Types ¶
This section is empty.