From 2c6ed51661b04962b07d6bd907347dfa77a93509 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Wed, 1 Jul 2020 09:37:42 -0400 Subject: [PATCH] docs: add short type references --- lib/ash/type/type.ex | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/ash/type/type.ex b/lib/ash/type/type.ex index d9b8656a..184f38a1 100644 --- a/lib/ash/type/type.ex +++ b/lib/ash/type/type.ex @@ -15,6 +15,16 @@ defmodule Ash.Type do ] ] + @short_names [ + term: Ash.Type.Term, + string: Ash.Type.String, + integer: Ash.Type.Integer, + boolean: Ash.Type.Boolean, + uuid: Ash.Type.UUID, + date: Ash.Type.Date, + utc_datetime: Ash.Type.UtcDatetime + ] + @doc_list_constraints Keyword.put(@list_constraints, :items, type: :any, doc: @@ -28,6 +38,14 @@ defmodule Ash.Type do Much better to `use Ash.Type` than to say `@behaviour Ash.Type` and define everything yourself. + ## Built in types + + #{ + Enum.map_join(@short_names, fn {key, module} -> + "* `#{inspect(key)}` - `#{inspect(module)}`\n" + end) + } + ### Composite Types Currently, the only composite type supported is a list type, specified via: @@ -45,16 +63,6 @@ defmodule Ash.Type do @callback apply_constraints(term, constraints()) :: :ok | {:error, String.t() | [String.t()]} @callback equal?(term, term) :: boolean - @short_names [ - term: Ash.Type.Term, - string: Ash.Type.String, - integer: Ash.Type.Integer, - boolean: Ash.Type.Boolean, - uuid: Ash.Type.UUID, - date: Ash.Type.Date, - utc_datetime: Ash.Type.UtcDatetime - ] - @type t :: atom | {:array, atom} @doc false