model

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const AnonBlockName = "clickToCopy"

AnonBlockName used for blocks that have no explicit name.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockParsed

type BlockParsed struct {
	base.BlockBase
	// contains filtered or unexported fields
}

BlockParsed groups a BlockBase with labels.

func NewBlockParsed

func NewBlockParsed(labels []base.Label, p base.MdProse, c base.OpaqueCode) *BlockParsed

NewBlockParsed returns a BlockParsed with the given content.

func NewProseOnlyBlock

func NewProseOnlyBlock(p base.MdProse) *BlockParsed

NewProseOnlyBlock makes a BlockParsed with no code.

func (*BlockParsed) HasLabel

func (x *BlockParsed) HasLabel(label base.Label) bool

HasLabel is true if the block has the given label argument.

func (*BlockParsed) Labels

func (x *BlockParsed) Labels() []base.Label

Labels are the labels found on the block.

type BlockTut

type BlockTut struct {
	BlockParsed
}

BlockTut is a part of a LessonTut - one block of code, maybe with prose.

func NewBlockTut

func NewBlockTut(b *BlockParsed) *BlockTut

NewBlockTut is a ctor.

func (*BlockTut) Accept

func (x *BlockTut) Accept(v TutVisitor)

Accept accepts a visitor.

func (*BlockTut) Children

func (x *BlockTut) Children() []Tutorial

Children of the block - there aren't any at this time. One could imagine each line of code in a code block as a child if that were useful somehow.

func (*BlockTut) Name

func (x *BlockTut) Name() string

Name attempts to return a decent name for the block.

func (*BlockTut) Path

func (x *BlockTut) Path() base.FilePath

Path to the file containing the block.

func (*BlockTut) Title

func (x *BlockTut) Title() string

Title is what appears to be the title of the block.

type Course

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

Course is a directory - an ordered list of Lessons and Courses.

func NewCourse

func NewCourse(p base.FilePath, c []Tutorial) *Course

NewCourse makes a Course.

func (*Course) Accept

func (c *Course) Accept(v TutVisitor)

Accept accepts a visitor.

func (*Course) Children

func (c *Course) Children() []Tutorial

Children are the parts of the course.

func (*Course) Name

func (c *Course) Name() string

Name is the purported Course name.

func (*Course) Path

func (c *Course) Path() base.FilePath

Path is where the course came from.

func (*Course) Title

func (c *Course) Title() string

Title is the purported Course title.

type LessonCounter

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

LessonCounter is a visitor that merely counts lessons.

func NewTutorialLessonCounter

func NewTutorialLessonCounter() *LessonCounter

NewTutorialLessonCounter makes a new LessonCounter.

func (*LessonCounter) Count

func (v *LessonCounter) Count() int

Count is the reason this visitor exists.

func (*LessonCounter) VisitBlockTut

func (v *LessonCounter) VisitBlockTut(b *BlockTut)

VisitBlockTut does nothing.

func (*LessonCounter) VisitCourse

func (v *LessonCounter) VisitCourse(c *Course)

VisitCourse visits children.

func (*LessonCounter) VisitLessonTut

func (v *LessonCounter) VisitLessonTut(l *LessonTut)

VisitLessonTut increments the count.

func (*LessonCounter) VisitTopCourse

func (v *LessonCounter) VisitTopCourse(t *TopCourse)

VisitTopCourse visits children.

type LessonTut

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

LessonTut has a one to one correspondence to a file. It must have a name, and may have blocks. An entirely empty file might appear with no blocks.

func NewLessonTutForTests

func NewLessonTutForTests(p base.FilePath, blocks []*BlockTut) *LessonTut

NewLessonTutForTests makes one for tests.

func NewLessonTutFromMdContent

func NewLessonTutFromMdContent(p base.FilePath, md *MdContent) *LessonTut

NewLessonTutFromMdContent converts MdContent to a LessonTut.

func (*LessonTut) Accept

func (l *LessonTut) Accept(v TutVisitor)

Accept accepts a visitor.

func (*LessonTut) Blocks

