Skip to content

Commit 95f2424

Browse files
committed
mix format
1 parent e45fd31 commit 95f2424

File tree

4 files changed

+50
-27
lines changed

4 files changed

+50
-27
lines changed

lib/mix/tasks/phx.gen.context.ex

+2
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ defmodule Mix.Tasks.Phx.Gen.Context do
109109
end
110110

111111
{context, schema} = build(args)
112+
112113
binding = [
113114
context: context,
114115
schema: schema,
115116
scope: context.scope,
116117
primary_key: schema.opts[:primary_key] || :id
117118
]
119+
118120
paths = Mix.Phoenix.generator_paths()
119121

120122
prompt_for_conflicts(context)

lib/mix/tasks/phx.gen.html.ex

+16-8
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ defmodule Mix.Tasks.Phx.Gen.Html do
126126
scope_conn_route_prefix: Scope.route_prefix(conn_scope, schema),
127127
scope_param_route_prefix: Scope.route_prefix("scope", schema),
128128
scope_assign_route_prefix: scope_assign_route_prefix(schema),
129-
test_context_scope: if(schema.scope && schema.scope.route_prefix, do: ", scope: scope", else: "")
129+
test_context_scope:
130+
if(schema.scope && schema.scope.route_prefix, do: ", scope: scope", else: "")
130131
]
131132

132133
paths = Mix.Phoenix.generator_paths()
@@ -186,11 +187,12 @@ defmodule Mix.Tasks.Phx.Gen.Html do
186187

187188
@doc false
188189
def print_shell_instructions(%Context{schema: schema, context_app: ctx_app} = context) do
189-
resource_path = if schema.scope && schema.scope.route_prefix do
190-
"#{schema.scope.route_prefix}/#{schema.plural}"
191-
else
192-
"/#{schema.plural}"
193-
end
190+
resource_path =
191+
if schema.scope && schema.scope.route_prefix do
192+
"#{schema.scope.route_prefix}/#{schema.plural}"
193+
else
194+
"/#{schema.plural}"
195+
end
194196

195197
if schema.web_namespace do
196198
Mix.shell().info("""
@@ -213,7 +215,9 @@ defmodule Mix.Tasks.Phx.Gen.Html do
213215
end
214216

215217
if schema.scope do
216-
Mix.shell().info("Ensure the routes are defined in a block that sets the `#{inspect(context.scope.assign_key)}` assign.")
218+
Mix.shell().info(
219+
"Ensure the routes are defined in a block that sets the `#{inspect(context.scope.assign_key)}` assign."
220+
)
217221
end
218222

219223
if context.generate?, do: Gen.Context.print_shell_instructions(context)
@@ -288,9 +292,13 @@ defmodule Mix.Tasks.Phx.Gen.Html do
288292

289293
defp label(key), do: Phoenix.Naming.humanize(to_string(key))
290294

291-
defp scope_assign_route_prefix(%{scope: %{route_prefix: route_prefix, assign_key: assign_key}} = schema) when not is_nil(route_prefix) do
295+
defp scope_assign_route_prefix(
296+
%{scope: %{route_prefix: route_prefix, assign_key: assign_key}} = schema
297+
)
298+
when not is_nil(route_prefix) do
292299
Scope.route_prefix("@#{assign_key}", schema)
293300
end
301+
294302
defp scope_assign_route_prefix(_), do: ""
295303

296304
@doc false

lib/mix/tasks/phx.gen.json.ex

+11-8
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ defmodule Mix.Tasks.Phx.Gen.Json do
122122
context_scope_prefix: context_scope_prefix,
123123
scope_conn_route_prefix: Scope.route_prefix(conn_scope, schema),
124124
scope_param_route_prefix: Scope.route_prefix("scope", schema),
125-
test_context_scope: if(schema.scope && schema.scope.route_prefix, do: ", scope: scope", else: "")
125+
test_context_scope:
126+
if(schema.scope && schema.scope.route_prefix, do: ", scope: scope", else: "")
126127
]
127128

128129
paths = Mix.Phoenix.generator_paths()
@@ -178,11 +179,12 @@ defmodule Mix.Tasks.Phx.Gen.Json do
178179

179180
@doc false
180181
def print_shell_instructions(%Context{schema: schema, context_app: ctx_app} = context) do
181-
resource_path = if schema.scope && schema.scope.route_prefix do
182-
"#{schema.scope.route_prefix}/#{schema.plural}"
183-
else
184-
"/#{schema.plural}"
185-
end
182+
resource_path =
183+
if schema.scope && schema.scope.route_prefix do
184+
"#{schema.scope.route_prefix}/#{schema.plural}"
185+
else
186+
"/#{schema.plural}"
187+
end
186188

187189
if schema.web_namespace do
188190
Mix.shell().info("""
@@ -205,10 +207,11 @@ defmodule Mix.Tasks.Phx.Gen.Json do
205207
end
206208

207209
if schema.scope do
208-
Mix.shell().info("Ensure the routes are defined in a block that sets the `#{inspect(context.scope.assign_key)}` assign.")
210+
Mix.shell().info(
211+
"Ensure the routes are defined in a block that sets the `#{inspect(context.scope.assign_key)}` assign."
212+
)
209213
end
210214

211215
if context.generate?, do: Gen.Context.print_shell_instructions(context)
212216
end
213-
214217
end

lib/mix/tasks/phx.gen.live.ex

+21-11
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ defmodule Mix.Tasks.Phx.Gen.Live do
144144
scope_param_prefix: scope_param_prefix(schema),
145145
scope_socket_route_prefix: Scope.route_prefix(socket_scope, schema),
146146
scope_assign_route_prefix: scope_assign_route_prefix(schema),
147-
test_context_scope: if(schema.scope && schema.scope.route_prefix, do: ", scope: scope", else: "")
147+
test_context_scope:
148+
if(schema.scope && schema.scope.route_prefix, do: ", scope: scope", else: "")
148149
]
149150

