Documentation
¶
Overview ¶
Package source fetches release notes for a tool's versions. Each changelog source kind is an Adapter; gh-release reads GitHub release bodies.
Index ¶
- Constants
- Variables
- func Boilerplate(body string) bool
- func Expand(tmpl string, s version.Scheme, v version.Version) string
- func ExpandPrev(tmpl string, s version.Scheme, v version.Version, prev version.V) string
- func FileURL(host string, k mdindex.Key) string
- func NewFileCache(gh FileFetcher) *mdindex.Cache
- func PickChangelog(files []github.File) (string, bool)
- type Adapter
- type Auto
- type ChangelogFile
- type FileFetcher
- type GHRelease
- type KindDoc
- type PageCache
- type Ref
- type ReleaseFetcher
- type RootLister
- type StructuredJSON
- type UpgradeGuide
- type UpgradeNotes
- type VersionNotes
- type Web
- type WebDoc
- type WebFetcher
Constants ¶
const ( KindGHRelease = "gh-release" KindChangelogFile = "changelog-file" KindStructuredJSON = "structured-json" KindWebDoc = "web-doc" KindUpgradeGuide = "upgrade-guide" KindUpgradeNotes = "upgrade-notes" )
Adapter kinds, as named in registry entries.
const ( HeadingUpgradeGuide = "Upgrade guide" HeadingUpgradeNotes = "Upgrade notes" )
Headings that upgrade documents are filed under. The classifier reads both as breaking.
Variables ¶
var ErrNotFound = errors.New("page not found")
ErrNotFound is wrapped by Web errors for pages that don't exist.
Functions ¶
func Boilerplate ¶
Boilerplate reports whether a release body carries no notes of its own: it is under 400 bytes, or it holds only headings, links and checksums.
func Expand ¶
Expand fills a path or ref template: {version}, {major}, {minor} (the minor number alone) and {tag}.
func ExpandPrev ¶
ExpandPrev is Expand with {prev_minor} (the line, such as 3.5) and {prev_major} taken from prev, the version before v.
func NewFileCache ¶
func NewFileCache(gh FileFetcher) *mdindex.Cache
NewFileCache returns an mdindex.Cache that reads files through gh. reStructuredText files get Markdown headings first.
Types ¶
type Adapter ¶
type Adapter interface {
Kind() string
Fetch(ctx context.Context, t registry.ToolSpec, versions []version.Version) ([]VersionNotes, error)
}
Adapter fetches notes for versions. Versions without notes are left out, not errors.
type Auto ¶
type Auto struct {
// contains filtered or unexported fields
}
Auto finds notes for a tool without registry sources, as Renovate and Dependabot do: GitHub release bodies when the range has real ones, else a changelog file in the default branch, unless the file stops before the newest release. Without a usable file it keeps whatever release bodies there are.
func NewAuto ¶
func NewAuto(logger *slog.Logger, gh ReleaseFetcher, lister RootLister, files *mdindex.Cache, newest version.V) *Auto
NewAuto returns an auto-discovery adapter; newest is the tool's newest stable version.
type ChangelogFile ¶
type ChangelogFile struct {
// contains filtered or unexported fields
}
ChangelogFile reads version sections from a changelog file in the tool's repository. Each file is fetched and parsed once through the shared cache.
func NewChangelogFile ¶
NewChangelogFile returns a changelog-file adapter for the registry source s.
type FileFetcher ¶
FileFetcher returns a file of a repository at a ref; github.Client implements it.
type GHRelease ¶
type GHRelease struct {
// contains filtered or unexported fields
}
GHRelease reads the GitHub release body of each version.
func NewGHRelease ¶
func NewGHRelease(gh ReleaseFetcher) *GHRelease
NewGHRelease returns a gh-release adapter that fetches through gh.
type PageCache ¶
type PageCache struct {
// contains filtered or unexported fields
}
PageCache fetches and parses each web page once. It is safe for concurrent use and lives as long as a digester.
func NewPageCache ¶
func NewPageCache(web WebFetcher) *PageCache
NewPageCache returns a cache that fetches pages with web.
type Ref ¶
type Ref struct {
Adapter string `json:"adapter"`
URL string `json:"url"`
Heading []string `json:"heading,omitempty"` // heading path inside the document
}
Ref says where a piece of notes came from.
type ReleaseFetcher ¶
type ReleaseFetcher interface {
ReleaseBodies(ctx context.Context, repo string, tags []string) (map[string]github.Release, error)
}
ReleaseFetcher returns releases by tag; github.Client implements it.
type RootLister ¶
RootLister lists a repository's top directory; github.Client implements it.
type StructuredJSON ¶
type StructuredJSON struct {
// contains filtered or unexported fields
}
StructuredJSON reads one JSON document per version, from a repository file or an allowed URL, and turns its entries into a Markdown list grouped by a heading field.
func NewStructuredJSON ¶
func NewStructuredJSON(logger *slog.Logger, files FileFetcher, web WebFetcher, s registry.Source) *StructuredJSON
NewStructuredJSON returns a structured-json adapter for the registry source s.
func (*StructuredJSON) Fetch ¶
func (a *StructuredJSON) Fetch( ctx context.Context, t registry.ToolSpec, versions []version.Version, ) ([]VersionNotes, error)
Fetch returns the entries of each version, in the order given. A missing document or one without entries is left out.
func (*StructuredJSON) Kind ¶
func (a *StructuredJSON) Kind() string
Kind returns KindStructuredJSON.
type UpgradeGuide ¶
type UpgradeGuide struct {
// contains filtered or unexported fields
}
UpgradeGuide attaches a whole upgrade document to the first version of each new release line in a range. A template with {minor} or {prev_minor} names one document per minor transition, otherwise one per major.
func NewUpgradeGuide ¶
func NewUpgradeGuide( logger *slog.Logger, files *mdindex.Cache, pages *PageCache, s registry.Source, from version.V, ) *UpgradeGuide
NewUpgradeGuide returns an upgrade-guide adapter for the registry source s. from is the version before the range; it names the line the first transition starts from.
type UpgradeNotes ¶
type UpgradeNotes struct {
// contains filtered or unexported fields
}
UpgradeNotes takes the section under a heading such as "Urgent Upgrade Notes" out of each version's changelog section, so those entries carry their own source and are classified as upgrade notes. It reads the file of the tool's changelog-file source.
func NewUpgradeNotes ¶
func NewUpgradeNotes( logger *slog.Logger, cache *mdindex.Cache, s registry.Source, file *registry.Source, ) *UpgradeNotes
NewUpgradeNotes returns an upgrade-notes adapter for the registry source s that reads the changelog file source file names; nil means the tool has none.
type VersionNotes ¶
type VersionNotes struct {
Version version.Version
Markdown string
Line int // 1-based line where Markdown starts in a file; 0 for release bodies
Source Ref
}
VersionNotes is the Markdown one source has for one version.
type Web ¶
type Web struct {
// contains filtered or unexported fields
}
Web fetches pages from the hosts registry.WebHosts allows, redirects included.
type WebDoc ¶
type WebDoc struct {
// contains filtered or unexported fields
}
WebDoc reads release notes from allowed web pages. With an anchor, each version gets the element with its id. Without one, a page holds a whole release line, such as one minor, and goes to the first version of the range whose URL is that page.
func NewWebDoc ¶
NewWebDoc returns a web-doc adapter for the registry source s. from is the version before the range, whose page the range doesn't repeat.