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

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

Merged
merged 3 commits into from
Nov 4, 2020

Conversation

whatyouhide
Copy link
Collaborator

@whatyouhide whatyouhide commented Nov 3, 2020

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.

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
Copy link
Member

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
Copy link
Collaborator Author

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

Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

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

nest_levels or nest_level? In any case, ship it. :)

@whatyouhide whatyouhide merged commit 802fd3c into master Nov 4, 2020
@whatyouhide whatyouhide deleted the support-nesting-docs branch November 4, 2020 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants