document

package
v0.2.5-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIndexOutOfRange = errors.New("block index out of range")

Functions

This section is empty.

Types

type Block

type Block interface {
	json.Marshaler
	Content() string
	Start() int
	Stop() int
}

type Blocks

type Blocks []Block

func (Blocks) CodeBlocks

func (b Blocks) CodeBlocks() (result CodeBlocks)

type CodeBlock

type CodeBlock struct {
	// contains filtered or unexported fields
}

func (*CodeBlock) Attributes

func (b *CodeBlock) Attributes() map[string]string

Attributes returns code block attributes detected in the first line. They are of a form: "sh { attr=value }".

func (*CodeBlock) Content

func (b *CodeBlock) Content() string

Content returns unaltered snippet as a single blob of text.

func (*CodeBlock) Executable

func (b *CodeBlock) Executable() string

Executable returns an identifier of a program to execute the block.

func (*CodeBlock) Intro

func (b *CodeBlock) Intro() string

Intro returns a normalized description of the code block based on the preceding paragraph.

func (*CodeBlock) Line

func (b *CodeBlock) Line(idx int) string

Line returns a normalized code block line at index.

func (*CodeBlock) LineCount

func (b *CodeBlock) LineCount() int

LineCount returns the number of code block lines.

func (*CodeBlock) Lines

func (b *CodeBlock) Lines() (result []string)

Lines returns all code block lines, normalized.

func (*CodeBlock) MapLines added in v0.2.4

func (b *CodeBlock) MapLines(fn func(string) (string, error)) error

func (*CodeBlock) MarshalJSON

func (b *CodeBlock) MarshalJSON() ([]byte, error)

func (*CodeBlock) Name

func (b *CodeBlock) Name() string

Name returns a code block name.

func (*CodeBlock) SetExtracted added in v0.3.0

func (b *CodeBlock) SetExtracted(val bool)

func (*CodeBlock) Start added in v0.3.0

func (b *CodeBlock) Start() int

func (*CodeBlock) Stop added in v0.3.0

func (b *CodeBlock) Stop() int

type CodeBlocks

type CodeBlocks []*CodeBlock

func (CodeBlocks) Lookup

func (b CodeBlocks) Lookup(name string) *CodeBlock

func (CodeBlocks) Names

func (b CodeBlocks) Names() (result []string)

type MarkdownBlock

type MarkdownBlock struct {
	// contains filtered or unexported fields
}

func (*MarkdownBlock) Content

func (b *MarkdownBlock) Content() string

func (*MarkdownBlock) MarshalJSON

func (b *MarkdownBlock) MarshalJSON() ([]byte, error)

func (*MarkdownBlock) SetExtracted added in v0.3.0

func (b *MarkdownBlock) SetExtracted(val bool)

func (*MarkdownBlock) Start added in v0.3.0

func (b *MarkdownBlock) Start() int

func (*MarkdownBlock) Stop added in v0.3.0

func (b *MarkdownBlock) Stop() int

type NameResolver added in v0.3.0

type NameResolver interface {
	Get(interface{}, string) string
}

type ParsedSource

type ParsedSource struct {
	// contains filtered or unexported fields
}

func (*ParsedSource) Blocks

func (s *ParsedSource) Blocks() Blocks

func (*ParsedSource) Root

func (s *ParsedSource) Root() ast.Node

func (*ParsedSource) Source

func (s *ParsedSource) Source() []byte

type Source

type Source struct {
	// contains filtered or unexported fields
}

func NewSource

func NewSource(data []byte) *Source

func NewSourceFromFile

func NewSourceFromFile(f fs.FS, filename string) (*Source, error)

func (*Source) Parse

func (s *Source) Parse() *ParsedSource

type Updater added in v0.3.0

type Updater struct {
	// contains filtered or unexported fields
}

func NewUpdater added in v0.3.0

func NewUpdater(parsed *ParsedSource) *Updater

func NewUpdaterWithSource added in v0.3.0

func NewUpdaterWithSource(data []byte) *Updater

func (*Updater) Parsed added in v0.3.0

func (u *Updater) Parsed() *ParsedSource

func (*Updater) UpdateBlock added in v0.3.0

func (u *Updater) UpdateBlock(idx int, newSource string) error

func (*Updater) Write added in v0.3.0

func (u *Updater) Write(w io.Writer) error

Jump to

Keyboard shortcuts

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