day8 / re-frame-10x

A debugging dashboard for re-frame. X-ray vision as tooling.
MIT License
634 stars 68 forks source link

Condensed pretty-print #100

Closed mhuebert closed 6 years ago

mhuebert commented 7 years ago

This PR (see issue #96) includes a new namespace with some functions for truncation, including namespace-aware truncation. It also has basic functionality for wrapping collections with appropriate brackets.

The pretty-print-condensed namespace contains exhaustive examples (tests in the form of commented assertions) which demonstrate the behaviour.

I used these functions to add a preview of event parameters in the trace view. Sometimes it's necessary to see the parameters that were passed to an event, in order to really know what happened. It was necessary to have nice compaction functions in order to show this information by default without overwhelming the viewer. The pretty-condensed function contains some hard-coded values for this use case (it could be easily parameterized).

Here is a screenshot from my example page. The previews are visible in grey, next to the event names:

image

AFAICT fipp and pprint have no built-in way to specify constraints on the length of internal elements of collections. If either of those tools have a suitable extension mechanism, maybe we could extend it to use these truncation functions whenever strings/keywords/symbols are encountered, and thus have a more general solution.

danielcompton commented 6 years ago

Hey I rolled all of this up into one commit, thanks heaps for working on it!