docgen

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package docgen contains helpers for generated project documentation.

The package renders source-readable Markdown tables and normalizes existing GitHub-flavored Markdown pipe tables while preserving fenced code blocks, escaped pipe characters, inline code spans, Unicode cell widths, and original line endings. Command packages use these helpers when refreshing README and docs content so generated files stay stable in diffs and easy to review as plain text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeReplacedSection

func ComputeReplacedSection(text, startMark, endMark, content string) (string, error)

ComputeReplacedSection returns text with the content between startMark and endMark replaced by content. It returns an error when either marker is absent, so callers fail fast instead of writing a malformed file.

func FormatMarkdownTables

func FormatMarkdownTables(content string) (string, bool)

FormatMarkdownTables normalizes GitHub-flavored Markdown pipe tables in content. Tables inside fenced code blocks are left unchanged.

func RenderMarkdownTable

func RenderMarkdownTable(headers []string, alignments []Alignment, rows [][]string) string

RenderMarkdownTable returns a Markdown table padded to the widest cell in each column so the generated source remains readable as plain text.

func ReplaceSection

func ReplaceSection(path, startMark, endMark, content string) error

ReplaceSection rewrites the file at path, replacing the content between startMark and endMark (both preserved) with content. It is used by the generator commands that maintain managed README/doc sections.

Types

type Alignment

type Alignment int

Alignment controls how a Markdown table column is padded and marked.

const (
	// AlignLeft pads cells on the right and uses the default Markdown separator.
	AlignLeft Alignment = iota
	// AlignRight pads cells on the left and uses a right-aligned separator.
	AlignRight
	// AlignCenter pads cells on both sides and uses a centered separator.
	AlignCenter
)

Jump to

Keyboard shortcuts

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