generator

package
v0.49.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SectionTypeGenerated is the section type indicating the section is generated automatically.
	SectionTypeGenerated = 0
	// SectionTypeAmend is the section type indicating the section is added by human editor after the generation.
	SectionTypeAmend = 1
)

Variables

This section is empty.

Functions

func ToGithubAnchorHash

func ToGithubAnchorHash(text string) string

ToGithubAnchorHash convert the given text of header to the hash of anchor link.

Types

type DocumentGenerator

type DocumentGenerator struct {
	// contains filtered or unexported fields
}

DocumentGenerator generates a document from a template. If there is already text added other than the parts automatically generated by the template, the text added after the immediately preceding automatically generated part will be kept after the corresponding generated text section.

func NewDocumentGeneratorFromTemplateFileGlob

func NewDocumentGeneratorFromTemplateFileGlob(templateFileGlob string) (*DocumentGenerator, error)

NewDocumentGeneratorFromTemplateFileGlob returns DocumentGenerator with the template files selected by the given glob file path.

func (*DocumentGenerator) GenerateDocument

func (g *DocumentGenerator) GenerateDocument(destination string, templateName string, parameters any, ignoreNonMatchingGeneratedSection bool) error

GenerateDocument creates or update document at the specified path with the specified template and parameter. When the ignoreNonMatchingGeneratedSection is false, this function returns error when it can't find the associated generated section preceding added text not to lose the edit.

type DocumentSection

type DocumentSection struct {
	Type SectionType
	ID   string
	Body string
}

DocumentSection represents a section inside the document. The splitter read given text and split them in multiple DocumentSection.

func SplitToDocumentSections

func SplitToDocumentSections(text string) ([]*DocumentSection, error)

SplitToDocumentSections splits text to array of DocumentSection This is for splitting the document with the part automatically generated or the part written by human. Generator append the contents written by human in addition to the document generated by the template with keeping its possition.

type SectionType

type SectionType int

SectionType is a enum of the type of a section.

Jump to

Keyboard shortcuts

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