Hello there,

TLDR: Having an easy way to find behaviour do for implementing function.

I was playing around with behaviours and found something that bugs me.
Here is the kind of code I wrote :

defmodule MyBehaviour do
@moduledoc "general purpose doc"

@doc "fun/0 contract description"
@callback fun() :: any()
end

defmodule MyImplementation do
@behaviour MyBehaviour

@impl MyBehaviour
def fun, do: nil
end

Then some other place (or even some other project if it’s bundled in a 
library) would call MyImplementation.fun()
My proposal is about documentation, currently we have no doc inheritance 
and this results in IEx returning:

> h MyImplementation.fun
No documentation for MyImplementation.fun was found

Intuitively, I would expect to get:
- MyImplementation.fun doc if defined (and a link to MyBehaviour.fun , 
maybe?)
- MyBehaviour.fun doc as a fallback (or only an link to it)

For example, in many projects, GenServer is used and I’d expect h 
MyService.init to point me to GenServer.init doc since most likely dev 
won’t override the doc.

Is there something I don’t see that would make this a bad idea?

-- 
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-core+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/elixir-lang-core/54e9d7d0-578a-4cd1-86b8-1b7bbd6c652dn%40googlegroups.com.

Reply via email to