Help us shape the future of Go! Take the 2026 Go Developer Survey

catalogsite

package
v5.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package catalogsite renders a version 2 catalog (govview.CatalogDocV2) as a static, self-contained, deterministic website that opens from file:// and makes no network request.

Every string that comes from the repository (ids, descriptions, owners, lint messages, excerpts) reaches the page through html/template's contextual escaping; the package never builds template.HTML, template.JS or template.URL values (a test enforces that). Links are relative and built from slugged keys, never from source text.

Index

Constants

View Source
const DefaultPageSize = 200

DefaultPageSize is the overview page size when Options.PageSize is not set.

View Source
const DefaultTitle = "AI-Rulez catalog"

DefaultTitle is the site title when none is given.

View Source
const MarkerFile = ".ai-rulez-catalog"

MarkerFile marks a directory as one this command may write into and clean.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	// Missing are files the site has that the directory lacks (the marker
	// included when it is absent).
	Missing []string
	// Changed are files whose bytes differ, or that are not regular files.
	Changed []string
	// Extra are files in the directory that the site does not have.
	Extra []string
}

CheckResult says how a directory differs from the site Render would write.

func Check

func Check(dir string, site *Site) (*CheckResult, error)

Check compares dir with site without writing anything: every file of the site must exist with the same bytes, and the directory must hold nothing else (besides the marker). A missing directory is drift, not an error, so a CI gate fails for a site that was never generated. Reading goes through an os.Root, so a symlink inside dir cannot lead the comparison outside it; a symlink is reported as changed (or extra), never followed.

func (*CheckResult) Drift

func (r *CheckResult) Drift() bool

Drift reports whether the directory differs from the site.

type Options

type Options struct {
	// Title is the site title; DefaultTitle when empty.
	Title string
	// Indexable lets search engines crawl the site (robots.txt and the noindex
	// meta are left out).
	Indexable bool
	// PageSize is how many overview rows one page shows before the rest moves to
	// the next page; DefaultPageSize when not positive.
	PageSize int
	// Markdown renders item excerpts as sanitized Markdown (see renderMarkdown)
	// instead of plain text.
	Markdown bool
}

Options tunes Render.

type Site

type Site struct {
	Files  map[string][]byte
	Digest string
}

Site is a rendered site: every file by slash path, and the digest of its catalog.json.

func Render

func Render(doc *govview.CatalogDocV2, opts Options) (*Site, error)

Render renders doc as a static site. The result depends on doc and opts only.

func (*Site) Paths

func (s *Site) Paths() []string

Paths returns the file paths in sorted order.

type WriteResult

type WriteResult struct {
	Written int
	Removed []string
}

WriteResult says what Write did.

func Write

func Write(log logger.Logger, dir string, site *Site, clean bool) (*WriteResult, error)

Write writes site into dir. The directory must be new, empty or marked with MarkerFile; anything else is refused so `--html .` can never overwrite a project, and a directory holding a .git or .ai-rulez folder (a project root) is refused outright. With clean, files a previous run wrote (listed in the marker with their digest) that the new site no longer has are removed; nothing else is ever removed: a listed path must have the shape of a site file and still hold the bytes this command wrote, so a hand-edited marker cannot point it at a project file.

The marker is written before the files, listing both the new and the previously listed paths, so an interrupted run never leaves unmarked files behind, and rewritten with the final set afterwards.

All access goes through an os.Root, so a symlink inside dir cannot lead a write or a removal outside it.

Jump to

Keyboard shortcuts

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