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 ¶
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 ¶
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 ¶
FilterBlocks returns the blocks visible to the given audience. Blocks whose Target is TargetAll always pass; otherwise Target must match audience.
type Step ¶
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.
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 ¶
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.