journal

package
v0.0.0-...-6339fb7 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Files

func Files(paths []string, recurse bool) (entries []string, err error)

Files finds journal entry files. It walks each given path checking for ones that look like journal entries. It returns a list of the entries it finds. If recurse is true, Files will recurse into subdirectories.

Types

type Entry

type Entry struct {
	Time time.Time
	File string

	// Linked list of tags.
	FirstTag *tagNode
	// contains filtered or unexported fields
}

Entry is a file in the journal and its associated tags.

func NewEntry

func NewEntry(file string) (e Entry, err error)

NewEntry returns a new Entry.

func (Entry) Title

func (e Entry) Title() string

Title returns a title for the entry. It uses the first heading if one exists. If no heading is found, it uses the portion of the entry's filename after the date as the title. In the latter case, dashes (`-`) and underscores (`_`) are converted to spaces, and the first letter of each word is capitalized.

type FileParser

type FileParser struct {
	parser.Parser
}

FileParser parses entry file markdown contents into ctags tags.

func NewFileParser

func NewFileParser() FileParser

NewFileParser returns a new FileParser.

func (FileParser) Parse

func (p FileParser) Parse(filename string) (lines []ctags.TagLine, err error)

Parse parses the given entry into ctags tags.

type Journal

type Journal struct {
	Entries []Entry
	Labels  []Label
}

Journal is a collection of entries and labels.

func NewJournal

func NewJournal(tags TagLines) (j Journal)

NewJournal returns a new Journal.

func (Journal) WriteLabels

func (j Journal) WriteLabels(w io.Writer, setters ...WriterOption) error

WriteLabels generates a list of entries categorized by label and writes the result to a writer.

func (Journal) WriteTimeline

func (j Journal) WriteTimeline(w io.Writer, setters ...WriterOption) error

WriteTimeline generates a timeline view of entries and writes the result to a writer.

type Label

type Label struct {
	Name        string
	Occurrences []LabelTag
}

Label is a keyword that appears in a journal entry.

type LabelOccurrences

type LabelOccurrences []LabelTag

LabelOccurrences attaches the methods of sort.Interface to []LabelTag.

func (LabelOccurrences) Len

func (lo LabelOccurrences) Len() int

func (LabelOccurrences) Less

func (lo LabelOccurrences) Less(i, j int) bool

Sort by label name in increasing order, then tagfile and line number in decreasing order.

func (LabelOccurrences) Swap

func (lo LabelOccurrences) Swap(i, j int)

type LabelTag

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

LabelTag is an occurrence of a Label within a journal entry.

type TagLines

type TagLines []ctags.TagLine

TagLines attaches the methods of sort.Interface to []ctags.TagLine.

func (TagLines) Len

func (t TagLines) Len() int

func (TagLines) Less

func (t TagLines) Less(i, j int) bool

Sort by tagfile then line number in increasing order. Headings appear first.

func (TagLines) Swap

func (t TagLines) Swap(i, j int)

type WriterOption

type WriterOption func(*WriterOptions)

WriterOption appplies an option to a WriterOptions struct.

func HeadingLevel

func HeadingLevel(level int) WriterOption

HeadingLevel sets the Level WriterOption value.

type WriterOptions

type WriterOptions struct {
	Level int
}

WriterOptions stores options for write functions.

Jump to

Keyboard shortcuts

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