150151
paths = Mix.Phoenix.generator_paths()
@@ -291,7 +292,9 @@ defmodule Mix.Tasks.Phx.Gen.Live do
291292
end
292293

293294
if schema.scope do
294-
Mix.shell().info("Ensure the routes are defined in a block that sets the `#{inspect(context.scope.assign_key)}` assign.")
295+
Mix.shell().info(
296+
"Ensure the routes are defined in a block that sets the `#{inspect(context.scope.assign_key)}` assign."
297+
)
295298
end
296299

297300
if context.generate?, do: Gen.Context.print_shell_instructions(context)
@@ -310,12 +313,13 @@ defmodule Mix.Tasks.Phx.Gen.Live do
310313
end
311314

312315
defp live_route_instructions(schema) do
313-
route_base = if schema.scope && schema.scope.route_prefix do
314-
scope_prefix = schema.scope.route_prefix
315-
"#{scope_prefix}/#{schema.plural}"
316-
else
317-
"/#{schema.plural}"
318-
end
316+
route_base =
317+
if schema.scope && schema.scope.route_prefix do
318+
scope_prefix = schema.scope.route_prefix
319+
"#{scope_prefix}/#{schema.plural}"
320+
else
321+
"/#{schema.plural}"
322+
end
319323

320324
[
321325
~s|live "#{route_base}", #{inspect(schema.alias)}Live.Index, :index\n|,
@@ -397,18 +401,24 @@ defmodule Mix.Tasks.Phx.Gen.Live do
397401

398402
defp label(key), do: Phoenix.Naming.humanize(to_string(key))
399403

400-
401404
defp scope_param(%{scope: nil}), do: ""
402-
defp scope_param(%{scope: %{route_prefix: route_prefix}}) when not is_nil(route_prefix), do: "scope"
405+
406+
defp scope_param(%{scope: %{route_prefix: route_prefix}}) when not is_nil(route_prefix),
407+
do: "scope"
408+
403409
defp scope_param(_), do: "_scope"
404410

405411
defp scope_param_prefix(schema) do
406412
param = scope_param(schema)
407413
if param != "", do: "#{param}, ", else: ""
408414
end
409415

410-
defp scope_assign_route_prefix(%{scope: %{route_prefix: route_prefix, assign_key: assign_key}} = schema) when not is_nil(route_prefix) do
416+
defp scope_assign_route_prefix(
417+
%{scope: %{route_prefix: route_prefix, assign_key: assign_key}} = schema
418+
)
419+
when not is_nil(route_prefix) do
411420
Scope.route_prefix("@#{assign_key}", schema)
412421
end
422+
413423
defp scope_assign_route_prefix(_), do: ""
414424
end

0 commit comments

Comments
 (0)