View Source Spark.OptionsHelpers (spark v1.1.44)
Helpers for working with our superset of nimble options.
Additional Types
Spark provides the following additional option types for use when building DSLs or validating options.
{:one_of, values}
- maps to{:in, values}
for backwards compatibility{:tagged_tuple, tag, inner_type}
- maps to{tag, type}
{:spark_behaviour, behaviour}
- expects a module that implements the given behaviour, and can be specified with options, i.emod
or{mod, [opt: :val]}
{:spark_behaviour, behaviour, builtin_module}
- Same as the above, but also accepts abuiltin_module
. The builtin_module is used to provide additional options for the elixir_sense plugin.{:spark_function_behaviour, behaviour, {function_mod, arity}}
- expects a module that implements the given behaviour, and can be specified with options, i.emod
or{mod, [opt: :val]}
, that also has a special module that supports being provided an anonymous function or MFA as the:fun
option.{:spark_function_behaviour, behaviour, builtin_module, {function_mod, arity}}
- Same as the above, but also accepts abuiltin_module
. The builtin_module is used to provide additional options for the elixir_sense plugin.{:behaviour, behaviour}
- expects a module that implements a given behaviour.{:spark, dsl_module}
- expects a module that is aSpark.Dsl
{:mfa_or_fun, arity}
- expects a function or MFA of a corresponding arity.{:spark_type, module, builtin_function}
- a behaviour that definesbuiltin_function/0
that returns a list of atoms that map to built in variations of that thing.{:spark_type, module, builtin_function, templates}
- same as the above, but includes additional templates for elixir_sense autocomplete:fun
- a function of any arity:literal
-> any literal value. Maps to:any
, but is used for documentation.{:literal, value}
-> exactly the value specified.:quoted
-> retains the quoted value of the code provided to the option:quoted_with_env
-> retains the qutoed value of the code provided to the option and the env, in a tuple{quoted, env}
.{:wrap_list, type}
-> Allows a single value or a list of values.
Summary
Types
The schema type, as defined by the NimbleOptions docs.
The types as specified by the NimbleOptions docs.
The actual schema type, as used in sections and entities.
Spark provides additional types on top of those provided by NimbleOptions.
Functions
Creates markdown documentation for a given schema.
Merges two schemas, and sets the subsection
option on all options on the right
side.
Sanitizes the option schema and validates with NimbleOptions.
Sanitizes the option schema and validates with NimbleOptions.
Types
@type nimble_schema() :: [ type: type() | :any, required: boolean(), default: :any, keys: Keyword.t({:type, type()}), deprecated: String.t(), doc: String.t(), subsection: String.t(), type_doc: false | String.t(), rename_to: atom() ]
The schema type, as defined by the NimbleOptions docs.
@type nimble_types() :: :any | :keyword_list | :non_empty_keyword_list | :map | {:map, key_type :: type(), value_type :: type()} | :atom | :string | :boolean | :integer | :non_neg_integer | :pos_integer | :float | :timeout | :pid | :reference | :mfa | :mod_arg | {:fun, arity :: non_neg_integer()} | {:in, [type()] | Range.t()} | {:custom, module(), function :: atom(), args :: [any()]} | {:or, [type()]} | {:list, type() | {:keyword_list, type()} | {:non_empty_keyword_list, type()}} | {:tuple, [type() | {:keyword_list, type()} | {:non_empty_keyword_list, type()}]}
The types as specified by the NimbleOptions docs.
@type schema() :: Keyword.t(nimble_schema())
The actual schema type, as used in sections and entities.
@type type() :: nimble_types() | {:one_of, [type()]} | {:tagged_tuple, tag :: type(), inner_type :: type()} | {:spark_behaviour, module()} | {:spark_behaviour, module(), module()} | {:spark_function_behaviour, module(), {module(), integer()}} | {:spark_function_behaviour, module(), module(), {module(), integer()}} | {:behaviour, module()} | {:spark, module()} | {:mfa_or_fun, non_neg_integer()} | {:spark_type, module(), builtin_function :: atom()} | {:spark_type, module(), builtin_function :: atom(), templates :: [String.t()]} | {:struct, module()} | :fun | {:fun, [type()]} | {:fun, [type()], type()} | {:wrap_list, type()} | :literal | {:literal, any()} | :quoted
Spark provides additional types on top of those provided by NimbleOptions.
Functions
Creates markdown documentation for a given schema.
Merges two schemas, and sets the subsection
option on all options on the right
side.
Sanitizes the option schema and validates with NimbleOptions.
Sanitizes the option schema and validates with NimbleOptions.