aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2010-07-14 08:49:21 +0000
committerSimon Marlow <marlowsd@gmail.com>2010-07-14 08:49:21 +0000
commit8a74f84ddfa0b6255790daf1a07e77fa0aa1514a (patch)
tree9d1d6d97c22efefc5efc5963a1ab31b227e2c399 /src/Haddock
parent06cfd96e5597d9eed57de37ffacf46d893938bc1 (diff)
common up code for instance rendering
Diffstat (limited to 'src/Haddock')
-rw-r--r--src/Haddock/Backends/LaTeX.hs26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/Haddock/Backends/LaTeX.hs b/src/Haddock/Backends/LaTeX.hs
index b9615fc6..e349e594 100644
--- a/src/Haddock/Backends/LaTeX.hs
+++ b/src/Haddock/Backends/LaTeX.hs
@@ -496,14 +496,24 @@ ppClassDecl instances loc mbDoc subdocs
-- atTable = abovesSep s8 $ [ ppAssocType summary links doc at unicode | at <- ats
-- , let doc = lookupAnySubdoc (tcdName $ unL at) subdocs ]
- instancesBit
- | null instances = empty
- | all (isNothing . snd) instances =
- declWithDoc (vcat (map (ppInstDecl unicode) (map fst instances))) Nothing
- | otherwise = vcat (map (ppDocInstance unicode) instances)
+ instancesBit = ppDocInstances unicode instances
ppClassDecl _ _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl"
+ppDocInstances :: Bool -> [DocInstance DocName] -> LaTeX
+ppDocInstances unicode [] = empty
+ppDocInstances unicode (i : rest)
+ | Just ihead <- isUndocdInstance i
+ = declWithDoc (vcat (map (ppInstDecl unicode) (ihead:is))) Nothing $$
+ ppDocInstances unicode rest'
+ | otherwise
+ = ppDocInstance unicode i $$ ppDocInstances unicode rest
+ where
+ (is, rest') = spanWith isUndocdInstance rest
+
+isUndocdInstance :: DocInstance a -> Maybe (InstHead a)
+isUndocdInstance (i,Nothing) = Just i
+isUndocdInstance _ = Nothing
-- | Print a possibly commented instance. The instance header is printed inside
-- an 'argBox'. The comment is printed to the right of the box in normal comment
@@ -563,11 +573,7 @@ ppDataDecl instances subdocs _loc mbDoc dataDecl unicode
vcat (zipWith (ppSideBySideConstr subdocs unicode) leaders cons) $$
text "\\end{tabulary}\\par"
- instancesBit
- | null instances = empty
- | all (isNothing . snd) instances =
- declWithDoc (vcat (map (ppInstDecl unicode) (map fst instances))) Nothing
- | otherwise = vcat (map (ppDocInstance unicode) instances)
+ instancesBit = ppDocInstances unicode instances
-- ppConstrHdr is for (non-GADT) existentials constructors' syntax