cmt

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cmt provides functions that parse and render GIR comments into nice and conventional Go comments.

Index

Constants

View Source
const (
	CommentsColumnLimit = 80 - 3 // account for prefix "// "
	CommentsTabWidth    = 4
)

Variables

This section is empty.

Functions

func EnsureInfoFields

func EnsureInfoFields(v interface{}) struct{}

EnsureInfoFields ensures that the given type contains all fields inside InfoFields.

func GoDoc

func GoDoc(v interface{}, indentLvl int, opts ...Option) string

GoDoc renders a Go documentation string from the given struct. The struct should contain at least the field Name, InfoAttrs and InfoElements.

func ReflowLinesIndent

func ReflowLinesIndent(indentLvl int, cmt string, opts ...Option) string

ReflowLinesIndent reflows the given cmt paragraphs into idiomatic Go comment strings. It is automatically indented.

func Synopsis

func Synopsis(v interface{}, indentLvl int, opts ...Option) string

Synopsis renders the synopsis of the documentation.

Types

type InfoFields

type InfoFields struct {
	Name       *string
	Attrs      *gir.InfoAttrs
	Elements   *gir.InfoElements
	ParamDocs  []ParamDoc
	ReturnDocs []ParamDoc
}

InfoFields contains common fields that a GIR schema type may contain. These fields should rarely be used, because they're too magical. All fields inside InfoFields are optional.

func GetInfoFields

func GetInfoFields(v interface{}) InfoFields

GetInfoFields gets the InfoFields from the given value.

type Option

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

Option defines possible options for GoDoc.

func AdditionalPrefix added in v0.0.2

func AdditionalPrefix(pfx string) Option

AdditionalPrefix adds the given prefix string into the head of the comment.

func AdditionalString

func AdditionalString(str string) Option

AdditionalString adds the given string into the tail of the comment as another paragraph.

func OverrideSelfName

func OverrideSelfName(self string) Option

OverrideSelfName overrides the Go type name that's implicitly converted automatically by GoDoc.

func ParagraphIndent added in v0.0.2

func ParagraphIndent(indent int) Option

ParagraphIndent indents the inner comment paragraphs.

func TrailingNewLine

func TrailingNewLine() Option

TrailingNewLine adds a trailing new line during documentation generation.

type ParamDoc added in v0.0.3

type ParamDoc struct {
	Name         string
	Optional     bool
	InfoElements gir.InfoElements
}

ParamDoc is the documentation for one parameter. It is added by callable generators for GoDoc to generate the rest.

Jump to

Keyboard shortcuts

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