make functions with @doc false visible in IEX autocompletion

101 views
Skip to first unread message

Milad Rastian

unread,
Dec 20, 2017, 4:51:29 AM12/20/17
to elixir-lang-core
I've noticed in Elixir 1.5 we don't autocomplete functions that have @doc false.

For example if I create a module like this

defmodule MyApp.Accounts.User do
  use Ecto.Schema
  import Ecto.Changeset
  alias MyApp.Accounts.User


  schema "users" do
    field :age, :integer
    field :name, :string

    timestamps()
  end

  @doc false
  def changeset(%User{} = user, attrs) do
    user
    |> cast(attrs, [:name, :age])
    |> validate_required([:name, :age])
  end
end

And now if I try to use it in iex, I won't get autocompletion suggestion for changeset function.

iex(1)> MyApp.Accounts.User.<with pressing TAB, iex doesn't suggest changeset>


I believe this behavior is changed since this PR https://github.com/elixir-lang/elixir/pull/6131

In terms of user experience is a bit unexpected that in the above example I have a public function changeset and I can't get suggestion it in IEx. I use IEx regularly when I want to check something quickly and it happened to me few times so far and I was really confused why I can't get suggestion for my public function.


Looking forwards to hear your opinions

Robert Virding

unread,
Dec 20, 2017, 11:26:26 AM12/20/17
to elixir-lang-core
That sounds weird.

w.m.w...@student.rug.nl

unread,
Dec 20, 2017, 11:57:26 PM12/20/17
to elixir-lang-core
I believe that `@doc false' is used as an indication that a function, while accessible from outside the module, is not supposed to be `publically' used by consumers of the module.
So this behaviour is expected, and the best way to resolve this situation is probably to just add some descriptive documentation to the changeset function.

I can totally understand that this behaviour might feel somewhat counter-intuitive, however.
There is a related discussion going on about this right now over here (proposal: protected/private modules)

Milad Rastian

unread,
Jan 4, 2018, 10:22:02 AM1/4/18
to elixir-lang-core
Now that Elixir 1.6 has a @deprecated attribute, can we disable autocomplete in IEx only for functions that have @deprecated associated to function definitions?

What do you think?

Kelvin Raffael Stinghen

unread,
Jan 19, 2018, 7:46:33 AM1/19/18
to elixir-lang-core
Now that Elixir 1.6 has a @deprecated attribute, can we disable autocomplete in IEx only for functions that have @deprecated associated to function definitions?

I agree with hiding @deprecated functions, but not the @doc false ones.
Reply all
Reply to author
Forward
0 new messages