Documentation
¶
Index ¶
- type Document
- type Dossier
- func (dossier *Dossier) CacheDocuments(docsFolderPath string)
- func (dossier *Dossier) CompleteShortTitle(match string) (titles []string)
- func (dossier *Dossier) FormatFrontMatter(format string, docs []Document)
- func (dossier *Dossier) InitalizeTerminalRenderer() (err error)
- func (dossier *Dossier) InitializeMarkdownHandler()
- func (dossier *Dossier) ListCategories(docs []Document) (categories []string)
- func (dossier *Dossier) ListTags(docs []Document) (tags []string)
- func (dossier *Dossier) ListTitles(docs []Document) (titles []Title)
- func (dossier *Dossier) Render(body string) (output string, err error)
- func (dossier *Dossier) RenderDocument(doc Document) (string, error)
- func (dossier *Dossier) SelectDocument(shortTitle string) (document Document, err error)
- type DossierI
- type FrontMatter
- type Title
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct { // Metadata about the Document FrontMatter FrontMatter // The text of the Document in markdown Body string }
A Document is sourced from markdown either embedded in the binary or available via another filesystem.
func FilterByCategory ¶
FilterByCategory returns a slice of Documents which have the specified category.
func FilterByTag ¶
FilterByTag returns a slice of Documents which have the specified tag.
type Dossier ¶
type Dossier struct { // The handler for interacting with a filesystem - local, remote, or otherwise. AFS *afero.Afero // The handler for interacting with documents embedded in the binary itself EFS *embed.FS // The handler for writing documents to the terminal with style TerminalRenderer *glamour.TermRenderer // The handler for parsing a markdown document with frontmatter MarkdownHandler *front.Matter // The cache of parsed documents in the Dossier Documents []Document }
A Dossier contains everything needed to display documentation in the terminal
func (*Dossier) CacheDocuments ¶
CacheEmbeddedDocuments searches the Dossier's embedded file system at the specified folder path, parsing all discovered markdown documents and caching them in the Dossier.
func (*Dossier) CompleteShortTitle ¶
CompleteShortTitle returns the list of short titles which are a valid match for the specified string as a prefix.
func (*Dossier) FormatFrontMatter ¶
FormatFrontMatter returns either the string representation of the JSON object containing the specified frontmatter or the rendered markdown table representation of the frontmatter to the caller but does not print either itself.
func (*Dossier) InitalizeTerminalRenderer ¶
InitializeTerminalRenderer creates the terminal renderer if it does not already exist and defines how it should behave.
func (*Dossier) InitializeMarkdownHandler ¶
func (dossier *Dossier) InitializeMarkdownHandler()
InitializeMarkdownHandler creates the handler for markdown documents if it does not already exist and defines how it should behave.
func (*Dossier) ListCategories ¶
ListCategories returns a slice of strings containing all of the unique categories used by the Documents in the Dossier's cache.
func (*Dossier) ListTags ¶
ListTags returns a slice of strings containing all of the unique tags used by the Documents in the Dossier's cache.
func (*Dossier) ListTitles ¶
ListTitles returns a slice of Titles (the short and long names) from every Document in the Dossier's cache.
func (*Dossier) Render ¶
Render initializes the terminal renderer if needed and then uses it to render the body of a markdown document, returning the rendered string for printing to the screen but not printing it itself.
func (*Dossier) RenderDocument ¶
RenderDocument returns the terminal-rendered markdown of the specified document but does not print it itself.
type DossierI ¶
type DossierI interface { // CacheDocuments searches the Dossier's embedded file system at the specified folder path, parsing all discovered // markdown documents and caching them in the Dossier. CacheDocuments(docsFolderPath string) // RenderDocument returns the terminal-rendered markdown of the specified document but does not print it itself. RenderDocument(doc Document) (string, error) // FormatFrontMatter returns either the string representation of the JSON object containing the specified frontmatter // or the rendered markdown table representation of the frontmatter to the caller but does not print either itself. FormatFrontMatter(format string, docs []Document) // SelectDocument returns the Document which has the specified short title. If no Document matches, it errors. SelectDocument(shortTitle string) (document Document, err error) // CompleteShortTitle returns the list of short titles which are a valid match for the specified string as a prefix. CompleteShortTitle(match string) (titles []string) // ListCategories returns a slice of strings containing all of the unique categories used by the Documents in the // Dossier's cache. ListCategories(docs []Document) (categories []string) // ListTags returns a slice of strings containing all of the unique tags used by the Documents in the Dossier's cache. ListTags(docs []Document) (tags []string) }
To implement your own Dossier, you must be able to read markdown documents, render them, list them all, list them filtered by category, list them filtered by tag, and cache them. TODO: Use actually needed methods
type FrontMatter ¶
type FrontMatter struct { // The human-readable title for the document and the short name suitable for shell completion Title Title // A short synopsis of the document's contents Description string // Whether this document is Conceptual, Narrative, or something else Category string // Freeform list of strings to help users filter and find documents Tags []string }
All Documents in a Dossier have required frontmatter; the source markdown document may have other metadata but it *must* have these fields.