Skip to content

Commit 6a32bc1

Browse files
committed
Add docs and defaults to base_configs_schema options
1 parent 1465e94 commit 6a32bc1

1 file changed

Lines changed: 31 additions & 15 deletions

File tree

lib/live_admin.ex

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ defmodule LiveAdmin do
22
@moduledoc docout: [LiveAdmin.READMECompiler]
33

44
@type mod_func :: {module(), :atom}
5-
@type func_ref :: :atom | mod_func() | :mfa
5+
@type func_ref :: atom() | mod_func()
66
@type func_list :: [func_ref] | keyword(func_ref)
77
@type field_list :: [:atom]
88

99
@options_schema [
1010
components: [
1111
type: :non_empty_keyword_list,
12+
doc: "Overrides portions of the UI with custom LiveComponent modules.",
1213
type_doc: "list of modules implementing LiveComponent overrides of LiveAdmin views",
1314
keys: [
1415
nav: [type: :atom],
@@ -22,49 +23,60 @@ defmodule LiveAdmin do
2223
],
2324
ecto_repo: [
2425
type: :atom,
26+
doc: "Required. Must be set at the application or scope level.",
2527
type_doc: "Ecto Repo used to query resource"
2628
],
2729
query_with: [
2830
type: {:or, [:atom, {:tuple, [:atom, :atom]}]},
31+
doc: "Customizes how records are fetched. Receives the resource and search term and should return an Ecto queryable. Useful for adding preloads or custom search logic. When not set, uses the schema with built-in search.",
2932
type_doc: "`t:func_ref/0` returning an Ecto queryable"
3033
],
3134
render_with: [
3235
type: {:or, [:atom, {:tuple, [:atom, :atom]}]},
36+
doc: "Customizes how field values are displayed. Receives the record, field name, and session. Should return a string or `Phoenix.HTML.Safe` value to render HTML. When not set, uses built-in type-based rendering.",
3337
type_doc: "`t:func_ref/0` used to convert field values to strings when rendering"
3438
],
3539
delete_with: [
36-
type: {:or, [:atom, {:tuple, [:atom, :atom]}]},
37-
type_doc: "`t:func_ref/0` or `false` to disable deleting records"
40+
type: {:or, [{:in, [false]}, :atom, {:tuple, [:atom, :atom]}]},
41+
doc: "Customizes how records are deleted. Can be set to `false` to disable. When not set, uses `Repo.delete`.",
42+
type_doc: "`t:func_ref/0` or `false`"
3843
],
3944
create_with: [
40-
type: {:or, [:atom, {:tuple, [:atom, :atom]}]},
41-
type_doc: "`t:func_ref/0` or `false` to disable creating records"
45+
type: {:or, [{:in, [false]}, :atom, {:tuple, [:atom, :atom]}]},
46+
doc: "Customizes how records are created. Can be set to `false` to disable. When not set, builds a changeset that casts all fields with no validations and calls `Repo.insert`.",
47+
type_doc: "`t:func_ref/0` or `false`"
4248
],
4349
update_with: [
44-
type: {:or, [:atom, {:tuple, [:atom, :atom]}]},
45-
type_doc: "`t:func_ref/0` or `false` to disable updating records"
50+
type: {:or, [{:in, [false]}, :atom, {:tuple, [:atom, :atom]}]},
51+
doc: "Customizes how records are updated. Can be set to `false` to disable. When not set, builds a changeset that casts all fields with no validations and calls `Repo.update`.",
52+
type_doc: "`t:func_ref/0` or `false`"
4653
],
4754
validate_with: [
4855
type: {:or, [:atom, {:tuple, [:atom, :atom]}]},
49-
type_doc:
50-
"`t:func_ref/0` used to validate create/update changesets in LiveAdmin :form component"
56+
doc: "Customizes how changesets are validated in create/update forms. When not set, no additional validation is applied.",
57+
type_doc: "`t:func_ref/0`"
5158
],
5259
label_with: [
5360
type: {:or, [:atom, {:tuple, [:atom, :atom]}]},
54-
type_doc:
55-
"`t:func_ref/0` used to convert (association) record to string in LiveAdmin SearchSelect component"
61+
doc: "Customizes how records are identified in the UI. When not set, uses the primary key.",
62+
type_doc: "`t:func_ref/0`"
5663
],
5764
title_with: [
5865
type: {:or, [:string, {:tuple, [:atom, :atom]}]},
59-
type_doc: "string literal or MFA returning a string used to render LiveAdmin UI heading"
66+
doc: "Customizes the heading displayed for a resource. When not set, uses the schema module name.",
67+
type_doc: "string literal or `t:func_ref/0`"
6068
],
6169
hidden_fields: [
6270
type: {:list, :atom},
63-
type_doc: "`t:field_list/0` to be hidden from LiveView"
71+
default: [],
72+
doc: "Specifies fields to hide from all views.",
73+
type_doc: "`t:field_list/0`"
6474
],
6575
immutable_fields: [
6676
type: {:list, :atom},
67-
type_doc: "`t:field_list/0` to be disabled in LiveAdmin :form component"
77+
default: [],
78+
doc: "Specifies fields to disable in create/update forms.",
79+
type_doc: "`t:field_list/0`"
6880
],
6981
actions: [
7082
type:
@@ -77,6 +89,8 @@ defmodule LiveAdmin do
7789
{:tuple,
7890
[:atom, {:or, [{:tuple, [:atom, :atom]}, {:tuple, [:atom, :atom, :integer]}]}]}
7991
]}},
92+
default: [],
93+
doc: "Defines functions that operate on a specific record.",
8094
type_doc: "`t:func_list/0` taking a record, LiveAdmin session struct, and any extra args"
8195
],
8296
tasks: [
@@ -90,8 +104,10 @@ defmodule LiveAdmin do
90104
{:tuple,
91105
[:atom, {:or, [{:tuple, [:atom, :atom]}, {:tuple, [:atom, :atom, :integer]}]}]}
92106
]}},
107+
default: [],
108+
doc: "Defines functions that operate on a resource as a whole.",
93109
type_doc:
94-
"`t:func_list/0` taking a query, LiveAdmin session and any extra args. The query will include any search conditions limiting results, but not pagination or order"
110+
"`t:func_list/0` taking a query, LiveAdmin session, and any extra args"
95111
]
96112
]
97113
@doc """

0 commit comments

Comments
 (0)