booklit

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 13 Imported by: 5

README

booklit

GoDoc CI

documentation

vito.github.io/booklit

installation

grab the latest release, or build from source:

go get github.com/vito/booklit/cmd/booklit

usage

booklit -i foo.lit -o ./out

example

clone this repo and build its docs:

booklit \
  -i docs/lit/index.lit \
  -o docs \
  --html-templates docs/lit/html \
  --plugin github.com/vito/booklit/booklitdoc \
  --plugin github.com/vito/booklit/chroma/plugin

then browse the generated docs from ./docs/index.html.

you can see the result at https://vito.github.io/booklit

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.0.0-dev"

overridden via linker flags

Functions

func ErrorPage added in v0.11.0

func ErrorPage(err error, w http.ResponseWriter)

func RegisterPlugin

func RegisterPlugin(name string, factory PluginFactory)

Types

type AmbiguousReferenceError added in v0.11.0

type AmbiguousReferenceError struct {
	TagName          string
	DefinedLocations []ErrorLocation

	ErrorLocation
}

func (AmbiguousReferenceError) Error added in v0.11.0

func (err AmbiguousReferenceError) Error() string

func (AmbiguousReferenceError) PrettyHTML added in v0.11.0

func (err AmbiguousReferenceError) PrettyHTML(out io.Writer) error

func (AmbiguousReferenceError) PrettyPrint added in v0.11.0

func (err AmbiguousReferenceError) PrettyPrint(out io.Writer)

type AnnotationData added in v0.11.0

type AnnotationData struct {
	FilePath                  string
	EOF                       bool
	Lineno                    string
	Prefix, Annotated, Suffix string
}

type Aux added in v0.6.0

type Aux struct {
	Content
}

type Content

type Content interface {
	String() string

	IsFlow() bool

	Visit(Visitor) error
}

func Append

func Append(first Content, rest ...Content) Content

func StripAux added in v0.6.0

func StripAux(content Content) Content

type Definition added in v0.6.0

type Definition struct {
	Subject    Content
	Definition Content
}

type Definitions added in v0.6.0

type Definitions []Definition

func (Definitions) IsFlow added in v0.6.0

func (con Definitions) IsFlow() bool

func (Definitions) String added in v0.6.0

func (con Definitions) String() string

func (Definitions) Visit added in v0.6.0

func (con Definitions) Visit(visitor Visitor) error

type ErrorLocation added in v0.11.0

type ErrorLocation struct {
	FilePath     string
	NodeLocation ast.Location
	Length       int
}

func (ErrorLocation) Annotate added in v0.11.0

func (loc ErrorLocation) Annotate(msg string, args ...interface{}) string

func (ErrorLocation) AnnotateLocation added in v0.11.0

func (loc ErrorLocation) AnnotateLocation(out io.Writer) error

func (ErrorLocation) AnnotatedHTML added in v0.11.0

func (loc ErrorLocation) AnnotatedHTML(out io.Writer) error

type FailedFunctionError added in v0.11.0

type FailedFunctionError struct {
	Function string
	Err      error

	ErrorLocation
}

func (FailedFunctionError) Error added in v0.11.0

func (err FailedFunctionError) Error() string

func (FailedFunctionError) PrettyHTML added in v0.11.0

func (err FailedFunctionError) PrettyHTML(out io.Writer) error

func (FailedFunctionError) PrettyPrint added in v0.11.0

func (err FailedFunctionError) PrettyPrint(out io.Writer)

type Image added in v0.6.0

type Image struct {
	Path        string
	Description string
}

func (Image) IsFlow added in v0.6.0

func (con Image) IsFlow() bool

func (Image) String added in v0.6.0

func (con Image) String() string

func (Image) Visit added in v0.6.0

func (con Image) Visit(visitor Visitor) error
type Link struct {
	Content

	Target string
}

func (Link) Visit

func (con Link) Visit(visitor Visitor) error

type List

type List struct {
	Items []Content

	Ordered bool
}

func (List) IsFlow added in v0.6.0

func (con List) IsFlow() bool

func (List) String

func (con List) String() string

func (List) Visit

func (con List) Visit(visitor Visitor) error

type Paragraph

type Paragraph []Content

func (Paragraph) IsFlow added in v0.6.0

func (con Paragraph) IsFlow() bool

func (Paragraph) String

func (con Paragraph) String() string

func (Paragraph) Visit

func (con Paragraph) Visit(visitor Visitor) error

type ParseError added in v0.11.0

