dashbitco / nimble_options

A tiny library for validating and documenting high-level options. πŸ’½

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Protocol.UndefinedError when documenting a wildcard key keyword list

the-mikedavis opened this issue Β· comments

πŸ‘‹ hello!

I have a minimal example repo here: https://github.com/the-mikedavis/nimble_example, with the schema definition here and tests that exhibit the behaviour here

Given a schema like so (similar to a snippet in the documentation):

[
  foo: [
    type: :keyword_list,
    keys: [*: [type: :atom]]
  ]
]

we can properly validate a set of input options:

iex(1)> NimbleOptions.validate([foo: [bar: :baz]], schema())
{:ok, [foo: [bar: :baz]]}

but trying to document this schema will fail:

iex(2)> NimbleOptions.docs(schema())                        
** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): Map, Stream, Range, Date.Range, List, GenEvent.Stream, Function, File.Stream, HashDict, MapSet, IO.Stream, HashSet
    (elixir 1.11.0) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.11.0) lib/enum.ex:141: Enumerable.reduce/3
    (elixir 1.11.0) lib/enum.ex:3461: Enum.reduce/3
    (nimble_options 0.3.5) lib/nimble_options/docs.ex:61: NimbleOptions.Docs.option_doc/2
    (elixir 1.11.0) lib/enum.ex:2181: Enum."-reduce/3-lists^foldl/2-0-"/3
    (nimble_options 0.3.5) lib/nimble_options/docs.ex:6: NimbleOptions.Docs.generate/2

I'm using these versions

tool version
elixir 1.11.0
erlang 23.1
nimble_options 0.3.5
OS ubuntu 16.04

thanks!

@the-mikedavis thanks for reporting this issue!