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

document

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package document is the editable document deliverable: letters, invoices, minutes, programs, binders, contracts and any other document a buyer fills in Word, Google Docs, Pages or LibreOffice, and slide decks with speaker notes for PowerPoint, Keynote and Google Slides. One Markdown file per document and language and a theme from the concept compile to .docx files whose look lives in real styles, per language and paper size; a release prints them in Chrome as Word lays them out and checks what every app will show.

Index

Constants

View Source
const (
	Dir         = "deliverables/document"
	ConceptFile = Dir + "/concept.md"
	FontsDir    = Dir + "/fonts"
	ImagesDir   = Dir + "/images"
	ListingFile = Dir + "/listing.md"
)

The layout under deliverables/document.

View Source
const (
	RuleConfig   = "document.config"
	RuleConcept  = "document.concept"
	RuleFonts    = "document.fonts"
	RuleSource   = "document.source"
	RuleDesign   = "document.design"
	RuleContent  = "document.content"
	RuleLayout   = "document.layout"
	RuleDelivery = "document.delivery"
	RuleListing  = "document.listing"
	RuleChannels = "document.channels"
)

Rule IDs.

View Source
const (
	Para      = markup.Para
	Heading   = markup.Heading
	Title     = markup.Title
	Subtitle  = markup.Subtitle
	List      = markup.List
	TableKind = markup.TableKind
	ImageKind = markup.ImageKind
	PageBreak = markup.PageBreak
	Ornament  = markup.Ornament
	Box       = markup.Box
	Columns   = markup.Columns
	Form      = markup.Form
	Signature = markup.Signature
)

Block kinds.

Variables

View Source
var DocumentColumns = []string{"Document", "Job"}

DocumentColumns are the columns of the Documents table.

View Source
var Papers = paper.Office

Papers are the sizes documents are built in.

View Source
var Sections = []concept.SectionSpec{
	{Name: "Buyer"}, {Name: "Promise"}, {Name: "Documents"}, {Name: "Look"}, {Name: "Changelog", Optional: true},
}

Sections of the document concept, in order.

Functions

func CopyLink(url string) string

CopyLink turns a Google Docs master's address into the link that makes the buyer's own copy.

func Distribution

func Distribution(r Report, files []deliver.File, data map[string][]byte, images []Image, pending bool, day string) (map[string][]byte, []string, []diagnostic.Diagnostic)

Distribution assembles the shop packages: every edition's ZIP once, the images, a guide per shop and the README.

func DownloadPage

func DownloadPage(r Report, files []deliver.File) []byte

DownloadPage renders the unlisted download page: the Google Docs copy links first, then the files.

func FileName

func FileName(title, ext string) string

FileName is a document's file name: its title, safe on every system.

func PagePixels

func PagePixels(e Edition) (int64, int64)

PagePixels is an edition's paper in CSS pixels, for a first-page shot.

func Present

func Present(p project.Project) bool

Present reports whether the project has deliverables/document.

func Rules

func Rules() []diagnostic.RuleInfo

Rules describes every document rule for the catalog.

Types

type Block

type Block = markup.Block

The Markdown model documents share with every editable deliverable.

type Built

type Built struct {
	Edition Edition
	Doc     *Doc
	Name    string // the file name buyers see: the document's title
	Key     string // the input key it is stamped with
	Data    []byte
}

Built is one .docx of one edition.

type Config

type Config struct {
	Path, Offer, Language, Sell, Version string
	Papers                               []string          // paper sizes for every language; default by language
	Docs                                 map[string]string // "lang/key" -> Google Docs master, for copy links
	Seller                               string
}

Config is deliverables.document in lfm.json.

type Doc

type Doc struct {
	Key, Lang  string
	File       string // path below the project
	Title      string
	Pages      int  // the pages it must print on; 0 when it may grow
	Ceremonial bool // centered layouts allowed: programs, invitations, certificates
	Cover      bool // the first page has no header or footer
	Header     string
	Footer     string // {page} and {pages} fill in; "none" for no footer
	Blocks     []Block
}

Doc is one document of one language, as its Markdown file describes it.

type Edition

type Edition struct {
	Key, Lang, Paper string
}

Edition is one language on one paper: the unit buyers download.

type Face

type Face = typeface.Face

Theme, Face and family are the shared look and fonts.

type Field

type Field = markup.Field

The Markdown model documents share with every editable deliverable.

type Figure

type Figure = markup.Figure

The Markdown model documents share with every editable deliverable.

type Finding

type Finding struct{ File, Message string }

Finding is a release finding about one source file.

type Image

type Image = deliver.Image

Image is a rendered listing image.

type ImagePlan

type ImagePlan struct {
	Name string
	Doc  []byte
}

ImagePlan is one listing image to render: 3000×2250 at twice the density.

type Inline

type Inline = markup.Inline

The Markdown model documents share with every editable deliverable.

type Item

type Item = markup.Item

The Markdown model documents share with every editable deliverable.

type Paper

type Paper = paper.Size

Paper is a page size in millimetres.

type Plan

type Plan struct {
	Name, Buyer, Promise string
	Documents            []Planned
	Look                 theme.Look
	Lines                map[string]int
}

