Skip to content

Commit

Permalink
Documentation for options on gen.{context, html, json} (phoenixframew…
Browse files Browse the repository at this point in the history
…ork#2165)

* Typo fix in phx.gen.schema documentation

* Documenting the options on phx.gen.{context, html, json}
  • Loading branch information
szajbus authored and chrismccord committed Mar 7, 2017
1 parent b61a034 commit 6ee2b4e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 16 deletions.
31 changes: 26 additions & 5 deletions lib/mix/tasks/phx.gen.context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,35 @@ defmodule Mix.Tasks.Phx.Gen.Context do
A migration file for the repository and test files for the context
will also be generated.
## Schema options
## table
By deault, the schema table name will be the plural name, namespaced by the
context name. You can customize this value by providing the `--table`
option to the generator.
By default, the table name for the migration and schema will be
the plural name provided for the resource, namespaced by the context name,
To customize this value, a `--table` option may be provided. For example:
mix phx.gen.context Accounts User users --table cms_users
## binary_id
Generated migration can use `binary_id` for schema's primary key
and its references with option `--binary-id`.
## Default options
This generator uses default options provided in the `:generators`
configuration of your application. These are the defaults:
config :your_app, :generators,
migration: true,
binary_id: false,
sample_binary_id: "11111111-1111-1111-1111-111111111111"
You can override those options per invocation by providing corresponding
switches, e.g. `--no-binary-id` to use normal ids despite the default
configuration or `--migration` to force generation of the migration.
Read the documentation for `phx.gen.schema` for more information on
attributes and supported options.
attributes.
"""

use Mix.Task
Expand Down
31 changes: 26 additions & 5 deletions lib/mix/tasks/phx.gen.html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,35 @@ defmodule Mix.Tasks.Phx.Gen.Html do
A migration file for the repository and test files for the context and
controller features will also be generated.
## Schema options
## table
By deault, the schema table name will be the plural name, namespaced by the
context name. You can customize this value by providing the `--table`
option to the generator.
By default, the table name for the migration and schema will be
the plural name provided for the resource. To customize this value,
a `--table` option may be provided. For example:
mix phx.gen.html Accounts User users --table cms_users
## binary_id
Generated migration can use `binary_id` for schema's primary key
and its references with option `--binary-id`.
## Default options
This generator uses default options provided in the `:generators`
configuration of your application. These are the defaults:
config :your_app, :generators,
migration: true,
binary_id: false,
sample_binary_id: "11111111-1111-1111-1111-111111111111"
You can override those options per invocation by providing corresponding
switches, e.g. `--no-binary-id` to use normal ids despite the default
configuration or `--migration` to force generation of the migration.
Read the documentation for `phx.gen.schema` for more information on
attributes and supported options.
attributes.
"""
use Mix.Task

Expand Down
31 changes: 26 additions & 5 deletions lib/mix/tasks/phx.gen.json.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,35 @@ defmodule Mix.Tasks.Phx.Gen.Json do
A migration file for the repository and test files for the context and
controller features will also be generated.
## Schema options
## table
By deault, the schema table name will be the plural name, namespaced by the
context name. You can customize this value by providing the `--table`
option to the generator.
By default, the table name for the migration and schema will be
the plural name provided for the resource. To customize this value,
a `--table` option may be provided. For example:
mix phx.gen.json Accounts User users --table cms_users
## binary_id
Generated migration can use `binary_id` for schema's primary key
and its references with option `--binary-id`.
## Default options
This generator uses default options provided in the `:generators`
configuration of your application. These are the defaults:
config :your_app, :generators,
migration: true,
binary_id: false,
sample_binary_id: "11111111-1111-1111-1111-111111111111"
You can override those options per invocation by providing corresponding
switches, e.g. `--no-binary-id` to use normal ids despite the default
configuration or `--migration` to force generation of the migration.
Read the documentation for `phx.gen.schema` for more information on
attributes and supported options.
attributes.
"""

use Mix.Task
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/phx.gen.schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule Mix.Tasks.Phx.Gen.Schema do
By default, the table name for the migration and schema will be
the plural name provided for the resource. To customize this value,
a `--table` option may be provided. For exampe:
a `--table` option may be provided. For example:
mix phx.gen.schema Blog.Post posts --table cms_posts
Expand Down

0 comments on commit 6ee2b4e

Please sign in to comment.