Documentation
¶
Overview ¶
Package pkgdirective reads forge's package-level comment directives — `//forge:exclude-contract: <why>`, `//forge:not-a-component: <why>` and their kin — from a package directory's source.
It imports only the standard library, deliberately. Contract mock generation consults `//forge:exclude-contract`, and forge's own mocks are regenerated by internal/tools/mockgen WITHOUT building forge (forge#1261): a stale mock_gen.go in a package the forge binary imports must never stop the tool that refreshes it from compiling. So this package may not grow an import of anything that carries generated contract code; internal/tools/mockgen's TestMockgenImportsNoContractCodegen holds that.
internal/codegen's directive API (FindExcludeContractMarker, FindNotAComponentMarker, …) is built on these primitives, so the generator and the bootstrap tool read a directive the same way.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForEachPackageComment ¶
ForEachPackageComment calls fn for every comment in dir's non-test, non-generated .go files, in file-name then position order. Unparseable files are skipped: a directive is read best-effort.
func ParseReasoned ¶
ParseReasoned is the whole-line rule for a directive that takes a reason after a colon: `//<directive>: <why>` yields "<why>", the bare `//<directive>` yields "", and anything else — prose that mentions the directive, a different separator — is not the directive.
func TrimCommentMarkers ¶
TrimCommentMarkers strips one comment's `//` or `/* */` syntax and the whitespace around its text.
Types ¶
type Marker ¶
type Marker struct {
// File is the absolute path of the file carrying the marker.
File string
// Line is the marker's 1-indexed line.
Line int
// Reason is the text after `forge:<directive>:`; "" for a bare marker.
Reason string
}
Marker is one occurrence of a package directive that takes a reason — `//forge:exclude-contract: <why>` or `//forge:not-a-component: <why>`.