type ParseError struct {
	Err error

	ErrorLocation
}

func (ParseError) Error added in v0.11.0

func (err ParseError) Error() string

func (ParseError) PrettyHTML added in v0.11.0

func (err ParseError) PrettyHTML(out io.Writer) error

func (ParseError) PrettyPrint added in v0.11.0

func (err ParseError) PrettyPrint(out io.Writer)

type Partials added in v0.6.0

type Partials map[string]Content

type Plugin

type Plugin interface {
}

type PluginFactory

type PluginFactory func(*Section) Plugin

func LookupPlugin

func LookupPlugin(name string) (PluginFactory, bool)

type Preformatted

type Preformatted []Content

func (Preformatted) IsFlow added in v0.6.0

func (con Preformatted) IsFlow() bool

func (Preformatted) String

func (con Preformatted) String() string

func (Preformatted) Visit

func (con Preformatted) Visit(visitor Visitor) error

type PrettyError added in v0.11.0

type PrettyError interface {
	PrettyPrint(io.Writer)
	PrettyHTML(io.Writer) error
}

type Reference

type Reference struct {
	TagName string
	Content Content

	Tag *Tag

	// original location of the reference
	Location ast.Location
}

func (*Reference) Display

func (con *Reference) Display() Content

func (*Reference) IsFlow added in v0.6.0

func (con *Reference) IsFlow() bool

func (*Reference) String

func (con *Reference) String() string

func (*Reference) Visit

func (con *Reference) Visit(visitor Visitor) error

type Section

type Section struct {
	Path string

	Title Content
	Body  Content

	PrimaryTag Tag
	Tags       []Tag

	Parent   *Section
	Children []*Section

	Style    string
	Partials Partials

	SplitSections        bool
	PreventSplitSections bool

	ResetDepth bool

	OmitChildrenFromTableOfContents bool

	Processor       SectionProcessor
	PluginFactories []PluginFactory
	Plugins         []Plugin

	Location       ast.Location
	InvokeLocation ast.Location
}

func (*Section) AnchorTags

func (con *Section) AnchorTags() []Tag

func (*Section) Contains

func (con *Section) Contains(sub *Section) bool

func (*Section) Depth added in v0.6.0

func (con *Section) Depth() int

func (*Section) FilePath added in v0.11.0

func (con *Section) FilePath() string

func (*Section) FindTag

func (con *Section) FindTag(tagName string) []Tag

func (*Section) HasAnchors

func (con *Section) HasAnchors() bool

func (*Section) IsFlow added in v0.6.0

func (con *Section) IsFlow() bool

func (*Section) IsOrHasChild added in v0.6.0

func (con *Section) IsOrHasChild(sub *Section) bool

func (*Section) Next added in v0.7.0

func (con *Section) Next() *Section

func (*Section) NextSibling added in v0.7.0

func (con *Section) NextSibling() *Section

func (*Section) Number

func (con *Section) Number() string

func (*Section) PageDepth added in v0.6.0

func (con *Section) PageDepth() int

func (*Section) Partial added in v0.6.0

func (con *Section) Partial(name string) Content

func (*Section) Prev added in v0.7.0

func (con *Section) Prev() *Section

func (*Section) SetPartial added in v0.6.0

func (con *Section) SetPartial(name string, value Content)

func (*Section) SetTag added in v0.6.0

func (con *Section) SetTag(name string, title Content, loc ast.Location, optionalAnchor ...string)

func (*Section) SetTagAnchored added in v0.6.0

func (con *Section) SetTagAnchored(name string, title Content, loc ast.Location, content Content, anchor string)

func (*Section) SetTitle

func (con *Section) SetTitle(title Content, loc ast.Location, tags ...string)

func (*Section) SplitSectionsPrevented added in v0.6.0

func (con *Section) SplitSectionsPrevented() bool

func (*Section) String

func (con *Section) String() string

func (*Section) Top

func (con *Section) Top() *Section

func (*Section) UsePlugin

func (con *Section) UsePlugin(pf PluginFactory)

func (*Section) Visit

func (con *Section) Visit(visitor Visitor) error

type SectionProcessor added in v0.8.0

type SectionProcessor interface {
	EvaluateFile(*Section, string, []PluginFactory) (*Section, error)
	EvaluateNode(*Section, ast.Node, []PluginFactory) (*Section, error)
}

type Sequence

type Sequence []Content

func (Sequence) Contents

func (con Sequence) Contents() []Content

