compiler

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = errors.New("compiler: directive conflicts detected")

ErrConflict is returned when directive conflicts are detected.

View Source
var ErrNotInstalled = errors.New("compiler: mln.lock not found — run mln install first")

ErrNotInstalled is returned when mln.lock does not exist. The user should run mln install first.

Functions

func Compile

func Compile(opts CompileOptions) error

Compile runs the full compile pipeline:

  1. Load mln.lock — return ErrNotInstalled if missing.
  2. Load each installed markdown file from .mln/ into []InstalledFile.
  3. Run conflict detection via Detect(). If conflicts found, call Print() and return ErrConflict. Do not write any output files on conflict.
  4. If clean, group InstalledFiles by their declared output target from melon.yaml outputs block.
  5. Call Assemble per output target group.
  6. Write each assembled string to its declared target path on disk (unless DryRun or CheckOnly).
  7. Print a summary of written files.

func Print

func Print(w io.Writer, conflicts []Conflict)

Print formats conflicts into a human-readable terminal report and writes it to w. For each conflict it prints:

  • the directive key in conflict
  • which packages define it
  • each package's conflicting value
  • a suggested resolution: remove one conflicting dep from melon.yaml, or add a manual override directive in the melon.yaml outputs block.

Uses github.com/fatih/color for colored output. The caller is responsible for exiting non-zero after calling Print.

Types

type CompileOptions

type CompileOptions struct {
	ProjectDir string // root of the project (where melon.yaml and mln.lock live)
	DryRun     bool   // if true, print what would be written but do not write files
	CheckOnly  bool   // if true, run conflict detection only, do not write files
}

CompileOptions controls the behavior of Compile.

type Conflict

type Conflict struct {
	Key       string               // the conflicting directive key
	Instances []injector.Directive // all definitions of this key across installed files
}

Conflict represents two or more deps that define the same directive key with different values.

func Detect

func Detect(files []injector.InstalledFile) []Conflict

Detect parses @directive lines from each InstalledFile and returns a []Conflict for every directive key defined with more than one distinct value.

Only lines matching "@directive:<key>: <value>" are checked. Plain prose is NOT conflict-checked in MVP. An empty return slice means the install is clean and safe to assemble.

Jump to

Keyboard shortcuts

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