abstract class DocComposite
# Parent element.
- var parent: nullable DocComposite = null
+ var parent: nullable DocComposite = null is writable
# Does `self` have a `parent`?
fun is_root: Bool do return parent == null
#
# Shortcut for `children.add`.
fun add_child(child: DocComposite) do
+ child.parent = self
children.add child
end
+
+ # Depth of `self` in the composite tree.
+ fun depth: Int do
+ if parent == null then return 0
+ return parent.depth + 1
+ end
end
# The `DocComposite` element that contains all the other.