Documentation
¶
Index ¶
- Constants
- func CheckExternalLinks(graph *LinkGraph, cfg ExternalCheckConfig) error
- type AnchorLookup
- type CoverageSummary
- type DimKey
- type ExternalCheckConfig
- type ExternalResult
- type Finding
- type FindingType
- type LaneSummary
- type LinkCheckConfig
- type LinkGraph
- type LinkKind
- type LinkRef
- type LinkStatus
- type PendingAnchorCheck
- type ReportInput
- type ReportResult
Constants ¶
const AmbiguousHint = "write ./name.md for a sibling page or a content-root path like docs/name.md"
AmbiguousHint is the fix advice attached to ambiguous_link findings: a bare `name.md` is never resolved (see linkrender.ClassifyDest); the author must say whether it is relative to the page or to the content root.
Variables ¶
This section is empty.
Functions ¶
func CheckExternalLinks ¶
func CheckExternalLinks(graph *LinkGraph, cfg ExternalCheckConfig) error
CheckExternalLinks probes external URLs recorded in the graph, updating broken ones to StatusExternalBroken. Results are cached to disk.
Types ¶
type AnchorLookup ¶
AnchorLookup is the interface ValidateAnchors needs from PageIndex. Satisfied by *content.PageIndex without importing the content package.
type CoverageSummary ¶
type CoverageSummary struct {
Lanes []LaneSummary
TotalLanes int
TotalPages int
TotalLinks int
TotalBroken int
MissedLanes []DimKey // expected lanes with no links checked
}
CoverageSummary reports which lanes were checked and aggregate stats.
func ComputeCoverage ¶
func ComputeCoverage(graph *LinkGraph, pages []*engine.Page, expectedLanes []DimKey) CoverageSummary
ComputeCoverage analyzes the link graph and the set of rendered pages to produce a coverage summary. expectedLanes is the full set of lanes that should produce output (from EnumerateLanes); the graph provides what was actually checked.
type DimKey ¶
DimKey identifies the content dimension a link was resolved in.
func EnumerateLanes ¶
func EnumerateLanes(collections map[string]*engine.Collection, languages []string) []DimKey
EnumerateLanes computes the full set of expected lanes from collections and language configuration. Each collection × language × version combination that produces output is one lane.
type ExternalCheckConfig ¶
type ExternalCheckConfig struct {
Enabled bool
Concurrency int
Timeout time.Duration
CachePath string // absolute path to linkcache.json
CacheTTL time.Duration
OnBroken string // "warn" | "error" | "ignore"
Ignore []string // URL glob patterns to skip
Method string // "head-then-get" | "head" | "get"
}
ExternalCheckConfig holds the resolved configuration for external link checking.
type ExternalResult ¶
type ExternalResult struct {
URL string `json:"url"`
StatusCode int `json:"status_code"`
OK bool `json:"ok"`
Checked time.Time `json:"checked"`
Error string `json:"error,omitempty"`
}
ExternalResult is the probed outcome for a single URL.
type Finding ¶
type Finding struct {
Type FindingType
Ref LinkRef
Policy string // "error" | "warn"
}
Finding is a single reportable issue derived from a LinkRef.
type FindingType ¶
type FindingType int
FindingType classifies what kind of issue a report finding represents.
const ( FindingBrokenTarget FindingType = iota FindingBrokenAnchor FindingRelativeLink FindingLocalLink FindingSameSite FindingExternalBroken FindingUnverifiedInternal FindingAmbiguousLink )
func (FindingType) Hint ¶ added in v1.4.0
func (ft FindingType) Hint() string
Hint returns fix advice for finding types that have one, else "".
func (FindingType) Label ¶
func (ft FindingType) Label() string
func (FindingType) String ¶
func (ft FindingType) String() string
type LaneSummary ¶
type LaneSummary struct {
Dim DimKey
Pages int
Links int
Broken int
External int
IsFallback bool // true if this lane only contains fallback pages
}
LaneSummary holds link-checking stats for a single rendered lane.
type LinkCheckConfig ¶
type LinkCheckConfig struct {
OnBroken string
OnBrokenAnchor string
OnRelativeLinks string
OnLocalLinks string
SameSitePolicy string
ReportFormat string
Exclude []string
OnExternalBroken string
OnUnverifiedInternal string
}
LinkCheckConfig holds resolved policy values for report generation. Avoids importing internal/config in this package.
type LinkGraph ¶
type LinkGraph struct {
// contains filtered or unexported fields
}
LinkGraph records every link resolution attempt during a build for queryable post-build validation. Safe for concurrent use.
func (*LinkGraph) BrokenRefs ¶
BrokenRefs returns only the refs with BrokenTarget or BrokenAnchor status.
func (*LinkGraph) ExternalRefs ¶
ExternalRefs returns only the refs with External status.
func (*LinkGraph) MarkExternalBroken ¶
MarkExternalBroken transitions all refs whose RawDest equals url from StatusExternal to StatusExternalBroken.
func (*LinkGraph) UnverifiedRefs ¶
UnverifiedRefs returns only the refs with Unverified status.
type LinkRef ¶
type LinkRef struct {
FromPage *engine.Page
FromFile string
Line, Col int
RawDest string
Dim DimKey
Kind LinkKind
Resolved string
TargetPage *engine.Page
Fragment string
Status LinkStatus
}
LinkRef records a single link resolution attempt.
type LinkStatus ¶
type LinkStatus int
LinkStatus classifies the outcome of a link resolution attempt.
const ( StatusOK LinkStatus = iota // resolved successfully StatusBrokenTarget // target page not found in index StatusBrokenAnchor // target page found but heading ID missing StatusExternal // external URL, unchecked by internal resolver StatusExternalBroken // external URL probed and returned non-2xx/3xx StatusUnverified // internal page-like link that didn't resolve in-lane (cross-lane or typo) StatusAmbiguous // bare `name.md` (no ./ or content-root prefix): never resolved by design )
type PendingAnchorCheck ¶
type PendingAnchorCheck struct {
SourceFile string
TargetPermalink string
Fragment string
RawHref string
FromPage *engine.Page
TargetPage *engine.Page
Dim DimKey
Kind LinkKind
Resolved string
// Line/Col of the link in SourceFile (1-based); 0 when unknown.
Line, Col int
}
PendingAnchorCheck records a deferred anchor validation. It carries the full LinkRef fields needed to write a definitive graph entry after all page headings are populated.
func ValidateAnchors ¶
func ValidateAnchors( graph *LinkGraph, pending []PendingAnchorCheck, index AnchorLookup, ) []PendingAnchorCheck
ValidateAnchors records a definitive LinkRef for each pending anchor check after all page headings are populated. It writes StatusOK or StatusBrokenAnchor into graph and returns the failed checks for the builder's warning machinery.
type ReportInput ¶
type ReportInput struct {
Graph *LinkGraph
Coverage CoverageSummary
Config LinkCheckConfig
SiteURL string
}
ReportInput bundles everything GenerateReport needs.
type ReportResult ¶
ReportResult is what GenerateReport returns to the builder.
func GenerateReport ¶
func GenerateReport(in ReportInput) ReportResult
GenerateReport applies policy filters over the link graph and returns a formatted report. The caller (builder.go) uses HasErrors to decide whether to return a build error.