diff options
author | Joey Hess <joey@kitenet.net> | 2011-02-04 00:36:36 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-02-04 00:36:36 -0400 |
commit | 30869187f0890f9e742b4a5dbb4579b0fca6f7e4 (patch) | |
tree | d5941ba504e3de85470976b7267a8c1b764ededa /Dot.hs | |
parent | 926df3d91ec29f35e2cdf3df0d286721f40b9cbf (diff) |
improve output
Diffstat (limited to 'Dot.hs')
-rw-r--r-- | Dot.hs | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -9,7 +9,7 @@ module Dot where -- import qualified {- generates a graph description from a list of lines -} graph :: [String] -> String -graph s = unlines $ [header] ++ map formatLine s ++ [footer] +graph s = unlines $ [header] ++ map indent s ++ [footer] where header = "digraph map {" footer= "}" @@ -20,7 +20,7 @@ graphNode nodeid desc = label desc $ quote nodeid {- an edge between two nodes -} graphEdge :: String -> String -> Maybe String -> String -graphEdge fromid toid desc = +graphEdge fromid toid desc = indent $ case desc of Nothing -> edge Just d -> label d edge @@ -43,14 +43,15 @@ fillColor color s = attr "fillcolor" color $ attr "style" "filled" $ s {- apply to graphNode to put the node in a labeled box -} subGraph :: String -> String -> String -> String subGraph subid l s = - "subgraph " ++ name ++ "{\n\t" ++ setlabel ++ "\n\t\t" ++ s ++ "\n\t}" + "subgraph " ++ name ++ " {\n" ++ ii setlabel ++ ii s ++ indent "}" where -- the "cluster_" makes dot draw a box name = quote ("cluster_" ++ subid) - setlabel = formatLine $ "label=" ++ quote l + setlabel = "label=" ++ quote l + ii x = (indent $ indent x) ++ "\n" -formatLine :: String -> String -formatLine s = "\t" ++ s ++ ";" +indent ::String -> String +indent s = "\t" ++ s quote :: String -> String quote s = "\"" ++ s' ++ "\"" |