From 30869187f0890f9e742b4a5dbb4579b0fca6f7e4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Feb 2011 00:36:36 -0400 Subject: improve output --- Dot.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Dot.hs') diff --git a/Dot.hs b/Dot.hs index 0507c638c..fcd0c19cc 100644 --- a/Dot.hs +++ b/Dot.hs @@ -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' ++ "\"" -- cgit v1.2.3