genplan

package
v0.15.8 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: EPL-2.0 Imports: 3 Imported by: 1 module, 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 genplan packs generated declaration chunks into deterministic, meaningfully named part files. It is the shared planner behind the GIR generators (girgen, webkitgen) and mirrors the j2go FilePlanner contract: chunks group by name family, consecutive groups fill a part up to the target line count, a part never exceeds the ceiling except for a single indivisible chunk, and part names carry the sanitized group name, never an opaque part number.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sanitize

func Sanitize(name string) string

Sanitize lowercases and maps every character outside [a-z0-9_] to '_'.

Types

type Chunk

type Chunk struct {
	Group string // name family the part file is named after
	Owner string // disambiguator basis when a group is split across parts
	Text  string
}

Chunk is one emitted declaration plus its name family. Relatives (overloads, the members of one widget family) share a Group so they stay in one file.

func (Chunk) Lines

func (c Chunk) Lines() int

Lines counts the chunk's lines, trailing blank line included (as committed).

type Part

type Part struct {
	Chunks []Chunk
	Name   string
}

Part is the chunk set of one output file. Name is the sanitized file suffix; a caller writing a small output keeps its base file name instead of a suffix.

func Plan

func Plan(chunks []Chunk, targetLines, maxLines int) []Part

Plan packs chunks into ordered parts. Sorting is a total order (group, owner, text), so the plan is identical for any input permutation and across consecutive generation runs. targetLines is the fill aim per part; maxLines is the ceiling a same-group piece must fit into, except for a single indivisible chunk over it.

func (*Part) Body

func (p *Part) Body() string

Body is the file's declarations, in chunk order.

func (*Part) Lines

func (p *Part) Lines() int

Jump to

Keyboard shortcuts

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