render

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DocString

func DocString(w io.Writer, f *parser.File, doc *ast.CommentGroup, wrapDocString int, lastPos, nextPos token.Pos)

DocString renders a docstring from lastPos to nextPos where lastPos is the end of the previous Decl and next pos is the start of the Decl corresponding to this doc string.

func Func

func Func(w io.Writer, f *parser.File, fn *parser.FuncDecl, tabSize, wrapBody, wrapDocString int, lastPos token.Pos)

Func renders the function fn into w. The function is wrapped so that no line exceeds past the wrap column wrapCol when tabs are rendered with specified tab size.

func GenDecl

func GenDecl(w io.Writer, f *parser.File, decl ast.GenDecl, wrapDocString int, lastPos token.Pos)

func Imports

func Imports(w io.Writer, f *parser.File, block ImportBlock)

Imports renders imports into w. Imports are separated into groups; groups are output in the order that they appear and separated by a blank line.

func Simplify

func Simplify(f *ast.File)

Types

type ImportBlock

type ImportBlock []ImportGroup

An ImportBlock is a collectino of ImportGroups.

func (ImportBlock) Size

func (b ImportBlock) Size() int

Size returns the number of specs within the import block.

type ImportGroup

type ImportGroup []parser.ImportSpec

An ImportGroup is a collection of related imports. It implements sort.Interface to sort imports by path.

func (ImportGroup) Len

func (ig ImportGroup) Len() int

func (ImportGroup) Less

func (ig ImportGroup) Less(i, j int) bool

func (ImportGroup) Swap

func (ig ImportGroup) Swap(i, j int)

Jump to

Keyboard shortcuts

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