config

package
v0.4.2 Latest Latest
Warning

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

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

Documentation

Overview

Package config reads the per-repo `.ipm.conf` file shared between cmd/md-embed, cmd/ipm-rpc, and any other infinite.pm Go toolchain entry point.

File format is a flat `key = value` INI dialect (no sections in v1). `#` starts a comment to end-of-line. Whitespace around the `=` and trailing spaces are ignored. Unknown keys are an error — they trip pre-commit / CI checks. To extend the schema, add a field to Config + a case in the parser; tests live next door.

Discovery walks upward from a starting directory looking for `.ipm.conf` or a `.git` marker; first match wins. This is the same shape as git-config's "repo root" discovery, so it composes cleanly with multi-root VS Code workspaces (one Config per workspace folder).

See the design rationale behind moving this out of pkg/mdembed.

Index

Constants

View Source
const FileName = ".ipm.conf"

FileName is the on-disk name of the per-repo config file.

Variables

This section is empty.

Functions

func FindRepoRoot

func FindRepoRoot(start string) string

FindRepoRoot walks upward from start, returning the first ancestor directory that contains either a `.git` entry or a .ipm.conf file. If neither is found before reaching the filesystem root, it returns start unchanged.

`.git` is recognized as either a directory (regular checkout) or a file (git worktree / submodule).

Types

type Config

type Config struct {
	SVGDir *string

	// EmbedIgnore is the list of glob patterns for `.md` files md-embed must
	// skip entirely — never scanned, rendered, or rewritten. Use it for docs
	// that contain illustrative or intentionally-invalid ipmt the tool would
	// otherwise try to process (e.g. the md-embed tutorial, an "invalid
	// examples" gallery).
	//
	// Set via one or more `embed-ignore = …` lines; each line is a comma- or
	// whitespace-separated list of patterns and the lines accumulate. Patterns
	// are matched against each file's path relative to the config's directory
	// (forward slashes). Beyond filepath.Match's *, ?, [], a ** spans any
	// number of path segments — so `docs/**/draft-*.md` matches at any depth
	// under docs/, while `docs/*.md` matches only direct children.
	EmbedIgnore []string
}

Config is the parsed contents of a .ipm.conf file. Only fields the file actually set are non-nil — that lets a caller distinguish "the file said `svg-dir = _ipm`" from "the file didn't mention svg-dir at all" when merging with CLI flag defaults.

func Load

func Load(rootDir string) (Config, bool, error)

Load reads `<rootDir>/.ipm.conf` if it exists and parses `key = value` lines (with `#` comments). Returns a zero Config and ok=false when no file is present. Returns an error only on read or parse problems.

func (Config) IsIgnored

func (c Config) IsIgnored(rel string) bool

IsIgnored reports whether rel — a path relative to the config's directory, either OS- or slash-separated — matches any EmbedIgnore pattern.

Jump to

Keyboard shortcuts

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