Latest Release

Gem Version

YARD Type Parser

Here is an experimental version of a parser that converts YARD's formal type syntax into plain old English. This is a good way to test if your type declaration means what you think it does:

You can find the code on Github at http://github.com/lsegal/yard-types-parser.

Enter a List of Types

Results

Try Some Examples
Click the examples to run them.

The syntax used in the examples below is not official YARD type syntax. This is actually just one syntax being looked at as a possible standard. You can give feedback on the syntax in the #yard IRC channel.

A bunch of regular types and a constant:
Fixnum, Foo, Object, true
A duck-typed Object
#read
An array of various objects
Array<String, Symbol, #read>
A collection type other than an Array
Set<Number>
An fixed-size array of specific objects
Array(String, Symbol)
A Hash with one key type and a few value types
Hash{String => Symbol, Number}
A complex example showing a possibility of many different types
Array<Foo, Bar>, List(String, Symbol, #to_s), {Foo, Bar => Symbol, Number}
Finally, some shorthands for collections and hashes
<String, Symbol>, (String, Symbol), {Key=>Value}