func (Sequence) IsFlow added in v0.6.0

func (con Sequence) IsFlow() bool

func (Sequence) String

func (con Sequence) String() string

func (Sequence) Visit

func (con Sequence) Visit(visitor Visitor) error

type String

type String string
var Empty String

func (String) IsFlow added in v0.6.0

func (str String) IsFlow() bool

func (String) String

func (str String) String() string

func (String) Visit

func (str String) Visit(visitor Visitor) error

type Style

type Style string
const (
	StyleVerbatim    Style = "verbatim"
	StyleItalic      Style = "italic"
	StyleBold        Style = "bold"
	StyleLarger      Style = "larger"
	StyleSmaller     Style = "smaller"
	StyleStrike      Style = "strike"
	StyleSuperscript Style = "superscript"
	StyleSubscript   Style = "subscript"
	StyleInset       Style = "inset"
	StyleAside       Style = "aside"
)

type Styled

type Styled struct {
	Style Style
	Block bool

	Content  Content
	Partials Partials
}

func (Styled) IsFlow added in v0.6.0

func (con Styled) IsFlow() bool

func (Styled) Partial added in v0.6.0

func (con Styled) Partial(name string) Content

func (Styled) String added in v0.6.0

func (con Styled) String() string

func (Styled) Visit

func (con Styled) Visit(visitor Visitor) error

type Table added in v0.6.0

type Table struct {
	Rows [][]Content
}

func (Table) IsFlow added in v0.6.0

func (con Table) IsFlow() bool

func (Table) String added in v0.6.0

func (con Table) String() string

func (Table) Visit added in v0.6.0

func (con Table) Visit(visitor Visitor) error

type TableOfContents

type TableOfContents struct {
	Section *Section
}

func (TableOfContents) IsFlow added in v0.6.0

func (con TableOfContents) IsFlow() bool

func (TableOfContents) String

func (con TableOfContents) String() string

func (TableOfContents) Visit

func (con TableOfContents) Visit(visitor Visitor) error

type Tag

type Tag struct {
	Name  string
	Title Content

	Section  *Section
	Location ast.Location
	Anchor   string

	Content Content
}

type Target

type Target struct {
	TagName  string
	Location ast.Location
	Title    Content
	Content  Content
}

func (Target) IsFlow added in v0.6.0

func (con Target) IsFlow() bool

func (Target) String

func (con Target) String() string

func (Target) Visit

func (con Target) Visit(visitor Visitor) error

type UndefinedFunctionError added in v0.11.0

type UndefinedFunctionError struct {
	Function string

	ErrorLocation
}

func (UndefinedFunctionError) Error added in v0.11.0

func (err UndefinedFunctionError) Error() string

func (UndefinedFunctionError) PrettyHTML added in v0.11.0

func (err UndefinedFunctionError) PrettyHTML(out io.Writer) error

func (UndefinedFunctionError) PrettyPrint added in v0.11.0

func (err UndefinedFunctionError) PrettyPrint(out io.Writer)

type UnknownTagError added in v0.11.0

type UnknownTagError struct {
	TagName string

	ErrorLocation
}

func (UnknownTagError) Error added in v0.11.0

func (err UnknownTagError) Error() string

func (UnknownTagError) PrettyHTML added in v0.11.0

func (err UnknownTagError) PrettyHTML(out io.Writer) error

func (UnknownTagError) PrettyPrint added in v0.11.0

func (err UnknownTagError) PrettyPrint(out io.Writer)

type Visitor

type Visitor interface {
	VisitString(String) error
	VisitSequence(Sequence) error
	VisitReference(*Reference) error
	VisitLink(Link) error
	VisitSection(*Section) error
	VisitParagraph(Paragraph) error
	VisitTableOfContents(TableOfContents) error
	VisitPreformatted(Preformatted) error
	VisitStyled(Styled) error
	VisitTarget(Target) error
	VisitImage(Image) error
	VisitList(List) error
	VisitTable(Table) error
	VisitDefinitions(Definitions) error
}

Directories

Path Synopsis
cmd
docs
hello Module
Code generated for package errhtml by go-bindata DO NOT EDIT.
Code generated for package errhtml by go-bindata DO NOT EDIT.
html
Code generated for package html by go-bindata DO NOT EDIT.
Code generated for package html by go-bindata DO NOT EDIT.
text
Code generated for package text by go-bindata DO NOT EDIT.
Code generated for package text by go-bindata DO NOT EDIT.

Jump to

Keyboard shortcuts

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