toDocument

This tree written back out as a document: the form an editor starts from when an admin changes the tree that is running.

The two forms are exact inverses on a valid tree: Topology.from(t.toDocument()) is TopologyParse.Valid with a topology equal to t. Every weight is written as the text from reads — "3" for a whole number, "3/2" for a ratio, always in lowest terms — and every child, template and ceiling is kept, in the order written.

Samples

val running = draft("pool") {
    group("acme", Weight.of(3)) {
        lane("interactive", Weight.of(3, 2))
        lane("batch", maxConcurrent = 2)
    }
}
val document = running.toDocument()
// Weights are written the way an admin writes them: a whole number, or a ratio.
val acme = document.children.single() as TopologyDocument.Group
check(acme.weight == "3" && acme.children.first().weight == "3/2")
// Reading it back gives the same tree.
check(Topology.from(document) == TopologyParse.Valid(running))