From 4a1d9bfa92e51ae8121c4315cded43a396e5ad41 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 14 Sep 2022 09:12:40 +0200 Subject: [PATCH] Add docstring to at-enumx macro, closes #2. --- src/EnumX.jl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/EnumX.jl b/src/EnumX.jl index 9310b01..a466896 100644 --- a/src/EnumX.jl +++ b/src/EnumX.jl @@ -8,6 +8,28 @@ abstract type Enum{T} <: Base.Enum{T} end @noinline panic(x) = throw(ArgumentError(x)) +""" + @enumx + +Macro for generating an enum type with instances. + +`@enumx` can be used as a drop in replacement for `@enum` from `Base`, but have several +improvements. See the [README](https://github.com/fredrikekre/EnumX.jl) or the module +docstring (`?EnumX` in the REPL) for more details. + +# Examples +```julia +julia> @enumx Fruit Apple Banana + +julia> Fruit.T +Enum type Fruit.T <: Enum{Int32} with 2 instances: + Fruit.Apple = 0 + Fruit.Banana = 1 + +julia> Fruit.Apple +Fruit.Apple = 0 +``` +""" macro enumx(args...) return enumx(__module__, Any[args...]) end