Permalink
Browse files

Merge pull request #2 from kurtharriger/master

Converted this into a leiningen plugin
  • Loading branch information...
2 parents 79fa21f + d0310da commit 179e21f7b79ff8fdebbf3b126ded1b2b84bd4664 @hiredman committed Apr 6, 2012
Showing with 44 additions and 16 deletions.
  1. +20 −4 README
  2. +5 −0 project.clj
  3. +19 −12 dep.clj → src/leiningen/depgraph.clj
View
24 README
@@ -2,7 +2,23 @@ trawls a directory of .clj files for namespace forms, and outputs a graph of
the information from those forms. the graph is in the graphviz dot language,
so you can run dot on it to get a nice svg out.
-example:
-if you have a checkout of ring in ~/ring/
-java clojure.main deps.clj ring/ ring.dot
-dot ring.dot -Tsvg -o ring.svg
+
+Installation:
+
+
+ lein plugin install org.clojars.kurtharriger/lein-depgraph 0.1.0
+
+Usage:
+
+ lein depgraph
+ open <projectname>.svg
+
+Dependencies:
+
+ graphviz
+
+ dot must be on your path to convert the .dot file to .svg file.
+
+ For OS X users, graphviz can be installed with homebrew
+ brew install graphviz
+
View
@@ -0,0 +1,5 @@
+(defproject org.clojars.kurtharriger/lein-depgraph "0.1.0"
+ :description "Generate a namespace dependency graph as an svg file"
+ :url "https://github.com/kurtharriger/clojure-dependency-grapher"
+;; :dependencies [[org.clojure/clojure "1.3.0"]]
+ :eval-in-leiningen true)
@@ -1,4 +1,6 @@
-(ns hiredman.deps)
+(ns leiningen.depgraph
+ "Generate a namespace dependency graph as an svg file"
+ (:use [clojure.java.shell :only [sh]]))
(defn ffile [file]
@@ -113,16 +115,21 @@
(fn [x]
(reduce str (map #(format "%s->%s;\n" (safe-name (first %)) (safe-name (second %))) x)))))
-
-(-> (first *command-line-args*) parse-directory
- ((partial remove (comp nil? first)))
- restructure
- (safe-name-and-label :java)
- (safe-name-and-label :clojure)
- edges
- dot
- ((fn [out]
- (binding [*out* (-> (second *command-line-args*) java.io.File. java.io.FileWriter.)]
- (println out)))))
+(defn depgraph
+ "Generate a namespace dependency graph as svg file"
+ [project]
+ (let [source-path (:source-path project "src")
+ dotfile (str (:name project) ".dot")
+ svgfile (str (:name project) ".svg")]
+ (-> source-path
+ parse-directory
+ ((partial remove (comp nil? first)))
+ restructure
+ (safe-name-and-label :java)
+ (safe-name-and-label :clojure)
+ edges
+ dot
+ ((partial spit dotfile)))
+ (sh "dot" "-Tsvg" (str "-o" svgfile ) dotfile) ))

0 comments on commit 179e21f

Please sign in to comment.