Plan is the parsed concept.

type Planned

type Planned struct {
	Key, Job string
	Line     int
}

Planned is one document of the set, by its file name.

type Report

type Report struct {
	Config      Config
	Summary     Summary
	Plan        Plan
	Theme       Theme
	Diagnostics []diagnostic.Diagnostic
	Buildable   bool
	Editions    []Edition
	Docs        map[string][]*Doc // by language, in the concept's order
	Listing     deliver.ShopListing
	// contains filtered or unexported fields
}

Report is the checked document set.

func Check

func Check(p project.Project, cfg Config, configured bool, offers map[string]*deliver.Price, site string) Report

Check reads and checks the document set: concept, fonts, every document of every language, the theme on every paper, and the listing.

func (Report) Build

func (r Report) Build(previous func(key string) []byte) ([]Built, error)

Build writes every document of every edition. previous returns a file built from the same inputs before, which is used as is; the rest build side by side.

func (Report) Digest

func (r Report) Digest() []byte

Digest is the hash of what every file of the set shares: the theme, the fonts and their licences, and the images.

func (Report) Facts

func (r Report) Facts() []string

Facts are the set's numbers for the shop descriptions, from the build.

func (Report) FileNote

func (r Report) FileNote(e Edition) string

FileNote is the line under a file on the download page.

func (Report) Guide

func (r Report) Guide(e Edition) []byte

Guide is an edition's start-here PDF as HTML to print: the documents, how to open them in every app, how to fill and restyle them, printing, the licence.

func (Report) GuideAssets

func (r Report) GuideAssets() map[string][]byte

GuideAssets are the font files a guide or listing image loads, by bare file name as the print server serves them.

func (Report) GuideName

func (r Report) GuideName(e Edition) string

GuideName is an edition's start guide as a separate file.

func (Report) Images

func (r Report) Images(shots []Shot) []ImagePlan

Images plans the listing images from the first edition's first pages, rendered from the real files: the first document alone, every document, each one large, then what the set works with.

func (Report) Inspect

func (r Report) Inspect(b Built, pdf []byte) []Finding

Inspect holds Chrome's print of a document to its plan: pages, paper and the theme's fonts.

func (Report) Jobs

func (r Report) Jobs() []Built

Jobs are every document of every edition with the key of its inputs, not yet built.

func (Report) Preview

func (r Report) Preview(e Edition) []byte

Preview is an edition's documents as one HTML page for lfm serve.

func (Report) PreviewAssets

func (r Report) PreviewAssets() map[string][]byte

PreviewAssets are the fonts and images a preview loads, by path below its folder.

func (Report) PrintDoc

func (r Report) PrintDoc(b Built) []byte

PrintDoc is a built document's print layout for Chrome.

func (Report) ShotDoc

func (r Report) ShotDoc(b Built) []byte

ShotDoc is a built document's first page for a listing image.

func (Report) Showcase

func (r Report) Showcase() Edition

Showcase is the edition the listing shows: the first in the listing's language, else the first.

func (Report) Slug

func (r Report) Slug() string

Slug names the product's files.

func (Report) Verify

func (r Report) Verify(ctx context.Context, soffice string, built []Built) ([]Finding, error)

Verify opens every built file in LibreOffice, one run for all, and holds its print to the plan as Inspect does Chrome's: another app's view of the real .docx.

func (Report) Word

func (r Report) Word(built []Built) ([]Finding, error)

Word opens every built file in Microsoft Word for Mac and holds Word's own PDF of it to the plan, as Verify does LibreOffice's: a file Word has to repair, other pages, another paper, other fonts.

func (Report) Zip

func (r Report) Zip(e Edition, built []Built, pdfs map[string][]byte, guide []byte, key string) ([]byte, error)

Zip packs an edition: its documents, their PDFs when printed, the start guide, and the fonts with their licence, so Pages users can install them. A key stamps a complete ZIP, so later compiles reuse it as is.

func (Report) ZipName

func (r Report) ZipName(e Edition) string

ZipName is an edition's download.

type Shot

type Shot struct {
	Key   string // the built file's key
	Title string
	PNG   []byte
}

Shot is a document's first page as LibreOffice renders the real file.

type Summary

type Summary struct {
	Name      string   `json:"name,omitempty"`
	Concept   bool     `json:"concept"`
	Fonts     []string `json:"fonts,omitempty"` // the families the concept names
	Documents int      `json:"documents"`
	Languages []string `json:"languages,omitempty"`
	Editions  []string `json:"editions,omitempty"`
	Fields    int      `json:"fields"`
	Sell      string   `json:"sell"`
	URL       string   `json:"url,omitempty"`
	Files     []string `json:"files,omitempty"`
	Listing   bool     `json:"listing"`
	Linked    int      `json:"linked"`
	Channels  []string `json:"channels,omitempty"`
	Images    int      `json:"images"`
	Pending   bool     `json:"pending"`
	Layout    string   `json:"layout,omitempty"`
}

Summary is what the compile report shows.

type Table

type Table = markup.Table

The Markdown model documents share with every editable deliverable.

type Theme

type Theme = theme.Theme

Theme, Face and family are the shared look and fonts.

Jump to

Keyboard shortcuts

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