sourcedocs

package
v0.4.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func PackageDocs(dir string) (map[string]string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL