aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Mitchell <unknown>2008-08-13 14:03:24 +0000
committerNeil Mitchell <unknown>2008-08-13 14:03:24 +0000
commit40c102adbf18e1575e9181866c76da8b55403ac7 (patch)
treea4e11d273ef6d201cd355daccbd1a110acbc8af5
parent0af6f7cf9895160b56c732ac77100e394c0dc27c (diff)
Generalise Hoogle.doc and add a docWith
-rw-r--r--src/Haddock/Backends/Hoogle.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Haddock/Backends/Hoogle.hs b/src/Haddock/Backends/Hoogle.hs
index dbbc0058..7d81fbab 100644
--- a/src/Haddock/Backends/Hoogle.hs
+++ b/src/Haddock/Backends/Hoogle.hs
@@ -158,12 +158,18 @@ ppCtor dat con = ldoc (con_doc con) ++ f (con_details con)
---------------------------------------------------------------------
-- DOCUMENTATION
-ldoc :: Maybe (LHsDoc Name) -> [String]
+ldoc :: Outputable o => Maybe (LHsDoc o) -> [String]
ldoc = doc . liftM unL
-doc :: Maybe (HsDoc Name) -> [String]
-doc Nothing = []
-doc (Just d) = "" : zipWith (++) ("-- | " : repeat "-- ") (showTags $ markup markupTag d)
+doc :: Outputable o => Maybe (HsDoc o) -> [String]
+doc = docWith ""
+
+
+docWith :: Outputable o => String -> Maybe (HsDoc o) -> [String]
+docWith [] Nothing = []
+docWith header d = ("":) $ zipWith (++) ("-- | " : repeat "-- ") $
+ [header | header /= ""] ++ ["" | header /= "" && isJust d] ++
+ maybe [] (showTags . markup markupTag) d
data Tag = TagL Char [Tags] | TagP Tags | TagPre Tags | TagInline String Tags | Str String
@@ -181,7 +187,7 @@ str a = [Str a]
-- or inlne for others (a,i,tt)
-- entities (&,>,<) should always be appropriately escaped
-markupTag :: DocMarkup Name [Tag]
+markupTag :: Outputable o => DocMarkup o [Tag]
markupTag = Markup {
markupParagraph = box TagP,
markupEmpty = str "",