Writer API contract
Every writer module exposes the same four output forms as extension functions on its model types. X stands for the format name (Asciidoc, Markdown, Dot, Bnf); x for its lower-case form.
The four forms
| Signature | Returns | Behavior |
|---|---|---|
|
|
the complete output as one string |
|
|
appends the output to any |
|
|
writes the output UTF-8 encoded to a kotlinx-io |
|
|
cold flow of output chunks in document order |
Writer options
A writer that has an output option takes it as a defaulted parameter on all four forms, rather than adding functions — the four forms stay four. markup-bnf-writer is the only such writer today: toBnf(flavor), writeBnfTo(out, flavor), writeBnfTo(sink, flavor) and bnfFlow(flavor) all take an optional BnfFlavor (default EBNF). The contract below holds per flavor.
Receiver × writer matrix
| Receiver | markup-asciidoc-writer | markup-markdown-writer | markup-dot-writer | markup-bnf-writer |
|---|---|---|---|---|
|
|
|
— |
— |
|
same four forms |
same four forms |
— |
— |
|
— |
— |
|
— |
|
— |
— |
— |
|
Packages
| Writer module | Package |
|---|---|
|
|
|
|
|
|
|
|
Example imports:
import org.markup.poet.dsl.write.asciidoc.toAsciidoc
import org.markup.poet.dsl.write.markdown.writeMarkdownTo
import org.markup.poet.dsl.write.dot.dotFlow
import org.markup.poet.dsl.write.bnf.toBnf
Contract
-
Concatenation equality — concatenating all emissions of
xFlow()yields exactly the string returned bytoX(); all four forms produce byte-identical output. -
Sink lifecycle — the
Sinkoverloads write UTF-8 and neither flush nor close the sink; the caller owns its lifecycle. -
Cold flows —
xFlow()does no work until collected, and each collection produces the chunks anew. -
Chunk boundaries are an implementation detail — chunks arrive in document order, but their size and split points may change between releases; do not depend on them.