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
- func Base(cacheHome string) string
- func Copy(ctx context.Context, lessons fs.FS, root, dir string, ...) error
- func Expansions(commands []string, keys KeyLabeler) map[string]string
- func Folder(cacheHome string, inUse func(dir string) bool) (string, error)
- func IsPractice(cacheHome, p string) bool
- func Placeholders(lessons fs.FS, root string) ([]string, error)
- type KeyLabeler
Constants ¶
const MainFile = "TUTOR.md"
MainFile is the lesson file a copy opens with.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
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 ¶
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 ¶
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.
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.