Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ArgumentError with empty lists #1784

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ex_doc/language/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ defmodule ExDoc.Language.Elixir do
# If it is none, then we need to look at underscore.
# TODO: We can remove this on Elixir v1.13 as all underscored are hidden.
defp doc?({{_, name, _}, _, _, :none, _}, _type) do
hd(Atom.to_charlist(name)) != ?_
ExDoc.Utils.starts_with_underscore?(name) != true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ExDoc.Utils.starts_with_underscore?(name) != true
not ExDoc.Utils.starts_with_underscore?(name)

end

# Everything else is hidden.
Expand Down
4 changes: 1 addition & 3 deletions lib/ex_doc/refs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ defmodule ExDoc.Refs do

defguardp has_no_docs(doc) when doc == :none or doc == %{}

defp starts_with_underscore?(name), do: hd(Atom.to_charlist(name)) == ?_

defp visibility(:hidden),
do: :hidden

Expand All @@ -139,7 +137,7 @@ defmodule ExDoc.Refs do
kind in [:callback, :type] ->
:public

kind == :function and starts_with_underscore?(name) ->
kind == :function and ExDoc.Utils.starts_with_underscore?(name) ->
:hidden

kind == :function ->
Expand Down
6 changes: 6 additions & 0 deletions lib/ex_doc/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,10 @@ defmodule ExDoc.Utils do
nil
end
end

def starts_with_underscore?(name) when is_atom(name),
do: Atom.to_charlist(name) |> starts_with_underscore?()

def starts_with_underscore?([head | _]), do: head == ?_
def starts_with_underscore?(_), do: false
end