site

package
v0.0.19 Latest Latest
Warning

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

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

Documentation

Overview

Package site renders the content tree to a static site (spec 14).

Build writes plain files: HTML pages, the machine copies (.md, .json), the search index, the scene bundles and the assets. A static host serves them. The site works with no script: the script adds the search palette, the code tabs, the theme switch and the player.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Badge

type Badge struct {
	Text string
	Tick bool
	Href string
	Hint string
}

Badge is one evidence badge (spec 13.1).

type Base

type Base struct {
	Title    string
	Desc     string
	Path     string // the canonical path, for example /merge-sort/
	Hue      int
	Section  string // the top bar item that is current
	Crumbs   []Link
	NoIndex  bool
	Scripts  []string
	Wide     bool
	BodyKind string
	Meta     *Meta
	JSONLD   template.JS
}

Base is the frame of a page.

type Card

type Card struct {
	Solves     []Link
	Techniques []Link
	Implements []Link
	Time       []Claim
	Space      []Claim
	Other      []Claim
	Model      *Link
	Vars       []string
	Props      []Prop
	Evidence   []Badge
	Origin     string
}

Card is the summary card of an algorithm, a data structure or a problem (spec 14.7.4).

type CardView added in v0.0.2

type CardView struct {
	Anchor  string
	Heading string
	Local   string
	Summary string
	Kind    string
	Code    string // the signature of an api entry, shown as code
	Facts   []Fact
	Links   []Link
	Sources []Link
	Record  string // the URL of the JSON record
	Help    string // the URL of the page that tells how to write the full page
}

CardView is one card on a collection page.

type Claim

type Claim struct {
	Bound string
	Cases string
	Group string
}

Claim is one bound with the cases that share it.

type CompatCell added in v0.0.2

type CompatCell struct {
	Lines []CompatLine
}

CompatCell is the support of one implementation. A cell has one line for each statement.

type CompatLine added in v0.0.2

type CompatLine struct {
	Text string
	// Class is yes, no, preview or partial.
	Class string
	// Verified tells if a current probe result proves the statement.
	Verified bool
	Detail   string
	// Notes are the numbers of the notes of the statement.
	Notes []int
}

CompatLine is one statement.

type CompatRow added in v0.0.2

type CompatRow struct {
	Key         string
	Description string
	Cells       []CompatCell
}

CompatRow is one compat entry.

type CompatView added in v0.0.2

type CompatView struct {
	Columns []compat.Impl
	Rows    []CompatRow
	Notes   []string
	// Verified and Documented count the cells that a probe proves and the cells that come from a source only.
	Verified, Documented int
}

CompatView is the compat table of a feature page (spec 09.2 and 16.4).

type Counts

type Counts struct {
	Nodes, Concepts, Languages, Features, Tasks, Examples, Impls, Langs, Proofs, Scenes, Areas int
}

Counts are the numbers of the home page.

type DeclView

type DeclView struct {
	Role   string
	Name   string
	Short  string // the name without the module namespace
	Kind   string
	Type   string
	Doc    string
	Axioms []string
	Std    bool
	Line   int
	Source string // the lines on GitHub
	Proof  *Link  // the human proof of the same claim, from the lean field of the proof
}

DeclView is one declaration of a Lean module.

type DocPage

type DocPage struct {
	Base
	Heading string
	Lead    string
	Body    template.HTML
	TOC     []markup.Heading
	Source  string
}

DocPage is a page of prose.

type ExampleView

type ExampleView struct {
	Lang     string
	Name     string
	ID       string // the id of the panel, code-<lang>, or example-<lang> when an implementation uses code-<lang>
	HTML     template.HTML
	GitHub   string
	Selected bool
	// contains filtered or unexported fields
}

ExampleView is the example file of one language, shown as a tab (spec 04.4 and 07.2).

type Fact

type Fact struct {
	Key, Value string
	Code       bool
}

Fact is one row of a fact table.

type FactRow

type FactRow struct {
	Key   string
	Text  string
	Code  bool
	URL   string
	Links []Link
}

FactRow is one row of the facts box of a node page (spec 14.7.4). A row has text, links or both.

type FileView

type FileView struct {
	Name  string
	Lines int
	HTML  template.HTML
}

FileView is one more file of an implementation.

type Group

type Group struct {
	ID    string
	Title string
	Intro string
	Items []Item
}

Group is one titled part of a list page.

type HomePage

type HomePage struct {
	Base
	Tiles  []Tile
	Start  []Item
	Scenes []Tile
	Langs  []Tile
}

HomePage is the data of the home page.

type ImplView

type ImplView struct {
	Lang     string
	Name     string
	Tier     int
	File     string
	Lines    int
	HTML     template.HTML
	Tests    []FileView
	Rung     status.Rung
	Test     *status.Test
	Raw      string
	GitHub   string
	Markers  template.JS
	Selected bool
}

ImplView is one language tab.

type Item

type Item struct {
	Link
	Summary string
	Level   string
	Meta    string
	Chips   []string
}

Item is one row of a list.

type LeanView

