Skip to content

Commit 41b2c5c

Browse files
authored
Merge pull request JuliaCollections#114 from mortenpi/patch-1
Improve trait docstrings
2 parents 69faf4e + b19fe40 commit 41b2c5c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/traits.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
A trait which indicates whether a tree node stores references to its parents (`StoredParents()`) or
77
if the parents must be inferred from the tree structure (`ImplicitParents()`).
88
9-
Trees for which `parentlinks` returns `StoredParents()` *MUST* implement [`parent`](@ref).
9+
Trees for which `ParentLinks` returns `StoredParents()` *MUST* implement [`parent`](@ref).
1010
1111
If `StoredParents()`, all nodes in the tree must also have `StoredParents()`, otherwise use
1212
`ImplicitParents()`.
1313
1414
**OPTIONAL**: This should be implemented for a tree if parents of nodes are stored
1515
```julia
16-
AbstractTrees.parentlinks(::Type{<:TreeType}) = AbstractTrees.StoredParents()
16+
AbstractTrees.ParentLinks(::Type{<:TreeType}) = AbstractTrees.StoredParents()
1717
parent(t::TreeType) = get_parent(t)
1818
```
1919
"""
@@ -92,12 +92,15 @@ SiblingLinks(tree) = SiblingLinks(typeof(tree))
9292
ChildIndexing(node)
9393
9494
A trait indicating whether the tree node `n` has children (as returned by [`children`](@ref)) which can be
95-
indexed using 1-based indexing.
95+
indexed using 1-based indexing. Options are either [`NonIndexedChildren`](@ref) (default) or [`IndexedChildren`](@ref).
96+
97+
To declare that the tree `TreeType` supports one-based indexing on the children, define
98+
```julia
99+
AbstractTrees.ChildIndexing(::Type{<:TreeType}) = AbstractTrees.IndexedChildren()
100+
```
96101
97102
If a node has the `IndexedChildren()` so must all connected nodes in the tree. Otherwise, use
98103
`NonIndexedChildren()` instead.
99-
100-
Options are either [`NonIndexedChildren`](@ref) (default) or [`IndexedChildren`](@ref).
101104
"""
102105
abstract type ChildIndexing end
103106

0 commit comments

Comments
 (0)