Skip to content

Commit 7ff1d6f

Browse files
committed
fix: Don't remove double newlines from generated docs
Removing double newlines breaks formatting in e.g. the generated browser docs, and breaks doctests, since they expect the example code sections to be separated by the rest of the comments by double newlines. Removing the calls to `trim_double_newlines` triggers a whole bunch of formatting changes, but they should be harmless enough. Fixes: #2433
1 parent 38447df commit 7ff1d6f

File tree

1 file changed

+35
-42
lines changed

1 file changed

+35
-42
lines changed

lib/ash/code_interface.ex

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -457,15 +457,14 @@ defmodule Ash.CodeInterface do
457457
interface_options = Ash.Resource.Interface.interface_options(:calculate, nil)
458458

459459
@doc """
460-
#{calculation.description || "Calculates #{calculation.name} action on #{inspect(resource)}."}
460+
#{calculation.description || "Calculates #{calculation.name} action on #{inspect(resource)}."}
461461
462-
#{Ash.CodeInterface.describe_calculation(resource, calculation, interface.args, interface.exclude_inputs, interface.custom_inputs)}
462+
#{Ash.CodeInterface.describe_calculation(resource, calculation, interface.args, interface.exclude_inputs, interface.custom_inputs)}
463463
464-
### Options
464+
### Options
465465
466-
#{interface_options.docs()}
467-
"""
468-
|> Ash.CodeInterface.trim_double_newlines()
466+
#{interface_options.docs()}
467+
"""
469468
@doc spark_opts: [
470469
{opts_location, interface_options.schema()}
471470
]
@@ -523,15 +522,14 @@ defmodule Ash.CodeInterface do
523522
end
524523

525524
@doc """
526-
#{calculation.description || "Calculates #{calculation.name} action on #{inspect(resource)}."}
525+
#{calculation.description || "Calculates #{calculation.name} action on #{inspect(resource)}."}
527526
528-
#{Ash.CodeInterface.describe_calculation(resource, calculation, interface.args, interface.exclude_inputs, interface.custom_inputs)}
527+
#{Ash.CodeInterface.describe_calculation(resource, calculation, interface.args, interface.exclude_inputs, interface.custom_inputs)}
529528
530-
### Options
529+
### Options
531530
532-
#{interface_options.docs()}
533-
"""
534-
|> Ash.CodeInterface.trim_double_newlines()
531+
#{interface_options.docs()}
532+
"""
535533
@doc spark_opts: [
536534
{opts_location, interface_options.schema()}
537535
]
@@ -1643,15 +1641,14 @@ defmodule Ash.CodeInterface do
16431641

16441642
@dialyzer {:nowarn_function, {interface.name, length(common_args) + 2}}
16451643
@doc """
1646-
#{action.description || "Calls the #{action.name} action on #{inspect(resource)}."}
1644+
#{action.description || "Calls the #{action.name} action on #{inspect(resource)}."}
16471645
1648-
#{Ash.CodeInterface.describe_action(resource, action, interface.args, interface.exclude_inputs, interface.custom_inputs)}
1646+
#{Ash.CodeInterface.describe_action(resource, action, interface.args, interface.exclude_inputs, interface.custom_inputs)}
16491647
1650-
## Options
1648+
## Options
16511649
1652-
#{interface_options.docs()}
1653-
"""
1654-
|> Ash.CodeInterface.trim_double_newlines()
1650+
#{interface_options.docs()}
1651+
"""
16551652

16561653
@doc spark_opts: [
16571654
{first_opts_location, interface_options.schema()},
@@ -1673,17 +1670,16 @@ defmodule Ash.CodeInterface do
16731670
# sobelow_skip ["DOS.BinToAtom"]
16741671
@dialyzer {:nowarn_function, {:"#{interface.name}!", length(common_args) + 2}}
16751672
@doc """
1676-
#{action.description || "Calls the #{action.name} action on #{inspect(resource)}."}
1673+
#{action.description || "Calls the #{action.name} action on #{inspect(resource)}."}
16771674
1678-
Raises any errors instead of returning them
1675+
Raises any errors instead of returning them
16791676
1680-
#{Ash.CodeInterface.describe_action(resource, action, interface.args, interface.exclude_inputs, interface.custom_inputs)}
1677+
#{Ash.CodeInterface.describe_action(resource, action, interface.args, interface.exclude_inputs, interface.custom_inputs)}
16811678
1682-
## Options
1679+
## Options
16831680
1684-
#{interface_options.docs()}
1685-
"""
1686-
|> Ash.CodeInterface.trim_double_newlines()
1681+
#{interface_options.docs()}
1682+
"""
16871683

16881684
@doc spark_opts: [
16891685
{first_opts_location, interface_options.schema()},
@@ -1722,13 +1718,12 @@ defmodule Ash.CodeInterface do
17221718
{first_opts_location + 1, interface_options.schema()}
17231719
]
17241720
@doc """
1725-
Returns the #{subject_name} corresponding to the action.
1721+
Returns the #{subject_name} corresponding to the action.
17261722
1727-
## Options
1723+
## Options
17281724
1729-
#{Spark.Options.docs(subject_opts)}
1730-
"""
1731-
|> Ash.CodeInterface.trim_double_newlines()
1725+
#{Spark.Options.docs(subject_opts)}
1726+
"""
17321727
@doc spark_opts: [
17331728
{first_opts_location, subject_opts},
17341729
{first_opts_location + 1, subject_opts}
@@ -1746,15 +1741,14 @@ defmodule Ash.CodeInterface do
17461741

17471742
# sobelow_skip ["DOS.BinToAtom"]
17481743
@doc """
1749-
Runs authorization checks for `#{inspect(resource)}.#{action.name}`
1744+
Runs authorization checks for `#{inspect(resource)}.#{action.name}`
17501745
1751-
See `Ash.can/3` for more information
1746+
See `Ash.can/3` for more information
17521747
1753-
## Options
1748+
## Options
17541749
1755-
#{Ash.Resource.Interface.CanOpts.docs()}
1756-
"""
1757-
|> Ash.CodeInterface.trim_double_newlines()
1750+
#{Ash.Resource.Interface.CanOpts.docs()}
1751+
"""
17581752
@dialyzer {:nowarn_function, {:"can_#{interface.name}", length(common_args) + 3}}
17591753
@doc spark_opts: [
17601754
{first_opts_location + 1, Ash.Resource.Interface.CanOpts.schema()},
@@ -1834,15 +1828,14 @@ defmodule Ash.CodeInterface do
18341828
{first_opts_location + 2, Ash.Resource.Interface.CanQuestionMarkOpts.schema()}
18351829
]
18361830
@doc """
1837-
Runs authorization checks for `#{inspect(resource)}.#{action.name}`, returning a boolean.
1831+
Runs authorization checks for `#{inspect(resource)}.#{action.name}`, returning a boolean.
18381832
1839-
See `Ash.can?/3` for more information
1833+
See `Ash.can?/3` for more information
18401834
1841-
## Options
1835+
## Options
18421836
1843-
#{Ash.Resource.Interface.CanQuestionMarkOpts.docs()}
1844-
"""
1845-
|> Ash.CodeInterface.trim_double_newlines()
1837+
#{Ash.Resource.Interface.CanQuestionMarkOpts.docs()}
1838+
"""
18461839
def unquote(:"can_#{interface.name}?")(
18471840
actor,
18481841
unquote_splicing(common_args),

0 commit comments

Comments
 (0)