2020-06-08 03:29:51 +03:00
|
|
|
#!/usr/bin/env fq -rnf
|
|
|
|
|
2022-02-02 21:39:33 +03:00
|
|
|
def color:
|
2022-06-13 19:49:30 +03:00
|
|
|
tomd5 | [.[range(3)]] | map(band(.; 0x7f)+60 | toradix(16) | "0"[length:]+.) | join("");
|
2022-02-02 21:39:33 +03:00
|
|
|
|
2020-06-08 03:29:51 +03:00
|
|
|
def _formats_dot:
|
|
|
|
def _record($title; $fields):
|
|
|
|
[ "<"
|
|
|
|
, "<table bgcolor=\"paleturquoise\" border=\"0\" cellspacing=\"0\">"
|
2022-02-27 02:45:31 +03:00
|
|
|
, "<tr><td port=\"\($title)\"><font point-size=\"20\">\($title)</font></td></tr>"
|
2020-06-08 03:29:51 +03:00
|
|
|
, [$fields | flatten | map("<tr><td align=\"left\" bgcolor=\"lightgrey\" port=\"\(.)\">\(.)</td></tr>")]
|
|
|
|
, "</table>"
|
|
|
|
, ">"
|
|
|
|
] | flatten | join("");
|
|
|
|
( "# ... | dot -Tsvg -o formats.svg"
|
|
|
|
, "digraph formats {"
|
2022-02-27 02:45:31 +03:00
|
|
|
, " nodesep=0.2"
|
|
|
|
, " ranksep=1"
|
2020-06-08 03:29:51 +03:00
|
|
|
, " rankdir=TB"
|
2022-02-02 21:39:33 +03:00
|
|
|
, " node [penwidth=2 shape=\"none\" style=\"\"]"
|
|
|
|
, " edge [penwidth=2]"
|
2020-06-08 03:29:51 +03:00
|
|
|
, ( .[]
|
|
|
|
| . as $f
|
|
|
|
| .dependencies
|
|
|
|
| flatten?
|
|
|
|
| .[]
|
2022-02-02 21:39:33 +03:00
|
|
|
| " \"\($f.name)\":\(.):e -> \(.):n [color=\"#\($f.name | color)\"]"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
, ( .[]
|
|
|
|
| .name as $name
|
|
|
|
| .groups[]?
|
2022-02-02 21:39:33 +03:00
|
|
|
| " \(.) -> \"\($name)\":\($name):n [color=\"#\(. | color)\"]"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
, ( to_entries[]
|
|
|
|
| " \(.key) [color=\"paleturquoise\", label=\(_record(.key; (.value.dependencies // [])))]"
|
|
|
|
)
|
|
|
|
, ( [.[].groups[]?]
|
|
|
|
| unique[]
|
2022-02-27 02:45:31 +03:00
|
|
|
| " \(.) [shape=\"record\",style=\"rounded,filled\",fontsize=\"25\"color=\"palegreen\"]"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
, "}"
|
|
|
|
);
|
|
|
|
|
|
|
|
formats | _formats_dot
|