doctaxonomy

package
v0.1.0-dev.20260816181925 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package doctaxonomy defines the documentation schema the goast provider enforces.

The schema names the blocks a Go doc comment may carry and the order and conditions under which each appears; goast's productions consume it to check and synthesize comments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentSchema

type CommentSchema struct {
	Name          string          `yaml:"-"`
	Format        string          `yaml:"format"`
	NodeType      string          `yaml:"node_type"`
	SummaryPrefix string          `yaml:"summary_prefix,omitempty"`
	Elements      []SchemaElement `yaml:"elements"`
}

CommentSchema defines the structure of a doc comment for a given node type and format.

func LoadSchemas

func LoadSchemas(path string) ([]CommentSchema, error)

LoadSchemas deserializes a YAML file into a slice of CommentSchema.

func ParseSchemas

func ParseSchemas(data []byte) ([]CommentSchema, error)

ParseSchemas deserializes YAML bytes into a slice of CommentSchema.

type SchemaElement

type SchemaElement struct {
	Name        string `yaml:"name"`
	Type        string `yaml:"type"`
	Required    string `yaml:"required,omitempty"`
	Cardinality string `yaml:"cardinality,omitempty"`
	Order       int    `yaml:"order"`
	Header      string `yaml:"header,omitempty"`
	ItemTokens  string `yaml:"item_tokens,omitempty"`

	// Production model fields.
	Production string `yaml:"production,omitempty"`  // "item" or "list"
	Consumes   string `yaml:"consumes,omitempty"`    // ABNF: "Paragraph / Heading", "*(Paragraph / Code)", etc.
	Condition  string `yaml:"condition,omitempty"`   // "params", "returns", "exported", "receiver"
	Prefix     string `yaml:"prefix,omitempty"`      // fuzzy prefix pattern: "{name}", "Parameters:", "+"
	Split      string `yaml:"split,omitempty"`       // "sentence" — extract first sentence, remainder flows to next
	Slots      string `yaml:"slots,omitempty"`       // "params" or "returns" — slot names from declaration context
	SlotPrefix string `yaml:"slot_prefix,omitempty"` // fuzzy slot prefix: "{slot}"
}

SchemaElement defines one element slot in a comment schema.

type SchemaRegistry

type SchemaRegistry struct {
	// contains filtered or unexported fields
}

SchemaRegistry holds loaded schemas keyed by (nodeType, format).

func DefaultRegistry

func DefaultRegistry() *SchemaRegistry

DefaultRegistry returns a SchemaRegistry with the standard Go comment schemas.

These match the defaults in the LintGoStyle extension config.

func NewSchemaRegistry

func NewSchemaRegistry() *SchemaRegistry

NewSchemaRegistry creates an empty registry.

func (*SchemaRegistry) All

func (r *SchemaRegistry) All() []CommentSchema

All returns a snapshot of every schema in the registry, in unspecified order.

Used by the goast provider's overlay path to iterate config-supplied schemas and re-register them onto the defaults registry, so a project config that provides only some schema types preserves the defaults for the schemas it didn't override.

func (*SchemaRegistry) Lookup

func (r *SchemaRegistry) Lookup(nodeType, format string) *CommentSchema

Lookup finds a schema by node type and format.

Returns nil if not found.

func (*SchemaRegistry) Register

func (r *SchemaRegistry) Register(schema CommentSchema)

Register adds a schema to the registry.

Jump to

Keyboard shortcuts

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