render

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package render provides advanced source code rendering modes for LLM context.

It transforms full source code into more compact representations by leveraging parsed symbol information. Modes include signatures-only, skeleton (signatures + body placeholders), and focused (full bodies for query-relevant symbols, signatures for the rest).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderFile

func RenderFile(source string, symbols []*parser.Symbol, opts Opts) string

RenderFile transforms source code according to the rendering mode, using parsed symbol information to identify which lines belong to function/method bodies vs. declarations.

For symbols of structural kinds (struct, interface, class, type), the full body is always preserved since fields ARE the API surface.

func ValidMode

func ValidMode(m string) bool

ValidMode reports whether m is a recognized rendering mode.

Types

type Mode

type Mode string

Mode controls how source code is rendered for LLM context.

const (
	// ModeDefault preserves the original source (existing behavior).
	ModeDefault Mode = ""

	// ModeSignatures keeps only declaration signatures, removing all bodies.
	ModeSignatures Mode = "signatures"

	// ModeSkeleton keeps signatures with "⋮..." placeholders for bodies.
	ModeSkeleton Mode = "skeleton"

	// ModeFocused keeps full bodies for query-relevant symbols and
	// signatures only for the rest.
	ModeFocused Mode = "focused"
)

type Opts

type Opts struct {
	// Mode selects the rendering strategy.
	Mode Mode

	// QueryTerms are lowercase terms used in focused mode to decide
	// which symbols get full bodies.
	QueryTerms []string
}

Opts controls rendering behavior.

Jump to

Keyboard shortcuts

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