dashbitco / nimble_options

A tiny library for validating and documenting high-level options. 💽
Apache License 2.0
507 stars 38 forks source link

Support a nesting level in NimbleOptions.docs/2 #57

Closed whatyouhide closed 3 years ago

whatyouhide commented 3 years ago

The nesting level allows to nest all options in the generated Markdown by the given level. This allows to have, for example, a nested nested_schema schema and use NimbleOptions.docs/2 inside the documentation for another option:

main_schema = [
  my_key: [
    type: {:or, [:string, keyword_list: nested_schema]},
    doc: """
    Either a string or a keyword list with keys:

    #{NimbleOptions.docs(nested_schema, _nest_level = 1)}
    """
  ]
]

The options for the nested schema in :my_key will be nested by one level, producing the correct Markdown.

josevalim commented 3 years ago

Can we make it a keyword list? I am sure we will want other options in the future and the fact we are using a variable probably means we should use a keyword list anyway. :D

whatyouhide commented 3 years ago

@josevalim good call, didn't think about it. Updated!