2020-06-08 03:29:51 +03:00
|
|
|
#!/usr/bin/env fq -rnf
|
|
|
|
|
|
|
|
def _formats_dot:
|
|
|
|
def _record($title; $fields):
|
|
|
|
[ "<"
|
|
|
|
, "<table bgcolor=\"paleturquoise\" border=\"0\" cellspacing=\"0\">"
|
|
|
|
, "<tr><td port=\"\($title)\">\($title)</td></tr>"
|
|
|
|
, [$fields | flatten | map("<tr><td align=\"left\" bgcolor=\"lightgrey\" port=\"\(.)\">\(.)</td></tr>")]
|
|
|
|
, "</table>"
|
|
|
|
, ">"
|
|
|
|
] | flatten | join("");
|
|
|
|
( "# ... | dot -Tsvg -o formats.svg"
|
|
|
|
, "digraph formats {"
|
|
|
|
, " rankdir=TB"
|
2022-01-16 22:12:40 +03:00
|
|
|
, " node [shape=\"none\" style=\"\"]"
|
2020-06-08 03:29:51 +03:00
|
|
|
, ( .[]
|
|
|
|
| . as $f
|
|
|
|
| .dependencies
|
|
|
|
| flatten?
|
|
|
|
| .[]
|
2022-01-16 22:12:40 +03:00
|
|
|
| " \"\($f.name)\":\(.):e -> \(.):n"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
, ( .[]
|
|
|
|
| .name as $name
|
|
|
|
| .groups[]?
|
2022-01-16 22:12:40 +03:00
|
|
|
| " \(.) -> \"\($name)\":\($name):n"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
, ( to_entries[]
|
|
|
|
| " \(.key) [color=\"paleturquoise\", label=\(_record(.key; (.value.dependencies // [])))]"
|
|
|
|
)
|
|
|
|
, ( [.[].groups[]?]
|
|
|
|
| unique[]
|
|
|
|
| " \(.) [shape=\"record\",style=\"rounded,filled\",color=\"palegreen\"]"
|
|
|
|
)
|
|
|
|
, "}"
|
|
|
|
);
|
|
|
|
|
|
|
|
formats | _formats_dot
|