Incant.Naming (Incant v0.1.1)

Copy Markdown View Source

Configurable naming for inferred Incant labels and titles.

Explicit DSL labels and titles always take precedence. The vocabulary only applies when Incant must infer display text from an identifier.

Summary

Functions

Returns the naming options declared by an admin metadata value.

Returns a sentence-style inferred label.

Resolves inferred labels throughout a portable admin contract.

Returns the display text for a value when the naming vocabulary defines an explicit term for it, or nil when it does not. Unlike label/2, this does not invent a title-cased form for unknown values, so it is safe for humanizing data cells without mangling identifiers and model names.

Returns a title-style inferred title.

Types

config()

@type config() :: keyword() | map()

style()

@type style() :: :sentence | :title

Functions

for_admin(arg1)

@spec for_admin(term()) :: config()

Returns the naming options declared by an admin metadata value.

label(value, naming \\ [])

@spec label(term(), config()) :: String.t()

Returns a sentence-style inferred label.

resolve_contract(contract, naming \\ [])

@spec resolve_contract(Incant.Admin.Contract.t(), config()) ::
  Incant.Admin.Contract.t()

Resolves inferred labels throughout a portable admin contract.

term_label(value, naming \\ [])

@spec term_label(term(), config()) :: String.t() | nil

Returns the display text for a value when the naming vocabulary defines an explicit term for it, or nil when it does not. Unlike label/2, this does not invent a title-cased form for unknown values, so it is safe for humanizing data cells without mangling identifiers and model names.

title(value, naming \\ [])

@spec title(term(), config()) :: String.t()

Returns a title-style inferred title.