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

Conversation

mayel
Copy link
Contributor

@mayel mayel commented Sep 27, 2023

After adding LiveViewNative to a project I was no longer able to generate docs, with this error:

Generating docs...
** (ArgumentError) errors were found at the given arguments:

  * 1st argument: not a nonempty list

    (erts 14.1) :erlang.hd([])
    (ex_doc 0.30.6) lib/ex_doc/refs.ex:119: ExDoc.Refs.starts_with_underscore?/1
    (ex_doc 0.30.6) lib/ex_doc/refs.ex:142: ExDoc.Refs.visibility/2
    (ex_doc 0.30.6) lib/ex_doc/refs.ex:97: anonymous fn/4 in ExDoc.Refs.fetch_entries/2
    (elixir 1.15.6) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_doc 0.30.6) lib/ex_doc/refs.ex:95: ExDoc.Refs.fetch_entries/2
    (ex_doc 0.30.6) lib/ex_doc/refs.ex:64: ExDoc.Refs.insert_from_chunk/2
    (ex_doc 0.30.6) lib/ex_doc/retriever.ex:66: ExDoc.Retriever.docs_chunk/1

It seems that was caused by a macro who's name appears as :"" which seems strange but anyway here's a fix.

@@ -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)

@whatyouhide whatyouhide changed the title fix for not a nonempty list Fix ArgumentError with empty lists Sep 28, 2023
@josevalim
Copy link
Member

I will push a smaller fix but please consider reporting this upstream to LVN. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants