asciidoc

package
Version: v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package asciidoc contains the types and functions used to simplify generation of Asciidoc documentation from the model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Markdown added in v0.0.16

func Markdown(text string) string

Markdown converts the given text from AsciiDoc to Markdown.

Types

type Buffer

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

Buffer is a type that simplifies the generation of Asciidoc code.

func (*Buffer) Emit

func (b *Buffer) Emit(tmpl string, args ...interface{})

Emit writes to the code buffer, using the given template and arguments. The syntax of the template is the one used by the text/template package. The arguments should be a set nave/value pairs. Names should be strings, and values can be anything. These names and values will be put in a map that will then be the data object used to execute the template. For example, a template that generates the code of a Go method could be used like this:

// Calculate the name of the method and of the type:
typeName := ...
methodName := ...

// Generate the code of the method:
buffer.Emit(`
	func (c *{{ .type }}) {{ .method }} {
		...
	}
	`,
	"type", typeName,
	"method", methodName,
)

All the facilities defined in the text/template package will also be available in these templates.

func (*Buffer) Write

func (b *Buffer) Write() error

Write creates the output file and writes the generated content.

type BufferBuilder

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

BufferBuilder is used to create a new Asciidoc buffer. Don't create it directly, use the NewBuffer function instead.

func NewBufferBuilder

func NewBufferBuilder() *BufferBuilder

NewBuffer creates a builder for Asciidoc buffers.

func (*BufferBuilder) Build

func (b *BufferBuilder) Build() (buffer *Buffer, err error)

Build creates a new buffer using the configuration stored in the builder.

func (*BufferBuilder) File

func (b *BufferBuilder) File(value string) *BufferBuilder

File sets the name of the file, without the .adoc extension.

func (*BufferBuilder) Function

func (b *BufferBuilder) Function(name string, function interface{}) *BufferBuilder

Function adds a function that can then be used in the templates.

func (*BufferBuilder) Output

func (b *BufferBuilder) Output(value string) *BufferBuilder

Output sets the output directory where the source code will be generated.

func (*BufferBuilder) Reporter

func (b *BufferBuilder) Reporter(reporter *reporter.Reporter) *BufferBuilder

Reporter sets the object that will be used to report errors and other relevant information.

type NamesCalculator

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

NamesCalculator is an object used to calculate Asciidoc names. Don't create instances directly, use the builder instead.

func (*NamesCalculator) Display

func (c *NamesCalculator) Display(name *names.Name) string

Display converts the given name into an string, following the rules for names displayed in the documentation.

func (*NamesCalculator) File

func (c *NamesCalculator) File(name *names.Name) string

File converts the given name into an string, following the rules for Asciidoc files.

func (*NamesCalculator) Tag

func (c *NamesCalculator) Tag(name *names.Name) string

Tag converts the given name into an string, following the rules for JSON field names.

type NamesCalculatorBuilder

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

NamesCalculatorBuilder is an object used to configure and build the Asciidoc names calculators. Don't create instances directly, use the NewNamesCalculator function instead.

func NewNamesCalculator

func NewNamesCalculator() *NamesCalculatorBuilder

NewNamesCalculator creates an Asciidoc names calculator builder.

func (*NamesCalculatorBuilder) Build

func (b *NamesCalculatorBuilder) Build() (calculator *NamesCalculator, err error)

Build checks the configuration stored in the builder and, if it is correct, creates a new calculator using it.

func (*NamesCalculatorBuilder) Reporter

Reporter sets the object that will be used to report information about the calculation processes, including errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL