central

package
v0.1.21 Latest Latest
Warning

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

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

Documentation

Overview

Package central emits the central generated package (solution design D5): path constants for non-parameterised routes and typed constructor functions for parameterised routes (FR-021). Routes are global by nature, so one package holds every generated route symbol; a renamed or re-pathed route regenerates the package and breaks every call site at compile time (D9).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructorBaseName added in v0.1.17

func ConstructorBaseName(handlerName string) string

ConstructorBaseName is the exported identifier a handler symbol contributes to its generated constructor, before any disambiguating package prefix. A method handler's dotted name (Handlers.ListUsers) sanitizes to HandlersListUsers. Exported so the analyzer's E0103 suggestion names the same symbol Naming will emit.

func EventCollisions

func EventCollisions(byName map[string]Constructor, events []Event) []string

EventCollisions reports events whose generated symbols collide with a route symbol or with an earlier event's symbols. Colliding events are excluded from emission by Generate; each message is a GHTMX-E0404.

func Generate

func Generate(table *routes.Table, opts Options) ([]byte, error)

Generate emits the routes file of the central generated package. The output is deterministic, gofmt-formatted Go (NFR-004, NFR-005).

func Naming

func Naming(table *routes.Table) (byName map[string]Constructor, conflicts [][]Constructor)

Naming assigns a deterministic, unique Go identifier to every route. The base name is the handler symbol's name; cross-package collisions are disambiguated with the handler's package base name, multi-verb collisions with the verb. A name that still collides is returned in conflicts and excluded from emission (GHTMX-E0404).

Types

type Constructor

type Constructor struct {
	// Name of the generated constructor function (or, for routes without
	// parameters, the base name of the <Name>Path constant).
	Name  string
	Route routes.Route
}

Constructor describes one generated route symbol.

type Event

type Event struct {
	// Name is the declared Go-side name, e.g. "UserCreated".
	Name string
	// WireName is the HX-Trigger name, e.g. "user-created".
	WireName string
	// Params is the declared payload parameter list source, e.g.
	// "(id string, name string)"; "()" for payload-less events.
	Params string
	// DeclaredAt is the declaration site for doc comments, already
	// module-relative and FILE ONLY — line/column would churn the
	// committed output when edits shift the declaration.
	DeclaredAt string
}

Event is one declared event to generate emission symbols for.

type Options

type Options struct {
	// PackageName is the generated package's name (ghtmxgen by default).
	PackageName string
	// Version is included as a comment when non-empty.
	Version string
	// ModRoot, when set, relativizes registration-site paths in doc
	// comments so output is byte-identical across machines (NFR-004).
	ModRoot string
	// Events are the declared events to emit emission symbols for
	// (FR-037), in registry order.
	Events []Event
	// HtmxVersion, when set, emits HTMXScript() baking the configured
	// version into the script tag (FR-091), so tag and configuration
	// cannot diverge.
	HtmxVersion string
}

Options configures emission.

Jump to

Keyboard shortcuts

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