leafo / tableshape

Test the shape or structure of a Lua table, inspired by React.PropTypes & LPeg
111 stars 9 forks source link

merge annotate and describe, more options for controlling how nodes print #14

Open leafo opened 2 years ago

leafo commented 2 years ago

There are currently two nodes that control how a node is printed:

The idea of controlling how a node prints, wither during failed parse or description should be merged into single node that can be customized based on the needs. Here are some potential features of the node

Notes for compatibility:

A good path going forward might be remove the describe node and make the annotate node responsible. The current annotate nodes takes only a single opts argument so it already has a flexible interface.

Another option is to remove these nodes entirely, and insert this functionality in the base class for all types. All types would have to ensure to support it. Then, have methods like annotate or describe on the node that copy and return a new node with the customized parameters.