I quite often put the API for a library in the top-level module, but delegate all the calls down into various implementation modules.
This leaves we with the problem of where to put the @doc.
I want to put it in the API module so that clients of the library can see all the API documentation by asking for help on the functions they actually call.
I also want to put it in the implementation modules so that people reading the code have access to it.
So, my suggestion: if a defdelegate does not have its own documentation, could it receive a copy of the documentation of the function it delegates to? This means the source could have just one copy (in the implementation), but iex, hexdocs etc would also see it at the top level.
This would be my preferred change. However, if it isn’t acceptable, I have a plan B.
Could we have an @see directive which could be used with @doc and @moduledoc?
@doc @see Mylib.Stats.stddev
defdelegate stddev(sample), to: Mylib.Stats
If @see is passed a module, it returns the moduledoc. If passed a function name, it returns the docstring. If passed a string, it returns the contents of the given file. Whaa??? you say. Doing this means we can document the top-level using
@moduledoc @see "README.md"
--
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/d94f489a-74cc-4f79-9c77-d13a06d68123%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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/CAGnRm4KT55uQMFn6t6xGFed%2BgSHFL%2BYUJ7BhieAx_ov_B5FJ4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Forgot to say, I think the best route would be @doc see: "String.length/1". Then it's the job of the doc tool to render it if they want to.
--
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/d94f489a-74cc-4f79-9c77-d13a06d68123%40googlegroups.com.
Btw, “see” could be implemented as a library today, it just needs to be a macro (a module attribute would be weird, especially since “@attr val” is meant to set the attribute, and not execute custom code). So I would go this route!
--
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/CAGnRm4%2BFN%3D8Go5KQkXpT6BXja7sOdDz%3D4%3DED6eexNFc6wA%3D-MQ%40mail.gmail.com.
--
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/72452964-30EB-48B6-B11C-3384F4B6EFBB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.