Documentation
¶
Overview ¶
Package spreadsheet is the spreadsheet deliverable: budget, bookkeeping and tracker templates described in workbook.json, built as .xlsx files per edition, computed and checked by lfm's own formula engine on every compile and, when installed, by LibreOffice on a release, and delivered with a Google Sheets copy link the owner creates once.
Index ¶
- Constants
- Variables
- func CopyLink(raw string) string
- func Distribution(r Report, files []deliver.File, data map[string][]byte, images []Image, ...) (map[string][]byte, []string, []diagnostic.Diagnostic)
- func DownloadPage(r Report, files []deliver.File) []byte
- func Office() (string, error)
- func Present(p project.Project) bool
- func Recalculate(ctx context.Context, soffice string, files map[string][]byte) (map[string]map[string][][]string, error)
- func Rules() []diagnostic.RuleInfo
- func Stamp(tail []byte) string
- type Built
- type Cell
- type Chart
- type Column
- type Config
- type Dataset
- type Edition
- type Highlight
- type Image
- type ImagePlan
- type Palette
- type Plan
- type Pos
- type Report
- func (r Report) Build(previous func(key string) []byte) ([]Built, error)
- func (r Report) Compat(ctx context.Context, office string, files []Built) ([]string, error)
- func (r Report) Excel(built []Built) ([]string, error)
- func (r Report) Facts() []string
- func (r Report) FileName(e Edition, example bool) string
- func (r Report) FileNote(name string) string
- func (r Report) Images() []ImagePlan
- func (r Report) Preview(key string) []byte
- func (r Report) Slug() string
- func (r Report) StartDoc(ed *edition) []byte
- func (r Report) StartDocs() map[string][]byte
- func (r Report) StartFileName(e Edition) string
- type Row
- type Sheet
- type Summary
- type Tab
- type Text
- type TextList
- type Workbook
Constants ¶
const ( Empty = "empty" Example = "example" )
Datasets the files are built from: the blank template and, when the workbook has one, the filled example.
const ( Dir = "deliverables/spreadsheet" ConceptFile = Dir + "/concept.md" WorkbookName = "workbook.json" WorkbookFile = Dir + "/" + WorkbookName ListingFile = Dir + "/listing.md" )
The layout under deliverables/spreadsheet.
const ( RuleConfig = "spreadsheet.config" RuleConcept = "spreadsheet.concept" RuleWorkbook = "spreadsheet.workbook" RuleFormulas = "spreadsheet.formulas" RuleCompat = "spreadsheet.compat" RuleSheets = "spreadsheet.sheets" RuleDelivery = "spreadsheet.delivery" RuleListing = "spreadsheet.listing" RuleChannels = "spreadsheet.channels" )
Rule IDs.
Variables ¶
var Sections = []concept.SectionSpec{ {Name: "Buyer"}, {Name: "Promise"}, {Name: "Tabs"}, {Name: "Look"}, {Name: "Changelog", Optional: true}, }
Sections of the spreadsheet concept, in order.
var TabColumns = []string{"Tab", "Job"}
TabColumns are the columns of the Tabs table.
Functions ¶
func CopyLink ¶
CopyLink turns a Google Sheets address into the link that makes the buyer a copy, or "".
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 from the built files: per edition the blank and example .xlsx and the start PDF, a ZIP per edition when Etsy's five files would not hold them, images, guides and a README.
func DownloadPage ¶
DownloadPage renders the unlisted download page: the Google Sheets copy links first, then the files.
func Recalculate ¶
func Recalculate(ctx context.Context, soffice string, files map[string][]byte) (map[string]map[string][][]string, error)
Recalculate opens every file in LibreOffice, recalculates it and returns each sheet's cells as LibreOffice computes them: file name -> sheet name -> rows of raw values. One soffice run serves all files.
func Rules ¶
func Rules() []diagnostic.RuleInfo
Rules describes every spreadsheet rule for the catalog.
Types ¶
type Cell ¶
type Cell struct {
At string `json:"at"` // report: A1 position; form cells stack from row 2
Name string `json:"name"` // a name formulas use: [income]
Label Text `json:"label"`
Text Text `json:"text"`
Value any `json:"value"` // an input's default
Formula string `json:"formula"`
Type string `json:"type"` // text, number, money, percent, date, enum, check
Style string `json:"style"` // title, heading, label, input, output, note, total
Values TextList `json:"values"`
From string `json:"from"`
Highlight []Highlight `json:"highlight"`
Note Text `json:"note"`
Merge int `json:"merge"` // columns the cell spans to the right
}
Cell is one cell of a form or report.
type Chart ¶
type Chart struct {
Type string `json:"type"` // pie, doughnut, column, bar, line
Title Text `json:"title"`
Labels string `json:"labels"` // [sheet.column] or a range placeholder
Values string `json:"values"`
At string `json:"at"`
Width int `json:"width"` // pixels
Height int `json:"height"`
}
Chart is a native chart on a report.
type Column ¶
type Column struct {
Key string `json:"key"`
Title Text `json:"title"`
Type string `json:"type"` // text, number, money, percent, date, enum, check
Values TextList `json:"values"`
From string `json:"from"` // enum: the column its choices come from, as sheet.column
Formula string `json:"formula"` // computed per row; [.other] is this row's cell of another column
Width float64 `json:"width"`
Highlight []Highlight `json:"highlight"`
Note Text `json:"note"` // shown as the header's comment
}
Column is one column of a table.
type Config ¶
type Config struct {
Path, Offer, Language, Sell, Version string
Sheets map[string]string // edition key (or key-example) -> Google Sheets master
Seller string
}
Config is deliverables.spreadsheet in lfm.json.
type Edition ¶
type Edition struct {
Key string `json:"key"` // e.g. en, de
Language string `json:"language"` // the language its texts are picked in
Currency string `json:"currency"` // ISO code: USD, EUR, GBP, CHF
}
Edition is one language and currency the workbook is built in.
type Highlight ¶
type Highlight struct {
If string `json:"if"`
Style string `json:"style"` // good, bad, warn, muted
}
Highlight colors a cell when its condition holds: "<0" or a formula.
type Palette ¶
type Palette struct {
Accent, Ink, Input, Heading, HeadingInk, Muted, Line string
}
Palette is the look of a workbook: its accent and the tints derived from it.
type Report ¶
type Report struct {
Config Config
Plan Plan
Workbook Workbook
Editions []*edition
Books map[string]map[string]*book // edition key -> dataset -> computed book
Summary Summary
Diagnostics []diagnostic.Diagnostic
Listing deliver.ShopListing
Buildable bool
}
Report is the checked spreadsheet.
func Check ¶
func Check(p project.Project, cfg Config, configured bool, offers map[string]*deliver.Price, site string) Report
Check reads deliverables/spreadsheet: configured tells whether lfm.json has deliverables.spreadsheet; site is the page URL the download path hangs off.
func (Report) Build ¶
Build writes the .xlsx files: per edition the blank template and, when the workbook has an example, the filled example. Files build side by side; previous returns a file built from the same inputs before, stamped with its key, which is used as is.
func (Report) Compat ¶
Compat recalculates the built files in LibreOffice and returns where its values differ from lfm's.
func (Report) Excel ¶
Excel opens every file in Microsoft Excel for Mac, recalculates it and holds Excel's values to lfm's: the differences, or why Excel refused a file.
func (Report) Images ¶
Images plans the listing images from the first edition's example: the main report alone first (Etsy ranks it higher without text), every tab, each tab large, then what it works with.
func (Report) Preview ¶
Preview is an edition as one HTML page with its tabs, computed with the example (or the blank template), for lfm serve.
func (Report) StartDoc ¶
StartDoc is the start-here PDF of an edition as HTML to print: the copy button first, the steps from the guide sheet, the notes for Excel, Numbers and phones, the licence.
func (Report) StartFileName ¶
StartFileName is the start PDF of an edition.
type Sheet ¶
type Sheet struct {
Key string `json:"key"` // stable name for placeholders: [log.amount]
Name Text `json:"name"`
Kind string `json:"kind"` // guide, form, table or report
Hidden bool `json:"hidden"`
Lines []Text `json:"lines"` // guide: one per row; "# " starts a heading
Cells []Cell `json:"cells"` // form and report
Columns []Column `json:"columns"` // table
Rows int `json:"rows"` // table: how many data rows the template holds
Seed []Row `json:"seed"` // table: rows the blank template ships with, such as categories
Charts []Chart `json:"charts"` // report
Widths []float64 `json:"widths"` // report: column widths in characters, from column A
}
Sheet is one tab.
type Summary ¶
type Summary struct {
Name string `json:"name,omitempty"`
Concept bool `json:"concept"`
Workbook bool `json:"workbook"`
Editions []string `json:"editions,omitempty"`
Sheets int `json:"sheets"`
Formulas int `json:"formulas"` // formula cells per edition
Checked []string `json:"checked,omitempty"`
Sell string `json:"sell"`
URL string `json:"url,omitempty"`
Files []string `json:"files,omitempty"`
Listing bool `json:"listing"`
Linked int `json:"linked"` // Google Sheets masters linked
Channels []string `json:"channels,omitempty"`
Images int `json:"images"`
Pending bool `json:"pending"`
Compat string `json:"compat,omitempty"`
}
Summary is what the report and --json show about the spreadsheet.
type Text ¶
Text is a string, or one per language: {"en": "Log", "de": "Buchungen"}.
func (*Text) UnmarshalJSON ¶
UnmarshalJSON takes a string or an object of strings.
type TextList ¶
TextList is a list of strings, or one list per language.
func (*TextList) UnmarshalJSON ¶
UnmarshalJSON takes a list or an object of lists.
type Workbook ¶
type Workbook struct {
Editions []Edition `json:"editions"`
Today string `json:"today"` // the date TODAY() is evaluated at in checks and previews
Words map[string]Text `json:"words"` // localized words formulas and choices use as [@key] and "@key"
Sheets []Sheet `json:"sheets"`
Datasets map[string]Dataset `json:"datasets"` // "example" fills the example file; "empty" is the blank template
Expect map[string]map[string]any `json:"expect"` // dataset -> cell -> value
}
Workbook is deliverables/spreadsheet/workbook.json: the sheets of the product, its editions, the datasets it is checked with and what they must compute.