model

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertionPackage

type AssertionPackage struct {
	Tool             string
	Header           string
	Package          string
	DocString        string
	Copyright        string
	Receiver         string
	TestDataPath     string
	Imports          ImportMap
	EnableFormat     bool
	EnableForward    bool
	EnableGenerics   bool
	EnableExamples   bool
	RunnableExamples bool

	Functions []Function
	Types     []Ident
	Consts    []Ident
	Vars      []Ident

	// extraneous information when scanning in collectDoc mode
	ExtraComments []ExtraComment
}

AssertionPackage describes the internal/assertions package.

func New

func New() *AssertionPackage

New empty AssertionPackage.

func (*AssertionPackage) Clone

func (a *AssertionPackage) Clone() *AssertionPackage

func (*AssertionPackage) HasHelpers

func (a *AssertionPackage) HasHelpers() (ok bool)

type CommentTag

type CommentTag uint8
const (
	CommentTagNone CommentTag = iota
	CommentTagDomain
	CommentTagMaintainer
	CommentTagMention
	CommentTagNote
	CommentTagDomainDescription
)

type Document

type Document struct {
	Title         string
	Domain        string
	Description   string
	Path          string // document folder, relative to its parent if any
	File          string // document name, e.g. _index.md, string.md
	GitHubURL     string
	PkgGoDevURL   string
	Kind          KindDoc           // page or index or folder
	Documents     []Document        // for folders, their content [Document]
	Index         []IndexEntry      // for indexes, their entry list
	Package       *AssertionPackage // subset of the package that pertains to this document
	ExtraPackages ExtraPackages
	RefCount      int
	Weight        int
}

func (Document) HasGenerics added in v2.2.0

func (d Document) HasGenerics() bool

type Documentation

type Documentation struct {
	Package   *AssertionPackage // the complete source package being documented
	Documents []Document        // Documents is a collection of markdown pages or folders
}

func NewDocumentation

func NewDocumentation() *Documentation

NewDocumentation builds an empty Documentation.

func (*Documentation) Merge

func (d *Documentation) Merge(doc Documentation)

type ExtraComment

type ExtraComment struct {
	Tag  CommentTag
	Key  string
	Text string
}

type ExtraPackages

type ExtraPackages []*AssertionPackage

func (ExtraPackages) LookupFunction

func (pkgs ExtraPackages) LookupFunction(name string) []FunctionWithContext

type Function

type Function struct {
	ID            string
	Name          string
	SourcePackage string
	TargetPackage string
	DocString     string
	UseMock       string
	Params        Parameters
	AllParams     Parameters
	Returns       Parameters
	TypeParams    []TypeParam
	IsGeneric     bool
	IsHelper      bool
	IsDeprecated  bool
	IsConstructor bool
	Tests         []Test
	// extraneous information when scanning in collectDoc mode
	Domain        string
	SourceLink    *token.Position
	ExtraComments []ExtraComment
}

Function represents an assertion function extracted from the source package.

func (Function) GenericCallName added in v2.2.0

func (f Function) GenericCallName(suffixes ...string) string

GenericCallName renders the function name with explicit type parameters. This is used when forwarding type parameters, as all type parameters may not be always infered from the arguments.

func (Function) GenericName added in v2.2.0

func (f Function) GenericName(suffixes ...string) string

GenericName renders the function name with one or more suffixes, accounting for any type parameter for generic functions.

func (Function) HasSuccessTest

func (f Function) HasSuccessTest() bool

func (Function) HasTest

func (f Function) HasTest() bool

type FunctionWithContext

type FunctionWithContext struct {
	Function

	Package        string
	Receiver       string
	EnableFormat   bool
	EnableForward  bool
	EnableGenerics bool
	EnableExamples bool
}

type Ident

type Ident struct {
	ID            string
	Name          string
	SourcePackage string
	TargetPackage string
	DocString     string
	IsAlias       bool
	IsDeprecated  bool
	Function      *Function // for function types (or vars)

	// extraneous information when scanning in collectDoc mode
	Domain        string
	SourceLink    *token.Position
	ExtraComments []ExtraComment
}

Ident represents an exported identifier (type, constant, or variable) from the source package.

type ImportMap

type ImportMap map[string]string

ImportMap represents the imports for the analyzed package.

func (ImportMap) HasImports

func (m ImportMap) HasImports() bool

type IndexEntry

type IndexEntry struct {
	Name        string
	Title       string
	Description string
	Link        string
	RefCount    int
	Weight      int
}

type KindDoc

type KindDoc uint8
const (
	KindPage KindDoc = iota
	KindIndex
	KindFolder
)

type Parameter

type Parameter struct {
	Name       string
	GoType     string
	Selector   string
	IsVariadic bool
	IsGeneric  bool
}

Parameter represents a function parameter or return value.

type Parameters

type Parameters []Parameter

type Test

type Test struct {
	TestedValue      string              // DEPRECATED: Original raw string, kept for backward compatibility
	TestedValues     []TestValue         // Parsed test value expressions
	ExpectedOutcome  TestExpectedOutcome // Expected test outcome (success/failure/panic)
	AssertionMessage string              // Optional assertion message for panic tests
}

Test captures test values to use with generated tests.

Test values are parsed as Go expressions and stored with their AST representation.

type TestExpectedOutcome

type TestExpectedOutcome uint8
const (
	TestNone TestExpectedOutcome = iota
	TestSuccess
	TestFailure
	TestPanic
)

type TestValue

type TestValue struct {
	Raw   string   // Original string from doc comment
	Expr  ast.Expr // Parsed Go expression (nil if parse failed)
	Error error    // Parse error if any
}

TestValue represents a single parsed test value expression.

It stores both the original string (for debugging/audit) and the parsed AST.

type TypeParam added in v2.2.0

type TypeParam struct {
	Name       string // type parameter name (e.g., "B")
	Constraint string // constraint type (e.g., "Boolean", "cmp.Ordered")
}

TypeParam represents a type parameter in a generic function.

Jump to

Keyboard shortcuts

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