type LeanView struct {
	Module string
	File   string // the path in the content repository, such as lean/Algo/Sorting/MergeSort.lean
	GitHub string
	URL    string // the Lean page, /<slug>/lean/
	Lines  int
	HTML   template.HTML
	Rung   status.Rung
	// Built is false when the build has no decls.jsonl. Then the page shows the source only.
	Built bool
	// Std is true when each declaration of the module uses only the standard axioms.
	Std bool
	// Key holds the declarations that the lean field names, and the class lemmas, in the order of the ladder.
	Key []DeclView
	// All holds each declaration of the module, in the order of the source.
	All []DeclView
}

LeanView is the Lean part of a node: its module, its declarations and the source (spec 07.16, 14.7).

type Link struct {
	Name    string
	URL     string
	Kind    string
	Missing bool
	Note    string
	Hue     int
}

Link is a link with a name.

type ListPage

type ListPage struct {
	Base
	Heading string
	Lead    string
	// Intro is the README of a top area, shown above its sub-areas.
	Intro  template.HTML
	Facts  []Fact
	Tiles  []Tile
	Groups []Group
	Empty  string
	Body   template.HTML
	// Cards are the cards of a collection page, and Pager links the pages of a long collection.
	Cards []CardView
	Pager []Link
}

ListPage is the data of an index page.

type MatrixCell

type MatrixCell struct {
	Level int
	Label string
	Title string
	URL   string
	Has   bool
	// Verdict is the status of a cell that has no code, such as absent or library (spec 04.8).
	Verdict string
}

MatrixCell is one language of a node.

type MatrixPage

type MatrixPage struct {
	Base
	Langs []node.Lang
	Rows  []MatrixRow
}

MatrixPage is the table of every node by every language.

type MatrixRow

type MatrixRow struct {
	Link
	H, L, V, W status.Rung
	Cells      []MatrixCell
}

MatrixRow is one node of the matrix.

type Meta

type Meta struct {
	BaseURL  string
	Version  string
	Commit   string
	Short    string
	Date     string
	Repo     string
	AgentURL string
	Counts   Counts
	Year     int
}

Meta is the data that every page shares.

type NodePage

type NodePage struct {
	Base
	N        *node.Node
	KindName string
	Body     template.HTML
	TOC      []markup.Heading
	Status   status.Status
	Rungs    []RungView
	Card     *Card
	Prereqs  []Link
	Leads    []Link
	Related  []Link
	Solvers  []SolverRow
	Impls    []ImplView
	Examples []ExampleView
	Compat   *CompatView
	Facts    []FactRow
	Guide    []Tile
	Glance   []FactRow
	Verdicts []VerdictRow
	Owned    []Link
	Proofs   []ProofView
	Lean     *LeanView
	Player   *PlayerView
	Sources  []SourceView
	Edit     string
	Copies   bool // the page has the Markdown and JSON copies; a stub has none
	History  string
	Report   string
	Tests    string // the summary line of the native tests
}

NodePage is the data of a node page.

type Options

type Options struct {
	Out      string // the output directory; Build empties it first
	BaseURL  string // for example https://programming.tamnd.com
	Results  string // the directory of the test results, build/results
	Decls    string // the declarations of the Lean package, build/lean/decls.jsonl
	SpecDir  string // a directory of the specification to publish at /spec/, or "" for the copy in the binary
	Version  string // the version of prog
	Commit   string // the commit of the content
	Repo     string // for example https://github.com/tamnd/algorithm
	AgentURL string // for example https://github.com/tamnd/programming-agent
	Minify   bool
	// Now is the build time. A zero time means time.Now.
	Now time.Time
	// Log gets one line for each problem that does not stop the build.
	Log func(format string, args ...any)
}

Options control a build.

type PlayerView

type PlayerView struct {
	Slug    string
	Script  string
	Presets template.JS
	Input   template.JS
	Pseudo  template.HTML
	Full    string
}

PlayerView is the data of the player.

type ProofView

type ProofView struct {
	ID     string
	Title  string
	Status string
	Proves []string
	HTML   template.HTML
}

ProofView is one human proof.

type Prop

type Prop struct {
	Text string
	On   bool
}

Prop is a property chip.

type Report

type Report struct {
	Pages      int
	Files      int
	Bytes      int64
	MathErrors []string
	Scenes     map[string]viz.Report
}

Report is what a build made.

func Build

func Build(c *node.Corpus, opt Options) (*Report, error)

Build renders the corpus into opt.Out. It writes a new tree next to opt.Out and then puts it in place, so a server that reads opt.Out never sees a half-written site.

type RungView

type RungView struct {
	Ladder string
	Lang   string
	status.Rung
}

RungView is one row of the ladder table of "About this page".

type SolverRow

type SolverRow struct {
	Link
	Time  string
	Space string
	Props []Prop
	Langs int
}

SolverRow is one row of the "Known algorithms" table of a problem.

type SourceView

type SourceView struct {
	Text    string
	URL     string
	Locator string
	Note    string
}

SourceView is one entry of Further reading.

type Tile

type Tile struct {
	Name    string
	URL     string
	Summary string
	Hue     int
	Count   int
	Unit    string
	Missing bool
	Extra   string
}

Tile is one tile of a grid.

type VerdictRow added in v0.0.2

type VerdictRow struct {
	Lang    string
	Name    string
	Verdict string
	// URL goes to the example tab or the feature page of the language.
	URL  string
	Note string
	Tier int
}

VerdictRow is one language of the verdict table of a concept page (spec 04.8 and 16.4).

Jump to

Keyboard shortcuts

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