Help us shape the future of Go! Take the 2026 Go Developer Survey

generator

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileData

type FileData struct {
	Path     string
	Content  string
	Language string
}

FileData holds file content for the generated sections

type Format

type Format interface {
	// Render converts the template data into the specific format
	Render(data TemplateData) (string, int, error)
	// Extension returns the file extension for this format
	Extension() string
	// Name returns the name of the format
	Name() string
}

Format defines the interface for different output formats

type Generator

type Generator struct {
	SelectedFiles   map[string]bool
	DeselectedFiles map[string]bool
	GitIgnoreMgr    *filesystem.GitIgnoreManager
	FilterMgr       *filesystem.FilterManager
	RootPath        string
	OutputPath      string
	UseTempFile     bool
	UseGitIgnore    bool
	ShowHidden      bool
	// contains filtered or unexported fields
}

Generator organizes how we generate the output in different formats

func NewGenerator

func NewGenerator(rootPath string, gitIgnoreMgr *filesystem.GitIgnoreManager, filterMgr *filesystem.FilterManager, outputPath string, useTempFile bool) *Generator

NewGenerator constructs a generator with default settings

func (*Generator) Generate

func (g *Generator) Generate() (string, int, error)

Generate creates an output file in the specified format

func (*Generator) GenerateString

func (g *Generator) GenerateString() (string, int, error)

GenerateString returns the rendered content as a string along with its estimated token count

func (*Generator) GetFormat

func (g *Generator) GetFormat() Format

GetFormat returns the current format

func (*Generator) GetFormatName

func (g *Generator) GetFormatName() string

GetFormatName returns the name of the current format

func (*Generator) PrepareTemplateData

func (g *Generator) PrepareTemplateData() (TemplateData, error)

PrepareTemplateData finalizes the selection and builds TemplateData for the template

func (*Generator) SetFormat

func (g *Generator) SetFormat(format Format)

SetFormat changes the output format

type Node

type Node struct {
	Name     string
	Path     string
	Content  string
	Language string
	Children []*Node
	IsDir    bool
}

Node represents a node in the in-memory file tree.

type TemplateData

type TemplateData struct {
	Structure string
	Files     []FileData
}

TemplateData is injected into the templates

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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