Documentation
¶
Index ¶
- func EachCommand(book *Book, cmd string, ...) error
- func EachItem(parentItem *BookItem, visitor ChapterVisitor) error
- func EachItemInBook(book *Book, visitor ChapterVisitor) error
- func Run(plug Plugin, inputRaw io.Reader, outputRaw io.Writer, args ...string) error
- type Book
- type BookChapter
- type BookConfig
- type BookItem
- type BookSection
- type ChapterVisitor
- type Config
- type Context
- type Input
- type Plugin
- type SectionNumber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EachCommand ¶
func EachCommand(book *Book, cmd string, callback func(chapter *BookChapter, args string) (string, error)) error
EachCommand looks for mustache-like declarations of the form `{{#cmd args}}` in each book chapter, and calls the callback for each one, substituting it for the result.
func EachItem ¶
func EachItem(parentItem *BookItem, visitor ChapterVisitor) error
EachItem calls the given visitor for each chapter in the given item, passing a pointer to the actual chapter that the visitor can modify.
func EachItemInBook ¶
func EachItemInBook(book *Book, visitor ChapterVisitor) error
EachItemInBook functions identically to EachItem, except that it visits all chapters in the book.
Types ¶
type Book ¶
type Book struct { Sections []BookItem `json:"sections"` NonExhaustive *struct{} `json:"__non_exhaustive"` }
Book is an mdBook book.
type BookChapter ¶
type BookChapter struct { Name string `json:"name"` Content string `json:"content"` Number SectionNumber `json:"number"` SubItems []BookItem `json:"sub_items"` Path string `json:"path"` ParentNames []string `json:"parent_names"` }
BookChapter is an mdBook chapter.
type BookConfig ¶
type BookConfig struct {
Src string `json:"src"`
}
BookConfig is a (partial) mdBook [book] stanza
type BookItem ¶
type BookItem bookItem
BookItem is an mdBook item. It wraps an underlying struct to provide proper marshalling and unmarshalling according to what serde produces/expects.
func (BookItem) MarshalJSON ¶
func (*BookItem) UnmarshalJSON ¶
type BookSection ¶
type BookSection struct {
Items []BookItem `json:"items"`
}
BookSection is an mdBook section.
type ChapterVisitor ¶
type ChapterVisitor func(*BookChapter) error
ChapterVisitor visits each BookChapter in a book, getting an actual pointer to the chapter that it can modify.
type Config ¶
type Config struct {
Book BookConfig `json:"book"`
}
Config is a (partial) mdBook config
type Input ¶
Input is the tuple that's presented to mdBook plugins. It's deserialized from a slice `[context, book]`, matching a Rust tuple.
func (*Input) UnmarshalJSON ¶
type Plugin ¶
type Plugin interface { // SupportsOutput checks if the given plugin supports the given output format. SupportsOutput(string) bool // Process modifies the book in the input, which gets returned as the result of the plugin. Process(*Input) error }
Plugin represents a mdBook plugin.
type SectionNumber ¶
type SectionNumber []uint32
SectionNumber is an mdBook section number (e.g. `1.2` is `{1,2}`).