Document

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

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

Document is a generic data structure that represents a document.

func NewDocument added in v0.2.36

func NewDocument(sentences ...string) *Document

NewDocument creates a new document.

Parameters:

  • sentences: The sentences to add to the document.

Returns:

  • *Document: A pointer to the newly created document.

Behaviors:

  • The sentences are separated by a space and on the same line.

func (*Document) AddLine added in v0.2.36

func (d *Document) AddLine(sentences ...string) *Document

AddLine adds sentences to the document separated by a space. The line is split by the newline character.

Parameters:

  • line: The line to add.

Returns:

  • *Document: A pointer to the document. This allows for chaining.

Example:

  • AddLine("Hello,", "world!")
  • AddLine("This is a sentence.")

func (*Document) FString added in v0.2.36

func (d *Document) FString(trav *ffs.Traversor) error

FString returns the formatted string representation of the document.

Parameters:

  • indentLevel: The level of indentation.

Returns:

  • []string: The formatted string representation of the document.

func (*Document) String added in v0.2.36

func (d *Document) String() string

String returns the string representation of the document.

Returns:

  • string: The string representation of the document.

func (*Document) Tmp added in v0.2.37

func (d *Document) Tmp() []string

type DocumentPrinter added in v0.3.5

type DocumentPrinter struct {
	// The name of the document.
	Name string

	// The document to print.
	Doc *Document

	// IfEmpty is the string to print if the document is empty.
	IfEmpty string
}

DocumentPrinter is a type that represents a printer for a document.

func NewDocumentPrinter added in v0.3.5

func NewDocumentPrinter(name string, doc *Document, ifEmpty string) *DocumentPrinter

NewDocumentPrinter is a function that creates a new document printer.

Parameters:

  • name: The name of the document.
  • doc: The document to print.
  • ifEmpty: The string to print if the document is empty.

Returns:

  • *DocumentPrinter: A pointer to the new document printer.

func (*DocumentPrinter) FString added in v0.3.5

func (dp *DocumentPrinter) FString(trav *ffs.Traversor) error

FString is a helper function that prints a document.

Format:

<name>:
  	<document>

or

<name>: <ifEmpty>

Parameters:

  • trav: The traversor to use for printing.

Returns:

  • error: An error if the printing fails.

Behaviors:

  • If the document is nil, the function prints the IfEmpty string.
  • If the document is not nil, the function prints the document.

Jump to

Keyboard shortcuts

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