aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/InterfaceFile.hs
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2017-12-26 17:13:14 +0200
committerAlexander Biehl <alexbiehl@gmail.com>2018-02-01 14:58:18 +0100
commit088b1993fb6c6ed014a95e93d7c07f68218c7777 (patch)
tree47d7c1c85657bf7670ff154ad9a9bc1d1538b0d0 /haddock-api/src/Haddock/InterfaceFile.hs
parent2e0d7aef60fbb17f29ffa1f363ffc423f31185fc (diff)
Grid Tables (#718)
* Add table examples * Add table types and adopt simple parser Simple parser is done by Giovanni Cappellotto (@potomak) in https://github.com/haskell/haddock/pull/577 It seems to support single fine full tables, so far from full RST-grid tables, but it's good start. Table type support row- and colspans, but obviously parser is lacking. Still TODO: - Latex backend. Should we use multirow package https://ctan.org/pkg/multirow?lang=en? - Hoogle backend: ? * Implement grid-tables * Refactor table parser * Add two ill-examples * Update CHANGES.md * Basic documentation for tables * Fix documentation example
Diffstat (limited to 'haddock-api/src/Haddock/InterfaceFile.hs')
-rw-r--r--haddock-api/src/Haddock/InterfaceFile.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/haddock-api/src/Haddock/InterfaceFile.hs b/haddock-api/src/Haddock/InterfaceFile.hs
index 76bcb4ae..bbd8d04e 100644
--- a/haddock-api/src/Haddock/InterfaceFile.hs
+++ b/haddock-api/src/Haddock/InterfaceFile.hs
@@ -459,6 +459,32 @@ instance Binary a => Binary (Header a) where
t <- get bh
return (Header l t)
+instance Binary a => Binary (Table a) where
+ put_ bh (Table h b) = do
+ put_ bh h
+ put_ bh b
+ get bh = do
+ h <- get bh
+ b <- get bh
+ return (Table h b)
+
+instance Binary a => Binary (TableRow a) where
+ put_ bh (TableRow cs) = put_ bh cs
+ get bh = do
+ cs <- get bh
+ return (TableRow cs)
+
+instance Binary a => Binary (TableCell a) where
+ put_ bh (TableCell i j c) = do
+ put_ bh i
+ put_ bh j
+ put_ bh c
+ get bh = do
+ i <- get bh
+ j <- get bh
+ c <- get bh
+ return (TableCell i j c)
+
instance Binary Meta where
put_ bh Meta { _version = v } = put_ bh v
get bh = (\v -> Meta { _version = v }) <$> get bh
@@ -542,6 +568,9 @@ instance (Binary mod, Binary id) => Binary (DocH mod id) where
put_ bh (DocMathDisplay x) = do
putByte bh 22
put_ bh x
+ put_ bh (DocTable x) = do
+ putByte bh 23
+ put_ bh x
get bh = do
h <- getByte bh
@@ -615,6 +644,9 @@ instance (Binary mod, Binary id) => Binary (DocH mod id) where
22 -> do
x <- get bh
return (DocMathDisplay x)
+ 23 -> do
+ x <- get bh
+ return (DocTable x)
_ -> error "invalid binary data found in the interface file"