tutor

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tutor makes the practice copies of the Emetos Tutor (SPEC §10.35): a folder of lessons, in the spirit of vimtutor, that the user edits in the editor itself. It picks the folder of a copy, writes the lessons into it with the user's own keys in place of the placeholders, and tells a practice folder from the others. It never imports the UI.

Index

Constants

View Source
const MainFile = "TUTOR.md"

MainFile is the lesson file a copy opens with.

Variables

This section is empty.

Functions

func Base

func Base(cacheHome string) string

Base is the folder that holds the practice copies: $XDG_CACHE_HOME/emetos.

func Copy

func Copy(ctx context.Context, lessons fs.FS, root, dir string, expansions map[string]string) error

Copy writes a fresh practice copy into dir: the folder is emptied (it must be a practice folder of Base) and the files under root of lessons are written into it, with the placeholders of the Markdown files replaced by expansions. The error is TutorCopyFailed, with the folder in its metadata.

func Expansions

func Expansions(commands []string, keys KeyLabeler) map[string]string

Expansions gives the text that replaces the placeholder of each command: the label of its key, or how to run it from the Command Palette when it has none.

func Folder

func Folder(cacheHome string, inUse func(dir string) bool) (string, error)

Folder picks the folder of a new copy: tutor, or tutor-2, tutor-3 ... when inUse says a workspace still has the earlier ones open. The error is TutorNoFreeFolder.

func IsPractice

func IsPractice(cacheHome, p string) bool

IsPractice tells whether a path is a practice folder of the tutor or inside one, so that it is kept out of the recently opened folders and files.

func Placeholders

func Placeholders(lessons fs.FS, root string) ([]string, error)

Placeholders lists the commands that the lessons under root name with {{key:...}}, each once, sorted.

Types

type KeyLabeler

type KeyLabeler interface {
	// KeyLabel is the label of the key that runs a command ("Ctrl+D"), or "" when it has no key.
	KeyLabel(command string) string
	// CommandTitle is the title of a command as the Command Palette shows it, and whether the command exists.
	CommandTitle(command string) (string, bool)
}

KeyLabeler tells how a command is run: the label of its key, and its title for a command with none.

Jump to

Keyboard shortcuts

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