press

package
v1.0.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncoderPressFunc

type EncoderPressFunc func(p *Press, ref string) (code string)

ref: the reference to the value being encoded.

type Press

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

Press is a tool for printing code. Press is not concurrency safe.

func NewPress

func NewPress() *Press

func (*Press) I

func (p *Press) I(block func(p2 *Press)) *Press

auto-indents p2, appends concents to p. Panics if the last call wasn't Pl() or Ln(). Regardless of whether Pl or Ln is called on p2, the indented lines terminate with newlineDelim before the next unindented line.

func (*Press) Lines

func (p *Press) Lines() (lines []line)

Returns the lines. This may be useful for adding additional indentation to each line for code blocks.

func (*Press) Ln

func (p *Press) Ln() *Press

Appends a new line. It is also possible to print newline characters directly, but Press doesn't treat them as newlines for the sake of indentation.

func (*Press) P

func (p *Press) P(s string, args ...interface{}) *Press

Main function for printing something on the press.

func (*Press) Pl

func (p *Press) Pl(s string, args ...interface{}) *Press

Convenience for P() followed by Nl().

func (*Press) Print

func (p *Press) Print() string

Prints the final representation of the contents.

func (*Press) RandID

func (p *Press) RandID(prefix string) string

Convenience

func (*Press) RandStr

func (p *Press) RandStr(length int) string

Convenience

func (*Press) SetIndentDelim

func (p *Press) SetIndentDelim(s string) *Press

func (*Press) SetNewlineStr

func (p *Press) SetNewlineStr(s string) *Press

func (*Press) SubPress

func (p *Press) SubPress() *Press

SubPress creates a blank Press suitable for inlining code. It starts with no indentation, zero lines, a derived rand from the original, but the same indent and nl strings..

Jump to

Keyboard shortcuts

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