Documentation
¶
Overview ¶
Package root implements the ctx why command.
It displays the philosophy and design rationale behind ctx, including the manifesto and project invariants.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DocAliases = map[string]string{
"manifesto": "manifesto",
"about": "about",
"invariants": "design-invariants",
}
DocAliases maps user-facing names to embedded asset names.
var DocOrder = []DocEntry{
{"manifesto", "The ctx Manifesto"},
{"about", "About ctx"},
{"invariants", "Design Invariants"},
}
DocOrder defines the display order for the interactive menu.
Functions ¶
func Cmd ¶
Cmd returns the "ctx why" cobra command.
Returns:
- *cobra.Command: Configured why command with document aliases
func ExtractAdmonitionTitle ¶
ExtractAdmonitionTitle pulls the quoted title from an admonition line. e.g., `!!! note "Title"` -> "Title"
Parameters:
- line: The admonition line to parse
Returns:
- string: The extracted title, or empty string if no valid title found
func ExtractTabTitle ¶
ExtractTabTitle pulls the quoted title from a tab marker line. e.g., `=== "Name"` -> "Name"
Parameters:
- line: The tab marker line to parse
Returns:
- string: The extracted title, or empty string if no valid title found
func Run ¶
Run dispatches to the interactive menu or direct document display.
Parameters:
- cmd: Cobra command for output stream
- args: Command arguments; optional args[0] is the document alias
Returns:
- error: Non-nil if the document is not found or input is invalid
func ShowDoc ¶
ShowDoc loads an embedded document by alias, strips MkDocs syntax, and prints it.
Parameters:
- cmd: Cobra command for output stream
- alias: Document alias (manifesto, about, or invariants)
Returns:
- error: Non-nil if the alias is unknown or the document fails to load
func StripMkDocs ¶
StripMkDocs removes MkDocs-specific syntax from Markdown content so it reads cleanly in the terminal.
Handles:
- YAML frontmatter (--- blocks): removed
- Image refs (): line removed
- Admonitions (!!! type "Title"): converted to blockquote with bold title
- Tab markers (=== "Name"): converted to bold name; body dedented
- Relative .md links (text(file.md)): kept as text only
Parameters:
- content: Raw Markdown with MkDocs syntax
Returns:
- string: Cleaned Markdown suitable for terminal display