lib

package
v0.0.0-...-bc7ee3a Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package lib generates starlark documentation from go code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doc

type Doc struct {
	Name        string
	Path        string
	Description string
	Functions   Functions
	Types       Types
	// contains filtered or unexported fields
}

Doc is is a documentation document

func ParseFirst

func ParseFirst(r io.Reader, opts ...Option) (doc *Doc, err error)

ParseFirst consumes a reader of outline data, creating and returning the first outline document it encounters. ParseFirst consumes the entire reader TODO(b5): don't consume the entire reader. return after the first complete document

func (*Doc) Examples

func (d *Doc) Examples() (egs []*Example)

Examples returns a slice of all examples defined in the document

func (*Doc) MarshalIndent

func (d *Doc) MarshalIndent(depth int, prefix string) ([]byte, error)

MarshalIndent writes doc to a string with depth & prefix

func (*Doc) Sort

func (d *Doc) Sort()

Sort sorts all sortable fields in the document

type Docs

type Docs []*Doc

Docs is a sortable slice of Doc pointers

func Parse

func Parse(r io.Reader, opts ...Option) (docs Docs, err error)

Parse consumes a reader of data that contains zero or more outlines creating and returning any documents it finds

func (Docs) Len

func (d Docs) Len() int

Len implements the sort.Sortable interface

func (Docs) Less

func (d Docs) Less(i, j int) bool

Less implements the sort.Sortable interface

func (Docs) Sort

func (d Docs) Sort()

Sort sorts all sortable fields in all docs, and the docs list itself

func (Docs) Swap

func (d Docs) Swap(i, j int)

Swap implements the sort.Sortable interface

type Example

type Example struct {
	Name        string
	Description string
	Code        string
}

type Field

type Field struct {
	Name        string
	Type        string
	Description string
}

Field is a property of a constructed Type

type Function

type Function struct {
	FuncName    string
	Receiver    string // should be set by parsing context
	Signature   string
	Description string
	Params      []*Param
	Return      string
	Examples    []*Example
}

Function documents a starlark function

type Functions

type Functions []*Function

Functions is a sortable slice of Function pointers

func (Functions) Len

func (f Functions) Len() int

Len implements the sort.Sortable interface

func (Functions) Less

func (f Functions) Less(i, j int) bool

Less implements the sort.Sortable interface

func (Functions) Swap

func (f Functions) Swap(i, j int)

Swap implements the sort.Sortable interface

type Operator

type Operator struct {
	Opr         string
	Description string
}

Operator documents boolean operation on a constructed type

type Option

type Option interface {
	// contains filtered or unexported methods
}

func AlphaSortFuncs

func AlphaSortFuncs() Option

func AlphaSortTypes

func AlphaSortTypes() Option

type Param

type Param struct {
	Name        string
	Type        string
	Optional    bool
	Description string
}

Param is an argument to a function

type Position

type Position struct {
	Line, Col, Offset int
}

Position of a token within the scan stream

type Token

type Token struct {
	Type TokenType
	Pos  Position
	Text string
}

Token is a recognized token from the outlineline lexicon

func (Token) String

func (t Token) String() string

String implements the stringer interface for token

type TokenType

type TokenType int

TokenType enumerates the different types of tokens

const (
	// IllegalTok is the default for unrecognized tokens
	IllegalTok TokenType = iota

	// LiteralBegin marks the beginning of literal tokens in the token enumeration
	LiteralBegin
	// IndentTok is a tab character "\t" or two consecutive spaces"  "
	IndentTok
	// NewlineTok is a line break
	NewlineTok
	// TextTok is a token for arbitrary text
	TextTok
	// LiteralEnd marks the end of literal tokens in the token enumeration
	LiteralEnd

	// KeywordBegin marks the end of keyword tokens in the token enumeration
	KeywordBegin
	// CodeTok is the "code:" token
	CodeTok
	// DocumentTok is the "document:" token
	DocumentTok
	// ExamplesTok is the "examples:" token
	ExamplesTok
	// PathTok is the "path:" token
	PathTok
	// FunctionsTok is the "functions:" token
	FunctionsTok
	// ParamsTok is the "params:" token
	ParamsTok
	// ReturnTok is the "return:" token
	ReturnTok
	// TypesTok is the "types:" token
	TypesTok
	// FieldsTok is the "fields:" token
	FieldsTok
	// MethodsTok is the "methods:" token
	MethodsTok
	// OperatorsTok is the "operators:" token
	OperatorsTok
	// KeywordEnd marks the end of keyword tokens in the token enumeration
	KeywordEnd
)

func (TokenType) String

func (t TokenType) String() string

type Type

type Type struct {
	Name        string
	Description string
	Methods     Functions
	Fields      []*Field
	Operators   []*Operator
}

Type documents a constructed type

func (*Type) Sort

func (t *Type) Sort()

Sort sorts a Type pointer's Methods

type Types

type Types []*Type

Types is a sortable slice of Type pointers

func (Types) Len

func (t Types) Len() int

Len implements the sort.Sortable interface

func (Types) Less

func (t Types) Less(i, j int) bool

Less implements the sort.Sortable interface

func (Types) Swap

func (t Types) Swap(i, j int)

Swap implements the sort.Sortable interface

Jump to

Keyboard shortcuts

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