docs: Format default options for special attributes as code, in Ash.Resource DSL (#1336)

This commit is contained in:
Rebecca Le 2024-07-24 18:15:31 +08:00 committed by GitHub
parent 516ff8ef8e
commit 912fcf99de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 26 deletions

View file

@ -120,11 +120,13 @@ Declares a non-writable attribute with a create default of `&DateTime.utc_now/0`
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except it sets
the following different defaults:
```elixir
writable? false
default &DateTime.utc_now/0
match_other_defaults? true
type Ash.Type.UTCDatetimeUsec
allow_nil? false
```
@ -162,12 +164,14 @@ Declares a non-writable attribute with a create and update default of `&DateTime
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except it sets
the following different defaults:
```elixir
writable? false
default &DateTime.utc_now/0
match_other_defaults? true
update_default &DateTime.utc_now/0
type Ash.Type.UTCDatetimeUsec
allow_nil? false
```
@ -207,11 +211,13 @@ Generated integer primary keys must be supported by the data layer.
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except for `allow_nil?`, but it sets
the following different defaults:
```elixir
public? true
writable? false
primary_key? true
generated? true
type :integer
```
@ -249,11 +255,13 @@ Declares a non writable, non-nil, primary key column of type `uuid`, which defau
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except for `allow_nil?`, but it sets
the following different defaults:
```elixir
writable? false
public? true
default &Ash.UUID.generate/0
primary_key? true
type :uuid
```
@ -291,11 +299,13 @@ Declares a non writable, non-nil, primary key column of type `uuid_v7`, which de
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except for `allow_nil?`, but it sets
the following different defaults:
```elixir
writable? false
public? true
default &Ash.UUIDv7.generate/0
primary_key? true
type :uuid_v7
```

View file

@ -55,11 +55,13 @@ defmodule Ash.Resource.Dsl do
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except it sets
the following different defaults:
writable? false
default &DateTime.utc_now/0
match_other_defaults? true
type Ash.Type.UTCDatetimeUsec
allow_nil? false
```elixir
writable? false
default &DateTime.utc_now/0
match_other_defaults? true
type Ash.Type.UTCDatetimeUsec
allow_nil? false
```
""",
examples: [
"create_timestamp :inserted_at"
@ -78,12 +80,14 @@ defmodule Ash.Resource.Dsl do
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except it sets
the following different defaults:
writable? false
default &DateTime.utc_now/0
match_other_defaults? true
update_default &DateTime.utc_now/0
type Ash.Type.UTCDatetimeUsec
allow_nil? false
```elixir
writable? false
default &DateTime.utc_now/0
match_other_defaults? true
update_default &DateTime.utc_now/0
type Ash.Type.UTCDatetimeUsec
allow_nil? false
```
""",
examples: [
"update_timestamp :updated_at"
@ -104,11 +108,13 @@ defmodule Ash.Resource.Dsl do
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except for `allow_nil?`, but it sets
the following different defaults:
public? true
writable? false
primary_key? true
generated? true
type :integer
```elixir
public? true
writable? false
primary_key? true
generated? true
type :integer
```
""",
examples: [
"integer_primary_key :id"
@ -128,11 +134,13 @@ defmodule Ash.Resource.Dsl do
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except for `allow_nil?`, but it sets
the following different defaults:
writable? false
public? true
default &Ash.UUID.generate/0
primary_key? true
type :uuid
```elixir
writable? false
public? true
default &Ash.UUID.generate/0
primary_key? true
type :uuid
```
""",
examples: [
"uuid_primary_key :id"
@ -152,11 +160,13 @@ defmodule Ash.Resource.Dsl do
Accepts all the same options as `d:Ash.Resource.Dsl.attributes.attribute`, except for `allow_nil?`, but it sets
the following different defaults:
writable? false
public? true
default &Ash.UUIDv7.generate/0
primary_key? true
type :uuid_v7
```elixir
writable? false
public? true
default &Ash.UUIDv7.generate/0
primary_key? true
type :uuid_v7
```
""",
examples: [
"uuid_v7_primary_key :id"