func (l *LessonTut) Blocks() []*BlockTut

Blocks in the lesson.

func (*LessonTut) Children

func (l *LessonTut) Children() []Tutorial

Children of the lesson - the code blocks.

func (*LessonTut) Name

func (l *LessonTut) Name() string

Name is the purported name of the lesson.

func (*LessonTut) Path

func (l *LessonTut) Path() base.FilePath

Path to the lesson. A lesson has a 1:1 correspondence with a path.

func (*LessonTut) Title

func (l *LessonTut) Title() string

Title is the purported title of the LessonTut.

type MdContent

type MdContent struct {
	Blocks []*BlockParsed
	// contains filtered or unexported fields
}

MdContent represents markdown content.

func NewMdContent

func NewMdContent() *MdContent

NewMdContent makes a new instance of MdContent.

func (*MdContent) AddBlockParsed

func (md *MdContent) AddBlockParsed(x *BlockParsed)

AddBlockParsed adds an instance of BlockParsed.

func (*MdContent) AddCode

func (md *MdContent) AddCode(x string)

AddCode adds code.

func (*MdContent) AddHeader

func (md *MdContent) AddHeader(x string, w int)

AddHeader adds a header.

func (*MdContent) AddProse

func (md *MdContent) AddProse(x string)

AddProse adds prose.

func (*MdContent) GetTitle

func (md *MdContent) GetTitle() string

GetTitle returns the most likely title of the markdown.

func (*MdContent) HasTitle

func (md *MdContent) HasTitle() bool

HasTitle is true if a title can be discerned from the markdown.

type TopCourse

type TopCourse struct {
	Course
}

A TopCourse is exactly like a Course accept that visitors may treat it differently, ignoring everything about it except its children. Its name is special in that it might be derived from a URL, from a list of files and directories, etc. It's usually a list of directories.

func NewTopCourse

func NewTopCourse(n string, p base.FilePath, c []Tutorial) *TopCourse

NewTopCourse makes a new TopCourse.

func (*TopCourse) Accept

func (t *TopCourse) Accept(v TutVisitor)

Accept accepts a visitor.

type TutVisitor

type TutVisitor interface {
	VisitTopCourse(t *TopCourse)
	VisitCourse(c *Course)
	VisitLessonTut(l *LessonTut)
	VisitBlockTut(b *BlockTut)
}

TutVisitor has the ability to visit the items specified in its methods.

type Tutorial

type Tutorial interface {
	Accept(v TutVisitor)
	Title() string
	Name() string
	Path() base.FilePath
	Children() []Tutorial
}

Tutorial represents a book in tree / hierarchical form.

type TxtPrinter

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

TxtPrinter prints a tutorial as text.

func NewTutorialTxtPrinter

func NewTutorialTxtPrinter(w io.Writer) *TxtPrinter

NewTutorialTxtPrinter makes a new TxtPrinter for the given writer.

func (*TxtPrinter) Depth

func (v *TxtPrinter) Depth() int

Depth is how deep we are in a tutorial tree.

func (*TxtPrinter) Down

func (v *TxtPrinter) Down()

Down goes deeper.

func (*TxtPrinter) P

func (v *TxtPrinter) P(s string, a ...interface{})

P does a formatted print.

func (*TxtPrinter) Up

func (v *TxtPrinter) Up()

Up is opposite of Down.

func (*TxtPrinter) VisitBlockTut

func (v *TxtPrinter) VisitBlockTut(b *BlockTut)

VisitBlockTut prints a BlockTut.

func (*TxtPrinter) VisitCourse

func (v *TxtPrinter) VisitCourse(c *Course)

VisitCourse prints a Course.

func (*TxtPrinter) VisitLessonTut

func (v *TxtPrinter) VisitLessonTut(l *LessonTut)

VisitLessonTut prints a LessonTut.

func (*TxtPrinter) VisitTopCourse

func (v *TxtPrinter) VisitTopCourse(t *TopCourse)

VisitTopCourse prints the children of a TopCourse.

Jump to

Keyboard shortcuts

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