Documentation
¶
Overview ¶
Package generator writes the Go models of a dbspec document set; the orm-gen command and other programs call it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check generates the models like Generate without changing OutputDir or its parent directory and returns one line for each generated file that differs, is missing, or is extra, ordered by path.
func CheckSets ¶ added in v0.0.22
CheckSets checks every set like Check, in the order GenerateSets uses, and returns the lines of every set's differences, each prefixed by its output directory.
func Generate ¶
Generate writes the Go models of the runtime model to OutputDir. The generated files of OutputDir are replaced after the scan converges; any other error leaves OutputDir unchanged. A *ScannedSourceError reports scanned packages that do not compile with the complete models written to OutputDir.
func GenerateSets ¶ added in v0.0.22
GenerateSets generates every set in an order that no set's scan needs a model of a set that is not generated yet. A set whose scanned packages import (directly or through other packages) the output package of another set is generated after that set; the other sets keep the order they are listed in. A cycle between sets has no such order and is refused, and the error names the sets of the cycle. The order of the list therefore does not matter. The first failed generation stops the run, as Generate does.
Types ¶
type Options ¶
type Options struct {
// Model is the runtime model of a dbspec document set.
Model *runtimemodel.Model
OutputDir string
// PackageName selects the Go package name; the directory name by default.
PackageName string
// Scan lists the Go package patterns whose model calls are generated.
Scan []string
}
Options describes one deterministic Go generation request.
type RefusedError ¶ added in v0.0.22
RefusedError is a refusal of the generator with its code of docs/spec/errors.yaml: a scan that does not parse or leaves a getter unattached (docs/spec/dsl.md, DSL-44 and DSL-152), and CONFIG for a name that the chain rules or the column name rules refuse (DSL-37, DSL-116, DSL-127, DSL-129 and DSL-130).
func (*RefusedError) Error ¶ added in v0.0.22
func (e *RefusedError) Error() string
type ScannedSourceError ¶
type ScannedSourceError struct {
Errors []string
}
ScannedSourceError reports scanned packages that do not compile with the generated models. The output directory holds the complete generated models when generation returns it.
func (*ScannedSourceError) Error ¶
func (e *ScannedSourceError) Error() string