Skip to content

Support defining Type Unions in Hash key or value signatures #150

Description

@postmodern

Is your feature request related to a problem? Please describe.

I am trying to use sord-4.0.0 to parse a very thoroughly YARD documented library of mine, but noticed that it does not recognize Type Unions within the key or value part of a Hash{K => V} signature.

Describe the solution you'd like

sord should be able to parse the following Hash{...} type signatures:

  • Hash{KeyType1,KeyType2 => ValueType}
  • Hash{KeyType => ValueType1,ValueType2}

Describe alternatives you've considered

The obvious workaround is to change the YARD Hash{...} type signature to Hash{KeyType1 => Value}, Hash{KeyType2 => Value}, however this implies that all of the Hash'es keys are either of KeyType or of KeyType2, but never a mixture of the two key types. I could change the Hash{...} signature to Hash{Object => ValueType} but that makes the Hash type signature less descriptive. In my library KeyType1 and KeyType2 do not have a common base class, so that is also not an option.

Additional context

real world code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions