flow

package module
v0.0.0-...-55046f7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 11 Imported by: 0

README

flow

create ascii flow chart from Golang code

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	RuneFunc         = '@'
	RuneFuncInternal = '\\'
	RuneBox          = ':'
	RuneFor          = '*'
	RuneIf           = '#'
	RuneSwitch       = '$'
	RuneDown         = 'V'
	RuneUp           = '^'
	RuneVertical     = '|'
)

Functions

func Ascii

func Ascii(width uint, code string) (out string, err error)

func DrawBox

func DrawBox(width uint, text string) (out [][]rune, height uint)
Example
var width uint = 10
out, height := DrawBox(width, "Long lorem porem text")
err := draw(width, height, out)
if err != nil {
	fmt.Fprintf(os.Stdout, "%v", err)
	return
}
Output:

|::::::::::|
|: LONG L :|
|: OREM P :|
|: OREM T :|
|: EXT    :|
|::::::::::|

func DrawFor

func DrawFor(width uint, text string) (out [][]rune, height uint)

func DrawFunc

func DrawFunc(width uint, text string) (out [][]rune, height uint)

func DrawFuncInternal

func DrawFuncInternal(width uint, text string) (out [][]rune, height uint)

func DrawIf

func DrawIf(width uint, text string) (out [][]rune, height uint)
Example
var width uint = 10
out, height := DrawIf(width, "Long lorem porem text")
err := draw(width, height, out)
if err != nil {
	fmt.Fprintf(os.Stdout, "%v", err)
	return
}
Output:

|IF #######|
|# LONG L #|
|# OREM P #|
|# OREM T #|
|# EXT    #|
|##########|

func DrawSwitch

func DrawSwitch(width uint, text string) (out [][]rune, height uint)

func DrawText

func DrawText(width uint, text string) (out [][]rune, height uint)
Example
var width uint = 10
out, height := DrawText(width, "Long lorem porem text")
err := draw(width, height, out)
if err != nil {
	fmt.Fprintf(os.Stdout, "%v", err)
	return
}
Output:

|LONG LOREM|
| POREM TEX|
|T         |

func ErrToOut

func ErrToOut(width uint, err error) (out string)

func Graph

func Graph(width uint, code string) (out string, err error)

func NodeToString

func NodeToString(node ast.Node) string

Types

type Visitor

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

func (*Visitor) DrawNode

func (v *Visitor) DrawNode(node ast.Node, dr func(width uint, text string) (out [][]rune, height uint))

func (*Visitor) Merge

func (v *Visitor) Merge(left, right string) string

func (*Visitor) Visit

func (v *Visitor) Visit(node ast.Node) (w ast.Visitor)

Jump to

Keyboard shortcuts

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