graph

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNKNOWN_TYPE int = iota
	// is node
	NODE_TYPE
	// is edge
	EDGE_TYPE
	// is info
	INFO_TYPE
	// is bulk
	BULK_TYPE

	// states
	NORMAL_STATE int = iota
	//
	BEGIN_TODO
)
View Source
const (
	CONTEXT_TAG = "@"
	PROJECT_TAG = "+"

	// Special Fields inside the description field
	DUE_PATTERN    = "due:"
	REPEAT_PATTERN = "repeat:"
	ACTION_PATTERN = "lel:"
)

special fields todo

Variables

View Source
var (
	ErrNoMetaInfo = errors.New("No Metainformation could be found ")
)
View Source
var (
	ErrNoValidRelation = errors.New("No Valid Relation")
)

Functions

func GetAlias

func GetAlias(relation string) string

func GetRefInfo

func GetRefInfo(raw string) (result string)

func GetRefRelation

func GetRefRelation(raw, origin string) (subject, relation, object string, err error)

func IsRelationAlias

func IsRelationAlias(relation string) bool

func NewMDUUID

func NewMDUUID() string

Types

type Edge

type Edge struct {
	Source string `json:"source"`
	Target string `json:"target"`
	Id     string `json:"id"`
	Label  string `json:"label"`

	Color string `json:"color"`

	References []string `json:"references"`
	Origin     string   `json:"origin"`
	Tags       []string `json:"tags"`
	Names      []string `json:"names"`

	// isEmpty defines if the
	IsEmpty bool `json:"-"`
}

Representation of a connections between nodes

func NewEdge

func NewEdge(label, source, target string) *Edge

func NewOriginEdge

func NewOriginEdge(info *MetaInfo, source, target string) *Edge

type Export

type Export struct {
	Nodes   []*Node           `json:"nodes"`
	Edges   []*Edge           `json:"edges"`
	Unknown map[string]string `json:"unknown"`
	Errs    map[string]string `json:"-"`
}

type MetaGraph

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

func New

func New() *MetaGraph

func (*MetaGraph) Add

func (g *MetaGraph) Add(m *MetaInfo) error

func (*MetaGraph) Clear

func (g *MetaGraph) Clear()

func (*MetaGraph) Export

func (g *MetaGraph) Export() Export

func (*MetaGraph) Get

func (g *MetaGraph) Get(id string) *MetaInfo

Get returns the metainfo for a specific id

func (*MetaGraph) IndexFile

func (g *MetaGraph) IndexFile(filePath, origin string) error

type MetaInfo

type MetaInfo struct {
	Names  []string `json:"names"`
	Entity string   `json:"entity"`

	// optional
	Tags      []string `json:"tags"`
	Relations []string `json:"relations"`
	Label     string   `json:"label"`

	References []string `json:"references"`
	// icon url
	Icon string `json:"icon"`

	// id is Origin
	Id string `json:"id"`

	// Todos
	Todos []Todo `json:"todos"`

	// Date
	Modified time.Time `json:"modified"`
	// contains filtered or unexported fields
}

MetaInformation contains raw information from the file

func MetaInfoFromFile

func MetaInfoFromFile(filename string, id string) (m *MetaInfo, err error)

MetaInfoFromFile creates a new metainfo from a file

func NewMetaInfoFromReader

func NewMetaInfoFromReader(r io.Reader, id string) (m *MetaInfo, err error)

NewMetaInformationFromReader creates a new metaInformation, through reading line by line

func (*MetaInfo) AddRef

func (m *MetaInfo) AddRef(relation string)

func (*MetaInfo) Collect

func (m *MetaInfo) Collect(line string) (err error)

SearchAndCollect adds metainformation from the line into the object, if the metaprefix matches

func (*MetaInfo) Equal

func (m *MetaInfo) Equal(other *MetaInfo) bool

Equal checks if the provided MetaInfo contains the exact same information

func (*MetaInfo) GetLabel

func (m *MetaInfo) GetLabel() (label string)

GetLabel returns the label or the first name of the entity

func (*MetaInfo) GetType

func (m *MetaInfo) GetType() int

GetType returns the type information based on the entity

func (*MetaInfo) Valid

func (m *MetaInfo) Valid() bool

Valid returns wether the file has enough information At least names and entity must be defined

type Node

type Node struct {
	Type  string `json:"type"`
	Size  string `json:"size"`
	Shape string `json:"shape"`
	Color string `json:"color"`
	Label string `json:"label"`
	X     int    `json:"x"`
	Y     int    `json:"y"`
	Id    string `json:"id"`
	Index int    `json:"index"`

	// custom node data
	References []string `json:"references"`
	Entity     string   `json:"entity"`
	Tags       []string `json:"tags"`
	Names      []string `json:"names"`
	Icon       string   `json:"icon,omitempty"`

	// isEmpty defines if the
	IsEmpty bool `json:"-"`
}

information can be retrieved through the G6 Api GraphNode define a node object which is a representation of different stuff :)

func NewNode

func NewNode(label string) *Node

func NewOriginNode

func NewOriginNode(info *MetaInfo) *Node

type Register

type Register struct {
	Type int
	Key  string
}

type Todo

type Todo struct {
	Complete       bool     `json:"done"`
	Priority       string   `json:"priority"`
	CompletionDate string   `json:"completion_date"`
	CreationDate   string   `json:"creation_date"`
	Description    string   `json:"description"`
	Context        string   `json:"context"`
	Projects       []string `json:"projects"`

	// Special tokens
	RepeatToken string `json:"repeat"`
	ActionToken string `json:"action"`
	DueToken    string `json:"due"`

	Raw string `json:"_raw"`
}

https://github.com/todotxt/todo.txt#todotxt-format-rules Todo is the structor of the todo.txt

func ConvertTodo

func ConvertTodo(raw string, context string) (todo *Todo, noerror bool)

Convert TODO from the raw string into a todo rule

func NewTodo

func NewTodo() *Todo

Jump to

Keyboard shortcuts

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