nix: Add a script to generate a graph of Haskell imports (#1751)
This commit is contained in:
@@ -21,3 +21,4 @@ __pycache__
|
|||||||
*.tix
|
*.tix
|
||||||
coverage
|
coverage
|
||||||
.hpc
|
.hpc
|
||||||
|
imports.png
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
, checkedShellScript
|
, checkedShellScript
|
||||||
, devCabalOptions
|
, devCabalOptions
|
||||||
, entr
|
, entr
|
||||||
|
, graphviz
|
||||||
, silver-searcher
|
, silver-searcher
|
||||||
, style
|
, style
|
||||||
, tests
|
, tests
|
||||||
@@ -96,6 +97,41 @@ let
|
|||||||
${style}/bin/postgrest-lint
|
${style}/bin/postgrest-lint
|
||||||
${style}/bin/postgrest-style-check
|
${style}/bin/postgrest-style-check
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
importsgraph =
|
||||||
|
checkedShellScript
|
||||||
|
{
|
||||||
|
name = "postgrest-importsgraph";
|
||||||
|
docs =
|
||||||
|
''
|
||||||
|
Render the imports between PostgREST modules as a graph.
|
||||||
|
|
||||||
|
Output is written to 'imports.png' in the root directory of the project.
|
||||||
|
'';
|
||||||
|
inRootDir = true;
|
||||||
|
}
|
||||||
|
''
|
||||||
|
imports=$(
|
||||||
|
grep -rE 'import .*PostgREST\.' src main \
|
||||||
|
| sed -E \
|
||||||
|
-e 's|/|\.|g' \
|
||||||
|
-e 's/(src|main)\.(.*)\.hs:import .*(PostgREST\.\S+)( .*)?/"\2" -> "\3"/'
|
||||||
|
)
|
||||||
|
|
||||||
|
labels=$(
|
||||||
|
grep -rE '^(--)?\s*Description\s*:' src main \
|
||||||
|
| sed -E \
|
||||||
|
-e 's|/|\.|g' \
|
||||||
|
-e 's/^(src|main)\.(.*)\.hs:(--)?\s*Description\s*:\s*(.*)$/"\2" [label="\2\\n\4"]/'
|
||||||
|
)
|
||||||
|
|
||||||
|
cat <<EOF | ${graphviz}/bin/dot -Tpng > imports.png
|
||||||
|
digraph {
|
||||||
|
$imports
|
||||||
|
$labels
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
buildEnv {
|
buildEnv {
|
||||||
name = "postgrest-devtools";
|
name = "postgrest-devtools";
|
||||||
@@ -106,5 +142,6 @@ buildEnv {
|
|||||||
run.bin
|
run.bin
|
||||||
clean.bin
|
clean.bin
|
||||||
check.bin
|
check.bin
|
||||||
|
importsgraph.bin
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user