Documentation
¶
Overview ¶
Package render turns a work into a file to send. Each kind of file is a Format: adding one is a type that implements it and a line in main that adds it to the Set; the mind and the console offer whatever the Set has.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoData = errors.New("render: the work doesn't carry what this file is made from")
Functions ¶
Types ¶
type DataFormat ¶
type DataFormat interface {
Format
// DataSchema is the data for Structured Outputs; DataHelp tells System 2
// how to write it.
DataSchema() map[string]any
DataHelp() string
// CleanData keeps what can be used of raw; an error if nothing can.
CleanData(raw json.RawMessage) (json.RawMessage, error)
}
DataFormat is a format made from data a work carries beside its words, which it defines: a craft that names the data (character.yaml's data) gets it written with each work.
type Format ¶
type Format interface {
Name() string // what a promise's "as" and a reply's send.as say, e.g. "pdf"
Ext() string
MediaType() string
// Describe is how the person knows the file, like "a PDF document, to
// print, attach or pass on"; WriteHelp is how to write a work meant to go
// as one, or "".
Describe() string
WriteHelp() string
// Needs is the data a work must carry to be this file (memory.Work.Carries);
// "" if its words are enough. A format that needs data is a DataFormat.
Needs() string
Render(w memory.Work, author string) ([]byte, error)
}
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
A nil Set has no formats.
func (*Set) Data ¶
func (s *Set) Data(kind string) (DataFormat, bool)
Data is the format that defines data of kind.
func (*Set) DataKinds ¶
DataKinds is the data its formats are made from, each once, in the order NewSet was given.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package archive is data a work carries: files with their paths, like the code of a small program, made into a zip.
|
Package archive is data a work carries: files with their paths, like the code of a small program, made into a zip. |
|
Package calendar is data a work carries: dated events, made into an iCalendar (.ics) file that adds them to any calendar app.
|
Package calendar is data a work carries: dated events, made into an iCalendar (.ics) file that adds them to any calendar app. |
|
Package docx writes a work's words as a Word document, laid out from its Markdown with Word's own styles (Title, Heading 1 to 9, lists, Quote, tables), so it can be edited as one.
|
Package docx writes a work's words as a Word document, laid out from its Markdown with Word's own styles (Title, Heading 1 to 9, lists, Quote, tables), so it can be edited as one. |
|
Package markdown reads a work's words as Markdown into a flat list of blocks for a format to lay out.
|
Package markdown reads a work's words as Markdown into a flat list of blocks for a format to lay out. |
|
Package midi writes a score (tracks of notes, placed by bar and beat) as a standard MIDI file that any DAW opens.
|
Package midi writes a score (tracks of notes, placed by bar and beat) as a standard MIDI file that any DAW opens. |
|
Package pdf lays a piece of writing out as an A4 PDF: its title, then its text read as Markdown (render/markdown).
|
Package pdf lays a piece of writing out as an A4 PDF: its title, then its text read as Markdown (render/markdown). |
|
Package table is data a work carries: a table of rows and columns, made into a spreadsheet (XLSX) or a CSV file.
|
Package table is data a work carries: a table of rows and columns, made into a spreadsheet (XLSX) or a CSV file. |