Skip to content

change DynamicSupervisor doc to avoid confusions #13678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lib/elixir/lib/dynamic_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@ defmodule DynamicSupervisor do
extra_arguments: [term()]
}

@typedoc "Options given to `start_link` functions"
@type option :: GenServer.option()
Comment on lines -218 to -219
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now-removed type was being used at https://github.com/elixir-lang/elixir/blob/main/lib/elixir/lib/task/supervisor.ex#L77C1-L77C37 which now needs to be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done and thanks:
#13704


@typedoc "Options given to `start_link` and `init/1` functions"
@typedoc "Options given to `start_link/1` and `init/1` functions"
@type init_option ::
{:strategy, strategy()}
| {:max_restarts, non_neg_integer()}
Expand Down Expand Up @@ -345,9 +342,11 @@ defmodule DynamicSupervisor do
specified in the child spec given to `start_child/2`. Defaults to
an empty list.

* Any of the standard [GenServer options](`t:GenServer.option/0`)

"""
@doc since: "1.6.0"
@spec start_link([option | init_option]) :: Supervisor.on_start()
@spec start_link([init_option | GenServer.option()]) :: Supervisor.on_start()
def start_link(options) when is_list(options) do
keys = [:extra_arguments, :max_children, :max_seconds, :max_restarts, :strategy]
{sup_opts, start_opts} = Keyword.split(options, keys)
Expand Down Expand Up @@ -381,9 +380,15 @@ defmodule DynamicSupervisor do
Note that a supervisor started with this function is linked to the parent
process and exits not only on crashes but also if the parent process exits
with `:normal` reason.

## Options

This function accepts any regular [`GenServer` options](`t:GenServer.option/0`).
Options specific to `DynamicSupervisor` must be returned from the `c:init/1`
callback.
"""
@doc since: "1.6.0"
@spec start_link(module, term, [option]) :: Supervisor.on_start()
@spec start_link(module, term, [GenServer.option()]) :: Supervisor.on_start()
def start_link(module, init_arg, opts \\ []) do
GenServer.start_link(__MODULE__, {module, init_arg, opts[:name]}, opts)
end
Expand Down