util

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package util provides general filesystem, git, markdown, and execution helpers for magefiles.

Index

Constants

View Source
const GeneratedBanner = "<!-- Page generated by Cargoship; DO NOT EDIT -->"

GeneratedBanner marks a page as generator output.

Variables

This section is empty.

Functions

func CheckRepoMarkdownTables added in v0.38.0

func CheckRepoMarkdownTables() error

CheckRepoMarkdownTables checks every tracked Markdown file outside vendor/ and reports each misaligned table line on stdout, returning an error when any were found.

func CleanBuild

func CleanBuild() error

CleanBuild removes compiled binary artifacts under build/.

func EscapeAngleBrackets

func EscapeAngleBrackets(s string) string

EscapeAngleBrackets replaces literal "<" and ">" with HTML entities.

func GitCommit

func GitCommit() string

GitCommit returns the short commit of the checkout being built, suffixed with "-dirty" when the working tree has uncommitted changes. When the commit cannot be resolved, it returns config.UnsetCLICommit.

func PaddedTable

func PaddedTable(header []string, rows [][]string) []string

PaddedTable renders a table in the aligned form required by repo style guides.

func RenderYAMLValue

func RenderYAMLValue(value any) string

RenderYAMLValue renders a default value the way it is written in YAML.

Types

type TableFinding added in v0.38.0

type TableFinding struct {
	File string
	Line int // 1-indexed
	Got  string
	Want string
}

TableFinding is one line of a Markdown table that is not padded to its column widths.

func CheckMarkdownTables added in v0.38.0

func CheckMarkdownTables(files []string) ([]TableFinding, error)

CheckMarkdownTables reports every table line in the given files that is not padded the way the repository style guide requires: one space inside each pipe, every cell padded to the width of the widest cell in its column, and the delimiter row's dashes run out to that same width. Tables inside fenced code blocks are skipped, since the style guide and several AGENTS.md files show deliberately unpadded tables as examples.

Jump to

Keyboard shortcuts

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