Documentation
¶
Overview ¶
Package summary generates human-readable Markdown summaries of dependency changes.
It transforms dependency diff data from the go-deps-diff library into organized, categorized Markdown output with visual indicators for package relationships and change types. The output includes collapsible sections, Unicode symbols for quick visual scanning, and semantic version tracking.
The GenerateForChanges function is the primary API. It accepts a DiffMap from go-deps-diff and produces a Markdown string ready for display, documentation, or file storage.
Example:
changes, err := difflib.Diff(oldPkgs, newPkgs)
if err != nil {
log.Fatal(err)
}
markdown := summary.GenerateForChanges(changes, "Composer")
fmt.Println(markdown)
Helper Functions:
- BuildVersionLabel: Formats versions with semantic version indicators - GetPackageSymbol: Returns symbols indicating package type/relationship - GetOperationSymbol: Returns symbols for change operations
Index ¶
Constants ¶
const ( AbandonedSymbol = "💀" NonSemverSymbol = "❗" )
const ( RootRequirementSymbol = "🗄️" RootDevRequirementSymbol = "🧰" TransitiveDependencySymbol = "🔗️" )
const ( SemverComponentUpgradeSymbol = "🔺" SemverComponentDowngradeSymbol = "🔻" SemverComponentSymbol = "🔹" UnknownOperationSymbol = "❓" SemverExtraUpdateOperationSymbol = SemverComponentSymbol + "." + SemverComponentSymbol + "." + SemverComponentSymbol + UnknownOperationSymbol RemovalOperationSymbol = "❌" AdditionOperationSymbol = "➕️" NonChangeOperationSymbol = "🟰" UnmanagedSymbol = "❔" )
Variables ¶
This section is empty.
Functions ¶
func BuildVersionLabel ¶
func BuildVersionLabel(version contract.PkgVersion) string
BuildVersionLabel formats a package version into a display label. If the version is not semantic, it appends a NonSemverSymbol (❗) indicator.
Parameters:
- version: The package version to format
Returns: A formatted string representation of the version, potentially with a symbol appended to indicate non-semantic versioning (e.g., git hashes, custom versions).
Example:
label := BuildVersionLabel(contract.PkgVersion{
Label: "1.2.3",
Semver: &contract.Semver{...},
})
fmt.Println(label) // Output: 1.2.3
func GenerateForChanges ¶
GenerateForChanges produces a Markdown-formatted summary of package dependency changes. It takes a DiffMap containing package changes and organizes them into categorized sections with appropriate symbols and formatting. The managerName parameter (e.g., "Composer" or "Npm") is used in the header to identify the package manager context.
Parameters:
- changes: A contract.DiffMap from go-deps-diff containing all package changes to summarize
- managerName: The name of the package manager (e.g., "Composer", "Npm") for header formatting
Returns: A Markdown-formatted string with sections for additions, removals, updates, and unchanged packages. Changes are visually distinguished using Unicode symbols and organized in collapsible detail sections.
Example:
changes, err := difflib.Diff(oldPkgs, newPkgs)
if err != nil {
log.Fatal(err)
}
markdown := GenerateForChanges(changes, "Composer")
fmt.Println(markdown)
func GetOperationSymbol ¶
GetOperationSymbol returns a Unicode symbol representing a package change operation. The symbol communicates the type of change: additions (➕), removals (❌), upgrades (🔺), downgrades (🔻), patch updates (🔹), or no change (🟰). For semver updates, nested symbols indicate which component changed (major/minor/patch).
Parameters:
- operation: The package operation/change to determine the symbol for
Returns: A Unicode emoji string (possibly in HTML sub/sup tags) representing the operation type.
Example:
symbol := GetOperationSymbol(contract.Operation{
Name: contract.UpgradeOperation,
SemverType: contract.SemverMajorUpdate,
})
fmt.Println(symbol) // Output: <sub><sup>🔺.🔹.🔹</sup></sub>
func GetPackageSymbol ¶
func GetPackageSymbol(pkg contract.PkgWrapper) string
GetPackageSymbol returns a Unicode symbol indicating the package type and relationship. The symbol communicates whether the package is a root requirement (🗄️), root dev requirement (🧰), or a transitive dependency (🔗️).
Parameters:
- pkg: The package to determine the symbol for
Returns: A Unicode emoji string representing the package type (🗄️, 🧰, or 🔗️).
Example:
symbol := GetPackageSymbol(pkg) fmt.Println(symbol) // Output: 🗄️ (for root requirement)
Types ¶
This section is empty.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package markdown provides a builder pattern for generating Markdown and HTML documents with structured formatting, indentation support, and collapsible sections.
|
Package markdown provides a builder pattern for generating Markdown and HTML documents with structured formatting, indentation support, and collapsible sections. |