aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Lentczner <markl@glyphic.com>2010-07-27 21:06:34 +0000
committerMark Lentczner <markl@glyphic.com>2010-07-27 21:06:34 +0000
commitb99698a292a1475d1b7c3f49b2a4fccb9994ca7c (patch)
treee44d2e33b05c75248c8d41348c79f105360c2ae0 /src
parentccb3be7d8d24eda2b5d871b96966049f2f1a7fc3 (diff)
give a class to empty dd elements so they can be hidden
Diffstat (limited to 'src')
-rw-r--r--src/Haddock/Backends/Xhtml.hs2
-rw-r--r--src/Haddock/Backends/Xhtml/DocMarkup.hs7
-rw-r--r--src/Haddock/Backends/Xhtml/Layout.hs8
-rw-r--r--src/Haddock/Backends/Xhtml/Utils.hs11
4 files changed, 15 insertions, 13 deletions
diff --git a/src/Haddock/Backends/Xhtml.hs b/src/Haddock/Backends/Xhtml.hs
index 7eb3180d..491ab9eb 100644
--- a/src/Haddock/Backends/Xhtml.hs
+++ b/src/Haddock/Backends/Xhtml.hs
@@ -186,7 +186,7 @@ bodyHtml doctitle iface themes
pageContent =
body << [
divPackageHeader << [
- sectionName << nonEmpty doctitle,
+ nonEmpty sectionName << doctitle,
unordList (catMaybes [
srcButton maybe_source_url iface,
wikiButton maybe_wiki_url (ifaceMod `fmap` iface),
diff --git a/src/Haddock/Backends/Xhtml/DocMarkup.hs b/src/Haddock/Backends/Xhtml/DocMarkup.hs
index 3ed36ed9..b1260a9c 100644
--- a/src/Haddock/Backends/Xhtml/DocMarkup.hs
+++ b/src/Haddock/Backends/Xhtml/DocMarkup.hs
@@ -90,8 +90,11 @@ rdrDocToHtml = markup fmt . cleanup
where fmt = parHtmlMarkup ppRdrName isRdrTc
-docElement :: (ADDATTRS a) => a -> a
-docElement = (! [theclass "doc"])
+docElement :: (Html -> Html) -> Html -> Html
+docElement el content_ =
+ if isNoHtml content_
+ then el ! [theclass "doc empty"] << spaceHtml
+ else el ! [theclass "doc"] << content_
docSection :: Doc DocName -> Html
diff --git a/src/Haddock/Backends/Xhtml/Layout.hs b/src/Haddock/Backends/Xhtml/Layout.hs
index 9e45b812..02146476 100644
--- a/src/Haddock/Backends/Xhtml/Layout.hs
+++ b/src/Haddock/Backends/Xhtml/Layout.hs
@@ -117,11 +117,7 @@ subDlist decls = Just $ dlist << map subEntry decls +++ clearDiv
subEntry (decl, mdoc, subs) =
dterm ! [theclass "src"] << decl
+++
- docElement ddef << (fmap docToHtml mdoc `with` subs)
-
- Nothing `with` [] = spaceHtml
- ma `with` bs = ma +++ bs
-
+ docElement ddef << (fmap docToHtml mdoc +++ subs)
clearDiv = thediv ! [ theclass "clear" ] << noHtml
@@ -132,7 +128,7 @@ subTable decls = Just $ table << aboves (concatMap subRow decls)
subRow (decl, mdoc, subs) =
(td ! [theclass "src"] << decl
<->
- docElement td << nonEmpty (fmap docToHtml mdoc))
+ docElement td << fmap docToHtml mdoc)
: map (cell . (td <<)) subs
diff --git a/src/Haddock/Backends/Xhtml/Utils.hs b/src/Haddock/Backends/Xhtml/Utils.hs
index 30abfdcd..edb5e659 100644
--- a/src/Haddock/Backends/Xhtml/Utils.hs
+++ b/src/Haddock/Backends/Xhtml/Utils.hs
@@ -113,10 +113,13 @@ char :: Char -> Html
char c = toHtml [c]
--- | Ensure content contains at least something (a non-breaking space)
-nonEmpty :: (HTML a) => a -> Html
-nonEmpty a = if isNoHtml h then spaceHtml else h
- where h = toHtml a
+-- | Make an element that always has at least something (a non-breaking space)
+-- If it would have otherwise been empty, then give it the class ".empty"
+nonEmpty :: (Html -> Html) -> Html -> Html
+nonEmpty el content_ =
+ if isNoHtml content_
+ then el ! [theclass "empty"] << spaceHtml
+ else el << content_
quote :: Html -> Html