tutorial

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 3 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 tutorial holds the data definitions for Ghost's guided tutorials. The CLI command in internal/cmd consumes these definitions to run a tutorial interactively; the generate-tutorial-docs binary consumes the same definitions to render the matching markdown docs. Keeping the data here (rather than next to either consumer) makes the source-of-truth explicit and avoids leaking doc-rendering concerns into the CLI package.

Index

Constants

View Source
const (
	SetupSQL      = "" /* 233-byte string literal not displayed */
	MutateForkSQL = "" /* 155-byte string literal not displayed */
	QuerySQL      = "SELECT id, name, location FROM ghost_tutorial_items ORDER BY id;"
)

SQL statements run during the tutorial. Exported so test code in other packages can match recorded query strings against them.

Variables

This section is empty.

Functions

func FormatCommand

func FormatCommand(args []string) string

FormatCommand builds the user-facing echo string from sub-command args. The sql command's query argument is rendered specially so multi-statement queries appear on multiple indented, quoted lines instead of as a single long line. Shared between the CLI step echo and the markdown code blocks so the two stay in sync.

Types

type Block

type Block struct {
	Prose           string
	Args            []string
	ExpectedOutput  string
	Target          Target
	CreatesDatabase string
	RemovesDatabase string
}

Block is one unit of tutorial content: optional prose followed by an optional ghost CLI command. ExpectedOutput is shown only in the markdown doc — the live CLI prints whatever the sub-command actually emits. Target lets a block be doc-only (e.g. the cleanup preamble that explains how the live tutorial transitions into Step 7) or CLI-only. CreatesDatabase and RemovesDatabase track side effects on the cleanup list for the live runtime; they are ignored by the markdown renderer.

func FilterBlocks

func FilterBlocks(blocks []Block, audience Target) []Block

FilterBlocks returns the blocks visible to the given audience. Blocks whose Target is TargetAll always pass; otherwise Target must match audience.

type Step

type Step struct {
	Title        string
	Blocks       []Block
	JoinedBlocks bool
}

Step is a numbered group of Blocks under a single heading. When JoinedBlocks is true, adjacent blocks render flush against each other (no blank line between them) — used for tight sequences such as the paired delete commands at the end of the tutorial.

type Target

type Target int

Target controls whether a Block appears in the live CLI run, the rendered markdown doc, or both. The zero value (TargetAll) means the block is visible everywhere, which is the common case.

const (
	TargetAll Target = iota
	TargetCLIOnly
	TargetDocsOnly
)

type Tutorial

type Tutorial struct {
	Filename   string
	Title      string
	Callout    string
	Intro      []string
	Steps      []Step
	DeleteStep Step
}

Tutorial bundles everything about one tutorial: the narrative shown in docs/tutorials/<Filename>, the steps run by the live `ghost tutorial` command, and an optional cleanup step the live CLI conditionally runs after a user prompt. New tutorials should be added to All().

func All

func All() []Tutorial

All is the registry of every tutorial defined in this package. The generate-tutorial-docs binary iterates this list to render markdown docs; the live `ghost tutorial` CLI command picks one (currently always learn-the-basics).

func BuildLearnTheBasicsTutorial

func BuildLearnTheBasicsTutorial(originalDatabaseName, forkDatabaseName string) Tutorial

BuildLearnTheBasicsTutorial constructs the learn-the-basics tutorial using the provided database names. The docs registry passes placeholder names so the rendered markdown reads consistently; the live CLI passes dynamically generated names so its sub-commands operate on real databases.

Jump to

Keyboard shortcuts

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