Skip to content

Commit

Permalink
chore: docs for new extension
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Dec 20, 2024
1 parent 70fa970 commit 9f18c5d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
60 changes: 60 additions & 0 deletions documentation/dsls/DSL-AshPhoenix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!--
This file was generated by Spark. Do not edit it by hand.
-->
# DSL: AshPhoenix

An extension to add form builders to the code interface.

This defines a `form_to_<name>` function for each code interface
function. Positional arguments are ignored, given that in forms,
all input typically comes from the `params` map.

The generated function passes all options through to
`AshPhoenix.Form.for_action/3`

Update and destroy actions take the record being updated/destroyed
as the first argument.

For example, given this code interface definition on a domain
called `MyApp.Accounts`:

```elixir
resources do
resource MyApp.Accounts.User do
define :register_with_password, args: [:email, :password]
define :update_user, action: :update, args: [:email, :password]
end
end
```

Adding the `AshPhoenix` extension would define
`form_to_register_with_password/2`.

## Usage

Without options:

```elixir
MyApp.Accounts.form_to_register_with_password()
#=> %AshPhoenix.Form{}
```

With options:

```elixir
MyApp.Accounts.form_to_register_with_password(params: %{"email" => "placeholder@email"})
#=> %AshPhoenix.Form{}
```

With

```elixir
MyApp.Accounts.form_to_update_user(params: %{"email" => "placeholder@email"})
#=> %AshPhoenix.Form{}
```





<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style>
2 changes: 2 additions & 0 deletions lib/ash_phoenix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule AshPhoenix do
@moduledoc """
An extension to add form builders to the code interface.
There is currently no DSL for this extension.
This defines a `form_to_<name>` function for each code interface
function. Positional arguments are ignored, given that in forms,
all input typically comes from the `params` map.
Expand Down
20 changes: 18 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ defmodule AshPhoenix.MixProject do
{"README.md", title: "Home"},
"documentation/tutorials/getting-started-with-ash-and-phoenix.md",
"documentation/topics/union-forms.md",
"documentation/dsls/DSL-AshPhoenix.md",
"CHANGELOG.md"
],
groups_for_extras: [
Expand All @@ -70,6 +71,10 @@ defmodule AshPhoenix.MixProject do
Topics: ~r'documentation/topics',
"About AshPhoenix": [
"CHANGELOG.md"
],
Reference: [
~r"documentation/topics/reference",
~r"documentation/dsls"
]
],
before_closing_head_tag: fn type ->
Expand Down Expand Up @@ -132,6 +137,7 @@ defmodule AshPhoenix.MixProject do
{:phoenix, "~> 1.5.6 or ~> 1.6"},
{:phoenix_html, "~> 4.0"},
{:phoenix_live_view, "~> 0.20.3 or ~> 1.0 or ~> 1.0.0-rc.1"},
{:spark, "~> 2.1 and >= 2.2.29"},
{:simple_sat, "~> 0.1", only: [:dev, :test]},
{:git_ops, "~> 2.5", only: [:dev, :test]},
{:ex_doc, "~> 0.32", only: [:dev, :test], override: true},
Expand All @@ -157,8 +163,18 @@ defmodule AshPhoenix.MixProject do

defp aliases do
[
docs: ["docs", "spark.replace_doc_links"],
sobelow: "sobelow --skip -i Config.Secrets --ignore-files lib/ash_phoenix/gen/live.ex"
sobelow: "sobelow --skip -i Config.Secrets --ignore-files lib/ash_phoenix/gen/live.ex",
docs: [
"spark.cheat_sheets",
"docs",
"spark.replace_doc_links",
"spark.cheat_sheets_in_search"
],
credo: "credo --strict",
format: "format",
"spark.cheat_sheets_in_search": "spark.cheat_sheets_in_search --extensions AshPhoenix",
"spark.formatter": "spark.formatter --extensions AshPhoenix",
"spark.cheat_sheets": "spark.cheat_sheets --extensions AshPhoenix"
]
end
end

0 comments on commit 9f18c5d

Please sign in to comment.