Skip to content

Commit a901a3a

Browse files
committed
Add axistrait docs
1 parent a66b03f commit a901a3a

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/core.jl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,10 @@ Two main types of axes supported by default include:
130130
131131
User-defined axis types can be added along with custom indexing
132132
behaviors. To add add a custom type as a Categorical or Dimensional
133-
axis, add a trait using `AxisArrays.axistrait`. Here is the example of
134-
adding a custom Dimensional axis:
135-
136-
```julia
137-
AxisArrays.axistrait(v::MyCustomAxis) = AxisArrays.Dimensional
138-
```
133+
axis, add a trait using [`AxisArrays.axistrait`](@ref).
139134
140135
For more advanced indexing, you can define custom methods for
141-
`AxisArrays.axisindexes`.
142-
136+
[`AxisArrays.axisindexes`](@ref).
143137
144138
### Examples
145139
@@ -520,6 +514,23 @@ immutable Dimensional <: AxisTrait end
520514
immutable Categorical <: AxisTrait end
521515
immutable Unsupported <: AxisTrait end
522516

517+
"""
518+
axistrait(ax::Axis) -> Type{<:AxisTrait}
519+
520+
Returns the indexing type of an `Axis`, any subtype of `AxisTrait`.
521+
The default is `Unsupported`, meaning there is no special indexing behaviour for this axis
522+
and indexes into this axis are passed directly to the underlying array.
523+
524+
Two main types of axes supported by default are `Categorical` and `Dimensional`; see
525+
[Indexing](@ref) for more information on these types.
526+
527+
User-defined axis types can be added along with custom indexing behaviors by defining new
528+
methods of this function. Here is the example of adding a custom Dimensional axis:
529+
530+
```julia
531+
AxisArrays.axistrait(v::MyCustomAxis) = AxisArrays.Dimensional
532+
```
533+
"""
523534
axistrait(::Any) = Unsupported
524535
axistrait(ax::Axis) = axistrait(ax.val)
525536
axistrait{T<:Union{Number, Dates.AbstractTime}}(::AbstractVector{T}) = Dimensional

0 commit comments

Comments
 (0)