Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eerohele/tab
A tool for tabulating Clojure collections.
https://github.com/eerohele/tab
clojure visualization
Last synced: 4 days ago
JSON representation
A tool for tabulating Clojure collections.
- Host: GitHub
- URL: https://github.com/eerohele/tab
- Owner: eerohele
- License: mit
- Created: 2023-01-02T21:20:12.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-17T06:45:27.000Z (2 months ago)
- Last Synced: 2024-09-17T09:19:18.705Z (2 months ago)
- Topics: clojure, visualization
- Language: Clojure
- Homepage:
- Size: 326 KB
- Stars: 69
- Watchers: 5
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Tab
[![0 dependencies!](https://0dependencies.dev/0dependencies.svg)](https://0dependencies.dev)
Tab is a little program that turns Clojure data structures into tables.
## Rationale
Tab's primary aim is to help Clojure programmers make sense of data.
Most interesting Clojure values are maps or seqs of maps. When small, pretty-printing is an adequate tool for inspecting such values. When they get to medium size (like, say, your typical [Ring](https://github.com/ring-clojure/ring) request map), you're better off reaching for something else.
Tab aims to be that something else.
## Differences to similar tools
- Tab only shows you one value at a time.
- Tab datafies (via `clojure.datafy/datafy`) values you give it.
- Tab aims to be useful without forcing you to choose between different viewers (table, tree, etc).
- Tab has no dependencies.## Try
Given that you have the [Clojure CLI](https://clojure.org/guides/install_clojure) installed, on the command line, run:
```bash
clj -Sdeps '{:deps {io.github.eerohele/tab {:git/tag "2024-09-27.371", :git/sha "c5d51f4"}}}'
```Then, in the REPL:
```clojure
user=> (require 'tab.auto)
Tab is listening on http://localhost:57426
nil
user=> (tap> BigInteger)
true
```Then, bask in the glory of the table that appears in your browser. If a tabulated `BigInteger` doesn't do it for you, there are [more examples available](#examples).
> **Note**
> In general, you'll probably want to use [`tab.api`](#api) instead of `tab.auto`. The only purpose of the `tab.auto` namespace is to make it as easy as possible to run a Tab.See the [user manual](#user-manual) for instructions of use.
To stop Tab:
```clojure
user=> (tab.auto/halt)
```The `tab.auto` namespace is the easiest way to run Tab. The `tab.api` namespace exposes the [API](#api) proper.
## API
Most importantly, there's `tab.api/run` and `tab.api/halt`:
```clojure
user=> (require '[tab.api :as tab])
nil
;; - Run a Tab in port 1234
;; - Don't open a browser by default.
;; - Set print length to 8
;; - Set print level to 2
user=> (def tab (tab/run :port 1234 :browse? false :print-length 8 :print-level 2))
#'user/tab
user=> (tab/halt tab)
nil
```See also:
```clojure
user=> (require '[tab.api :as tab])
nil
user=> (doc tab/run)
...
user=> (doc tab/tab>)
...
user=> (doc tab/address)
...
user=> (doc tab/halt)
...
```Only `tab.api` and `tab.auto` are part of Tab's public API. All other namespaces are internal and subject to change.
## User manual
- Click `-` to collapse a node.
- Click `+` to expand a node.
- Press Alt and click `-` or `+` to expand or collapse all nodes underneath a node.
- Click a table header (e.g. `ARRAY MAP`) to zoom in on that table.
- Press Alt and click a table header (e.g. `ARRAY MAP`) to copy the value backing that table to your clipboard.
- Click opaque objects (`#object[...]`) to view datafied versions of them (provided that they implement `clojure.core.protocols/Datafiable`).
- Click the text that says `$N vals` in the footer to empty Tab's in-memory database (and release values for garbage collection).
- Use the buttons in the footer to go to the next/previous value.
- Click the lightning icon in the footer to pause or resume page updates.## Examples
For more examples on what Tab can do, see [`repl/demo/intro.repl`](https://github.com/eerohele/tab/blob/main/repl/demo/intro.repl).
## Features
- Can make tables.
- Zero dependencies, apart from Clojure itself.
- [Prefers operating system theme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) (light or dark mode).## Limitations
- Can only make tables.
- Will blow up if you expand an infinite seq of scalars in a table cell with an ellipsis.
- You might be able to have Tab do a denial-of-service attack on itself if you Alt-click a node with _many_ children.
- Requires a modern browser to look good. If your browser supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter), you should be good.
- Might not work with Clojure versions older than 1.10.2.
- Untested on Windows. `:browse? true` [reportedly has no effect on Windows Subsystem for Linux 2, at least](https://github.com/eerohele/tab/issues/1).## Inspiration
- Gregoire, Daniel. (2018, November 30). [Tables Considered Helpful](https://www.youtube.com/watch?v=b5UK-VHbJlQ) (Clojure/conj 2018).
## Prior art / superior alternatives
- [Morse](https://github.com/nubank/morse)
- [Portal](https://djblue.github.io/portal/)
- [Reveal](https://vlaaad.github.io/reveal/)## Acknowledgements
- [My previous employer](https://www.solita.fi), for graciously sponsoring the development of this tool.
- [Nikita Prokopov](https://github.com/tonsky), for the [Alabaster Color Scheme](https://github.com/tonsky/sublime-scheme-alabaster).
- [Pedro Girardi](https://github.com/pedrorgirardi), for alpha testing and improvement ideas.