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.
You can specify whether to cut from the :start, :middle or :end (for strings)
When truncating namespaced things, we cut from the start, and only keep whole segments.
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:
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.
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.
:start
,:middle
or:end
(for strings)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:
AFAICT
fipp
andpprint
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.