Something went wrong. Try again.
Newt - a dependent typed programming language
This is a mirror of the main github repository. newt.cloakedarrow.com
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233#!/bin/bash
# The first pass of this was LLM generated for expediency
# scan the src directory for *.newt files# match lines like `import Foo.Bar.Baz`# use graphviz to create a dependency graph in a pdf file
SRC_DIR="/Users/dunham/prj/newt/src"OUTPUT_FILE="/Users/dunham/prj/newt/dependency_graph.pdf"
TEMP_FILE=$(mktemp)trap 'rm -f "$TEMP_FILE"' EXIT
echo "digraph dependencies {" > "$TEMP_FILE"
# GPT4 did the first version of this, I wasn't familiar with "read"find "$SRC_DIR" -name "*.newt" | while read -r file; do grep -Eo '^import [A-Za-z0-9.]+' "$file" | egrep -v 'Prelude|Data' | while read -r line; do module=$(echo "$file" | sed "s|$SRC_DIR/||; s|/|.|g; s|.newt$||") imported_module=$(echo "$line" | awk '{print $2}') echo " \"$module\" -> \"$imported_module\";" >> "$TEMP_FILE" donedone
# End the graphviz dot fileecho "}" >> "$TEMP_FILE"
# Generate the PDF using dotdot -Tpdf "$TEMP_FILE" -o "$OUTPUT_FILE"
echo "Dependency graph created at $OUTPUT_FILE"