aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Backends/Xhtml/Layout.hs
diff options
context:
space:
mode:
authorMark Lentczner <markl@glyphic.com>2010-04-04 06:24:14 +0000
committerMark Lentczner <markl@glyphic.com>2010-04-04 06:24:14 +0000
commit1ea671418f3e6650bf6b30f5efb0a364f043093d (patch)
tree5c48448b4978baec31c64328bed64f32549701fb /src/Haddock/Backends/Xhtml/Layout.hs
parentf5f0af15b7feee9535c2e57afeeb7018231063f4 (diff)
all decls now generate Html not HtmlTable
- ppDecl return Html, and so now do all of the functions it calls - added some internal tables to some decls, which is wrong, and will have to be fixed - decl "Box" functions became "Elem" functions to make clear they aren't in a table anymore (see Layout.hs) - docBox went away, as only used in one place (and its days are numbered) - cleaned up logic in a number of places, removed dead code - added maybeDocToHtml which simplified a number of places in the code
Diffstat (limited to 'src/Haddock/Backends/Xhtml/Layout.hs')
-rw-r--r--src/Haddock/Backends/Xhtml/Layout.hs46
1 files changed, 16 insertions, 30 deletions
diff --git a/src/Haddock/Backends/Xhtml/Layout.hs b/src/Haddock/Backends/Xhtml/Layout.hs
index fa96049d..93ce0987 100644
--- a/src/Haddock/Backends/Xhtml/Layout.hs
+++ b/src/Haddock/Backends/Xhtml/Layout.hs
@@ -24,12 +24,10 @@ import FastString ( unpackFS )
import GHC
-declWithDoc :: Bool -> LinksInfo -> SrcSpan -> DocName -> Maybe (Doc DocName) -> Html -> HtmlTable
-declWithDoc True _ _ _ _ html_decl = declBox html_decl
-declWithDoc False links loc nm Nothing html_decl = topDeclBox links loc nm html_decl
-declWithDoc False links loc nm (Just doc) html_decl =
- topDeclBox links loc nm html_decl </> docBox (docToHtml doc)
-
+declWithDoc :: Bool -> LinksInfo -> SrcSpan -> DocName -> Maybe (Doc DocName) -> Html -> Html
+declWithDoc True _ _ _ _ html_decl = declElem html_decl
+declWithDoc False links loc nm doc html_decl =
+ topDeclElem links loc nm html_decl +++ maybeDocToHtml doc
{-
@@ -38,36 +36,27 @@ text = strAttr "TEXT"
-}
-- a box for displaying code
-declBox :: Html -> HtmlTable
-declBox html = tda [theclass "decl"] << html
+declElem :: Html -> Html
+declElem = paragraph ! [theclass "decl"]
-- a box for top level documented names
-- it adds a source and wiki link at the right hand side of the box
-topDeclBox :: LinksInfo -> SrcSpan -> DocName -> Html -> HtmlTable
-topDeclBox ((_,_,Nothing), (_,_,Nothing)) _ _ html = declBox html
-topDeclBox ((_,_,maybe_source_url), (_,_,maybe_wiki_url))
- loc name html =
- tda [theclass "topdecl"] <<
- ( table ! [theclass "declbar"] <<
- ((tda [theclass "declname"] << html)
- <-> srcLink
- <-> wikiLink)
- )
+topDeclElem :: LinksInfo -> SrcSpan -> DocName -> Html -> Html
+topDeclElem ((_,_,maybe_source_url), (_,_,maybe_wiki_url)) loc name html =
+ declElem << (html +++ srcLink +++ wikiLink)
where srcLink =
case maybe_source_url of
- Nothing -> emptyTable
- Just url -> tda [theclass "declbut"] <<
- let url' = spliceURL (Just fname) (Just origMod)
+ Nothing -> noHtml
+ Just url -> let url' = spliceURL (Just fname) (Just origMod)
(Just n) (Just loc) url
- in anchor ! [href url'] << toHtml "Source"
+ in anchor ! [href url', theclass "link"] << "Source"
wikiLink =
case maybe_wiki_url of
- Nothing -> emptyTable
- Just url -> tda [theclass "declbut"] <<
- let url' = spliceURL (Just fname) (Just mdl)
+ Nothing -> noHtml
+ Just url -> let url' = spliceURL (Just fname) (Just mdl)
(Just n) (Just loc) url
- in anchor ! [href url'] << toHtml "Comments"
+ in anchor ! [href url', theclass "link"] << "Comments"
-- For source links, we want to point to the original module,
-- because only that will have the source.
@@ -81,16 +70,13 @@ topDeclBox ((_,_,maybe_source_url), (_,_,maybe_wiki_url))
fname = unpackFS (srcSpanFile loc)
+
-- a box for displaying an 'argument' (some code which has text to the
-- right of it). Wrapping is not allowed in these boxes, whereas it is
-- in a declBox.
argBox :: Html -> HtmlTable
argBox html = tda [theclass "arg"] << html
--- a box for displaying documentation,
--- indented and with a little padding at the top
-docBox :: Html -> HtmlTable
-docBox html = tda [theclass "doc"] << html
-- a box for displaying documentation, not indented.
ndocBox :: Html -> HtmlTable