traindown

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: BSD-3-Clause Imports: 8 Imported by: 1

README

traindown-go

A language to help athletes express their training. Inspired by Markdown.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TokenMap map[string]int

TokenMap maps is an enum

View Source
var Tokens = []string{
	"DATE", "LOAD", "FAILS", "METADATA", "MOVEMENT", "MOVEMENT_SS", "NOTE", "REPS", "SETS",
}

Tokens used in parsing Traindown inputs

Functions

This section is empty.

Types

type Formatter

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

Formatter formats Traindown documents

func NewFormatter

func NewFormatter() (*Formatter, error)

NewFormatter returns a pointer to a Formatter

func (Formatter) Format

func (f Formatter) Format(txt string) (string, error)

Format takes a Traindown string and returns a prettier version of it.

type Lexer

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

Lexer type

func NewLexer

func NewLexer() (Lexer, error)

NewLexer returns a new Lexer

func (Lexer) Scan

func (lexer Lexer) Scan(text []byte) ([]*Token, error)

Scan returns the next token

type Metadata

type Metadata map[string]interface{}

Metadata is key value pairs.

type Movement

type Movement struct {
	DefaultUnit string `json:"defaultUnit,omitempty"`
	Name        string `json:"name"`
	Sequence    int    `json:"sequence"`
	SuperSet    bool   `json:"superSet"`

	Performances []*Performance `json:"performances"`

	Metadata Metadata `json:"metadata"`
	Notes    []string `json:"notes"`
}

Movement is an thing you do, you know?

func NewMovement

func NewMovement() *Movement

NewMovement spits out a new Movement

func (Movement) String

func (m Movement) String() string

func (Movement) Volumes

func (m Movement) Volumes() map[string]float32

Volumes computes the volume performed by unit.

type Performance

type Performance struct {
	Fails        int     `json:"fails"`
	Load         float32 `json:"load"`
	PercentOfMax float32 `json:"percentOfMax,omitempty"`
	Reps         int     `json:"reps"`
	Sequence     int     `json:"sequence"`
	Sets         int     `json:"sets"`
	Unit         string  `json:"unit"`

	Metadata Metadata `json:"metadata"`
	Notes    []string `json:"notes"`
}

Performance is an expression of a movement.

func NewPerformance

func NewPerformance() *Performance

NewPerformance spits out a new Performance

func (Performance) String

func (p Performance) String() string

func (Performance) Volume

func (p Performance) Volume() (float32, string)

Volume produces a float and a string containing the unit.

type Session

type Session struct {
	Date        time.Time   `json:"date"`
	DefaultUnit string      `json:"defaultUnit,omitempty"`
	Errors      []error     `json:"errors"`
	Movements   []*Movement `json:"movements"`

	Metadata Metadata `json:"metadata"`
	Notes    []string `json:"notes"`
}

Session is a collection of Movements that occurred.

func NewSession

func NewSession() *Session

NewSession spits out a new Session

func ParseByte

func ParseByte(txt []byte) (*Session, error)

ParseByte takes in a Traindown byte slice and returns a pointer to a Session.

func ParseString

func ParseString(txt string) (*Session, error)

ParseString takes in a Traindown string and returns a pointer to a Session.

func (Session) String

func (s Session) String() string

func (Session) Volumes

func (s Session) Volumes() map[string]float32

Volumes computes the volume performed by unit.

type Token

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

Token holds information about a token

func (Token) End

func (tok Token) End() (int, int)

End getter

func (Token) Name

func (tok Token) Name() string

Name getter

func (Token) Start

func (tok Token) Start() (int, int)

Start getter

func (*Token) String

func (tok *Token) String() string

String override

func (Token) Type

func (tok Token) Type() int

Type getter

func (Token) Value

func (tok Token) Value() string

Value getter

Jump to

Keyboard shortcuts

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