IEx auto-complete on __functions__

39 views
Skip to first unread message

thibaut...@gmail.com

unread,
Sep 6, 2023, 4:01:56 PM9/6/23
to elixir-lang-core
Hi!

Today during a session I was caught a bit off-guard by the fact that completion doesn't tell you about __schema__ on an Ecto module.


I feel this is a bit sad in terms of "discoverability" for newcomers to Ecto in that case, since __schema__ is a public API of Ecto (https://hexdocs.pm/ecto/Ecto.Schema.html#module-reflection).

I wonder if this is an isolated example or if there are more cases that could affect newcomers to a given Elixir library, and how we could make this more approchable for newcomers?

Let me know what you think!

-- Thibaut


Austin Ziegler

unread,
Sep 6, 2023, 4:50:01 PM9/6/23
to elixir-l...@googlegroups.com
`__schema__` is only a partially-public API. For it to show up in documentation and iex, a PR would need to be accepted to Ecto that would add a `@doc` attribute to the generated `def __schema__(…)` code.

I just did the following test, and iex acts exactly as it should:

```
defmodule TestApp do
  def __test__, do: :test
end
```

In iex, `TestApp.<tab>` does not complete.

```
defmodule TestApp do
  @doc "The secret __test__ function"
  def __test__, do: :test
end
```

In iex, `TestApp.<tab>` completes to `TestApp.__test__`.

-a

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/3fbfc0f6-a7f0-4635-b4d1-32f1417d350dn%40googlegroups.com.


--

Thibaut Barrère

unread,
Sep 12, 2023, 3:13:13 AM9/12/23
to elixir-lang-core

> `__schema__` is only a partially-public API.

I believe it is indeed the culprit ; it is displayed as public on the website, but "technically" not public.

> For it to show up in documentation and iex, a PR would need to be accepted
> to Ecto that would add a `@doc` attribute to the generated `def __schema__(…)` code.

This is a good suggestion - I'll open an issue over there.

Thanks!

-- Thibaut

Reply all
Reply to author
Forward
Message has been deleted
0 new messages