forked from jgm/pandoc-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-diagram.hs
30 lines (26 loc) · 1.12 KB
/
make-diagram.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE OverloadedStrings #-}
import Text.Pandoc
import Text.Pandoc.Class
import Data.List
import qualified Data.Text.IO as TIO
import qualified Data.Text as T
main = do
TIO.putStrLn "digraph Pandoc {"
TIO.putStrLn "rankdir=LR;"
TIO.putStrLn "ranksep=10;"
TIO.putStrLn "bgcolor=\"white\";"
let rs = [r | r <- map fst (readers :: [(T.Text, Reader PandocIO)]) , r /= "native"]
let ws = [w | w <- map fst (writers :: [(T.Text, Writer PandocIO)]) , w /= "native"]
TIO.putStrLn $ "{rank=same; " <> T.unwords [r <> "reader" | r <- rs] <> ";}"
-- TIO.putStrLn $ "{rank=same; " <> T.unwords [w <> "writer" | w <- ws] <> ";}"
TIO.putStrLn $ T.unlines [readernode r | r <- rs]
TIO.putStrLn $ T.unlines [writernode w | w <- ws]
TIO.putStrLn $ T.unlines $ [T.unwords [r <> "reader", "->", w <> "writer", " [color=\"gray\"]", ";"]
| r <- rs, w <- ws]
TIO.putStrLn "}"
readernode r =
r <> "reader [label=" <> r <> ", fontsize=14, width=" <> wid <> ", height=" <> hgt <> "];"
writernode r =
r <> "writer [label=" <> r <> ", fontsize=14, width=" <> wid <> ", height=" <> hgt <> "];"
wid = "2"
hgt = "1"