tour

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = codeblock.Config{
	EnablePHP:    true,
	EnableVuego:  true,
	EnableSQLite: true,
}

DefaultConfig enables the evaluators the tour relies on. Shell execution is intentionally left disabled.

Functions

func ValidateLesson

func ValidateLesson(lesson *Lesson) error

ValidateLesson checks that a lesson has at least one runnable file.

func ValidateTour

func ValidateTour(t *Tour) error

ValidateTour checks that all lessons in the tour have valid content.

Types

type Chapter

type Chapter struct {
	Name    string    // Chapter name (from filename)
	Title   string    // Chapter title (from # heading or filename)
	Lessons []*Lesson // Lessons in this chapter
	Index   int       // Chapter index (0-based)
}

Chapter represents a chapter containing multiple lessons.

func (*Chapter) Slug

func (c *Chapter) Slug() string

Slug returns the directory name for a chapter (strips numeric prefix). e.g., "01-interpolation" -> "interpolation".

type Lesson

type Lesson struct {
	ID             string              // Unique identifier (chapter/lesson index)
	Title          string              // Lesson title from ## heading
	Content        string              // Markdown content for the lesson
	Files          map[string]string   // Template and data files for this lesson
	FileRefs       []string            // File paths from @file: references
	FileOptions    map[string][]string // Optional hints from @file references, keyed by filename
	Chapter        string              // Parent chapter name
	ChapterTitle   string              // Parent chapter title (friendly name)
	ChapterSlug    string              // URL-friendly chapter name (e.g., "interpolation")
	ChapterIdx     int                 // Chapter index (0-based)
	LessonIdx      int                 // Lesson index within chapter (0-based)
	HasPrev        bool                // Whether there's a previous lesson
	HasNext        bool                // Whether there's a next lesson
	PrevID         string              // Previous lesson ID
	NextID         string              // Next lesson ID
	PrevSlug       string              // Previous lesson chapter slug
	PrevLessonIdx  int                 // Previous lesson index
	NextSlug       string              // Next lesson chapter slug
	NextLessonIdx  int                 // Next lesson index
	TotalInChapter int                 // Total lessons in this chapter
}

Lesson represents a single lesson within a chapter.

func (*Lesson) DataFile

func (l *Lesson) DataFile() string

DataFile returns the data filename (.yaml or .json) that matches the primary template.

func (*Lesson) PrimaryTemplate

func (l *Lesson) PrimaryTemplate() string

PrimaryTemplate returns the main .vuego template filename for the lesson. It looks for index.vuego first, then any .vuego file.

type Module

type Module struct {
	platform.UnimplementedModule

	FS fs.FS
	// contains filtered or unexported fields
}

Module represents the tour module for the platform.

func NewModule

func NewModule(contentFS fs.FS) *Module

NewModule creates a new tour module using embedded content.

func (*Module) Mount

func (m *Module) Mount(_ context.Context, r platform.Router) error

Mount registers the tour routes.

func (*Module) Name

func (m *Module) Name() string

Name returns the module name.

type Tour

type Tour struct {
	Chapters []*Chapter
	// contains filtered or unexported fields
}

Tour holds all chapters and lessons.

func ParseTour

func ParseTour(contentFS fs.FS) (*Tour, error)

ParseTour parses a tour from the given filesystem. It expects markdown files in the root and lesson files in subdirectories.

func (*Tour) FirstLesson

func (t *Tour) FirstLesson() *Lesson

FirstLesson returns the first lesson in the tour.

func (*Tour) GetLesson

func (t *Tour) GetLesson(id string) *Lesson

GetLesson returns a lesson by its ID.

func (*Tour) GetLessonByName

func (t *Tour) GetLessonByName(chapterName, lessonIdx string) *Lesson

GetLessonByName returns a lesson by chapter name and lesson index. The chapter name is matched against the suffix of the chapter name (e.g., "interpolation" matches "01-interpolation").

func (*Tour) LessonCount

func (t *Tour) LessonCount() int

LessonCount returns the total number of lessons.

Jump to

Keyboard shortcuts

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