TomHale
How do I overload @doc strings?
I’m trying to work around the following warning:
warning: redefining @doc attribute previously set at line 78.
Please remove the duplicate docs. If instead you want to override a previously defined @doc, attach the @doc attribute to a function head (the function signature not followed by any do-block). For example:
@doc """
new docs
"""
def get_futures_instruments(...)
I’ve tried to implement this advice, but can’t seem to work it out. What I’m doing is:
@doc """
Get all instruments, optionally filtered by underlying instrument(s)
*** This is the main doc string that I'm trying to override below. ***
"""
def get_futures_instruments(filter \\ nil)
@doc "Get all instruments whose names start with the given `filter_str`"
@spec get_futures_instruments(String.t() | nil) :: {:ok, list(map)} | error_response()
def get_futures_instruments(filter_str) when is_binary(filter_str) or is_nil(filter_str) do
...
end
@doc "Get all instruments whose names start with any of those given in `filter_list`"
@spec get_futures_instruments(list(String.t())) :: {:ok, list(map)} | error_response()
def get_futures_instruments(filter_list) when is_list(filter_list) do
...
end
Most Liked
APB9785
Creator of ECSx
I think what the warning is getting at, is that all your docs should be above
def get_futures_instruments(filter \\ nil)
Checking the docs for the docs (Writing Documentation — Elixir v1.12.3), it says:
- Place documentation before the first clause of multi-clause functions. Documentation is always per function and arity and not per clause.
It seems like what you’re trying to do in the OP goes against this rule.
1
Nicd
Perhaps if a macro has written a @doc for you, then you might end up with two @doc.
1
Popular in Questions
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
Hey guys.
I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Other popular topics
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
can someone please explain to me how Enum.reduce works with maps
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New







