diff options
author | Mark Lentczner <markl@glyphic.com> | 2010-07-13 05:26:21 +0000 |
---|---|---|
committer | Mark Lentczner <markl@glyphic.com> | 2010-07-13 05:26:21 +0000 |
commit | 16c666804946a08870926f25205117104625b72e (patch) | |
tree | 17e979d1ab136b28168b6ea457879c804c48adf5 | |
parent | 92eb93b4d7ede4a28aff90a1697951c6aef093cf (diff) |
change to new page structure
-rw-r--r-- | html/xhaddock.css | 97 | ||||
-rw-r--r-- | src/Haddock/Backends/Xhtml.hs | 59 | ||||
-rw-r--r-- | src/Haddock/Backends/Xhtml/Layout.hs | 36 | ||||
-rw-r--r-- | src/Haddock/Backends/Xhtml/Util.hs | 7 |
4 files changed, 130 insertions, 69 deletions
diff --git a/html/xhaddock.css b/html/xhaddock.css index 3bb95166..f1c149b5 100644 --- a/html/xhaddock.css +++ b/html/xhaddock.css @@ -18,13 +18,18 @@ a:hover { background-color: #e0e0ff; text-decoration: none } /* <tt> font is a little too small in MSIE */ tt { font-size: 100%; } pre { font-size: 100%; } -span.keyword { text-decoration: underline; } +.keyword { text-decoration: underline; } +.caption { + font-weight: bold; + margin: 0; + padding: 0; +} h1 { padding-top: 15px; font-weight: bold; - font-size: 150% - } + font-size: 150%; +} h2 { padding-top: 10px; @@ -43,6 +48,11 @@ h4, h5 { font-size: 100% } +h1, h2, h3, h4, h5 { + margin-top: 0.5em; + margin-bottom: 0.5em; +} + p { padding-top: 2px; padding-left: 10px; @@ -66,12 +76,8 @@ h2 + p, h3 + p, h4 + p { margin-top: 1em; } -p.caption { - margin: 0; - padding: 0; -} -div.package-header { +#package-header { color: #ffffff; padding: 5px 5px 5px 31px; margin: 0 0 1px; @@ -79,10 +85,10 @@ div.package-header { position: relative; } -div.package-header a:link { color: #ffffff } -div.package-header a:visited { color: #ffff00 } -div.package-header a:hover { background-color: #6060ff; } -div.package-header ul.links li:hover { background-color: #6060ff; } +#package-header a:link { color: #ffffff } +#package-header a:visited { color: #ffff00 } +#package-header a:hover { background-color: #6060ff; } +#package-header ul.links li:hover { background-color: #6060ff; } ul.links { list-style: none; @@ -102,17 +108,18 @@ ul.links li { padding: 1px 5px; } -div.module-header { +#module-header { background-color: #0077dd; padding: 5px; position: relative; - height: 3em; } -div.module-header p { +#module-header .caption { font-size: 200%; height: 1.5em; padding-top: .25em; + font-weight: normal; + font-style: normal; } dl.info { @@ -135,63 +142,71 @@ dl.info dd { padding-left: 6em; } -div.table-of-contents { +#table-of-contents { margin-top: 1em; - margin-bottom: 1em; + margin-bottom: 2em; } -div.table-of-contents p { - font-weight: bold; -} - -div.table-of-contents ul { +#table-of-contents ul { margin-top: 1em; margin-bottom: 1em; - margin-left: 10px; + margin-left: 0; list-style-type: none; + padding: 0; +} + +#table-of-contents ul ul { + margin-left: 2.5em; +} + +#description .caption, +#synopsis .caption { + padding-top: 15px; + font-weight: bold; + font-size: 150% } -ul.synopsis { - margin-left: 0px; +#synopsis { + margin-bottom: 2em; } -ul.synopsis p.decl { +#synopsis p.src { padding: 0; } -ul.synopsis li { +#synopsis li { background-color: #f0f0f0; font-family: monospace; vertical-align: top; - margin-top: 6px; - margin-bottom: 6px; + margin-top: 8px; + margin-bottom: 8px; padding: 3px; list-style-type: none; } -ul.synopsis li ul { +#synopsis ul { margin: 0; padding-top: 0; } -ul.synopsis li ul li { +#synopsis li ul li { margin: 3px; padding: 0; } -div.decldoc { +div.top { margin-top: 1em; } -div.decldoc h5 { +div.top h5 { margin-left: 10px; } -div.decldoc table, div.subdecl { +div.top table, div.subdecl { margin-left: 20px; } -p.decl { +.src { padding: 3px; background-color: #f0f0f0; font-family: monospace; @@ -199,7 +214,7 @@ p.decl { } -p.decl a.link { +.src a.link { float: right; border-left-width: 1px; border-left-color: #000099; @@ -256,25 +271,25 @@ td.rdoc p { -div.bottom { +#footer { background-color: #000099; color: #ffffff; padding: 4px } -div.bottom p { +#footer p { padding: 1px; margin: 0; } -div.bottom a:link { +#footer a:link { color: #ffffff; text-decoration: underline } -div.bottom a:visited { +#footer a:visited { color: #ffff00 } -div.bottom a:hover { +#footer a:hover { background-color: #6060ff } diff --git a/src/Haddock/Backends/Xhtml.hs b/src/Haddock/Backends/Xhtml.hs index c8a64ece..dc24acbd 100644 --- a/src/Haddock/Backends/Xhtml.hs +++ b/src/Haddock/Backends/Xhtml.hs @@ -152,7 +152,7 @@ copyHtmlBits odir libdir maybe_css = do footer :: Html footer = - thediv ! [theclass "bottom"] << paragraph << ( + divFooter << paragraph << ( "Produced by " +++ (anchor ! [href projectUrl] << toHtml projectName) +++ (" version " ++ projectVersion) @@ -194,8 +194,8 @@ simpleHeader :: String -> Maybe String -> Maybe String -> SourceURLs -> WikiURLs -> Html simpleHeader doctitle maybe_contents_url maybe_index_url maybe_source_url maybe_wiki_url = - thediv ! [theclass "package-header"] << ( - paragraph ! [theclass "caption"] << doctitle +++ + divPackageHeader << ( + sectionName << nonEmpty doctitle +++ unordList (catMaybes [ srcButton maybe_source_url Nothing, wikiButton maybe_wiki_url Nothing, @@ -210,8 +210,8 @@ pageHeader :: String -> Interface -> String pageHeader mdl iface doctitle maybe_source_url maybe_wiki_url maybe_contents_url maybe_index_url = - thediv ! [theclass "package-header"] << ( - paragraph ! [theclass "caption"] << (doctitle +++ spaceHtml) +++ + divPackageHeader << ( + sectionName << nonEmpty doctitle +++ unordList (catMaybes [ srcButton maybe_source_url (Just iface), wikiButton maybe_wiki_url (Just $ ifaceMod iface), @@ -219,8 +219,8 @@ pageHeader mdl iface doctitle indexButton maybe_index_url ]) ! [theclass "links"] ) +++ - thediv ! [theclass "module-header"] << ( - paragraph ! [theclass "caption"] << mdl +++ + divModuleHeader << ( + sectionName << mdl +++ moduleInfo iface ) @@ -606,8 +606,7 @@ ifaceToHtml maybe_source_url maybe_wiki_url iface unicode = ppModuleContents exports +++ description +++ synopsis +++ - maybe_doc_hdr +++ - bdy + divInterface (maybe_doc_hdr +++ bdy) where exports = numberSectionHeadings (ifaceRnExportItems iface) @@ -623,16 +622,18 @@ ifaceToHtml maybe_source_url maybe_wiki_url iface unicode description = case ifaceRnDoc iface of Nothing -> noHtml - Just doc -> h1 << toHtml "Description" +++ docToHtml doc + Just doc -> divDescription $ + sectionName << "Description" +++ docToHtml doc -- omit the synopsis if there are no documentation annotations at all synopsis | no_doc_at_all = noHtml | otherwise - = h1 << "Synopsis" +++ - unordList ( - mapMaybe (processExport True linksInfo unicode) exports - ) ! [theclass "synopsis"] + = divSynposis $ + sectionName << "Synopsis" +++ + shortDeclList ( + mapMaybe (processExport True linksInfo unicode) exports + ) -- if the documentation doesn't begin with a section header, then -- add one ("Documentation"). @@ -644,8 +645,7 @@ ifaceToHtml maybe_source_url maybe_wiki_url iface unicode bdy = foldr (+++) noHtml $ - map (thediv ! [theclass "decldoc"]) $ - mapMaybe (processExport False linksInfo unicode) exports + mapMaybe (processExport False linksInfo unicode) exports linksInfo = (maybe_source_url, maybe_wiki_url) @@ -702,8 +702,8 @@ ppModuleContents exports | null sections = noHtml | otherwise = contentsDiv where - contentsDiv = thediv ! [theclass "table-of-contents"] << ( - paragraph ! [theclass "caption"] << "Contents" +++ + contentsDiv = divTableOfContents << ( + sectionName << "Contents" +++ unordList sections) (sections, _leftovers{-should be []-}) = process 0 exports @@ -737,20 +737,28 @@ processExport :: Bool -> LinksInfo -> Bool -> (ExportItem DocName) -> Maybe Html processExport summary _ _ (ExportGroup lev id0 doc) = nothingIf summary $ groupTag lev << namedAnchor id0 << docToHtml doc processExport summary links unicode (ExportDecl decl doc subdocs insts) - = Just $ ppDecl summary links decl doc insts subdocs unicode -processExport _ _ _ (ExportNoDecl y []) - = Just $ ppDocName y -processExport _ _ _ (ExportNoDecl y subs) - = Just $ ppDocName y +++ parenList (map ppDocName subs) + = processDecl summary $ ppDecl summary links decl doc insts subdocs unicode +processExport summary _ _ (ExportNoDecl y []) + = processDeclOneLiner summary $ ppDocName y +processExport summary _ _ (ExportNoDecl y subs) + = processDeclOneLiner summary $ ppDocName y +++ parenList (map ppDocName subs) processExport summary _ _ (ExportDoc doc) = nothingIf summary $ docToHtml doc -processExport _ _ _ (ExportModule mdl) - = Just $ toHtml "module" <+> ppModule mdl "" +processExport summary _ _ (ExportModule mdl) + = processDeclOneLiner summary $ toHtml "module" <+> ppModule mdl "" nothingIf :: Bool -> a -> Maybe a nothingIf True _ = Nothing nothingIf False a = Just a +processDecl :: Bool -> Html -> Maybe Html +processDecl True = Just +processDecl False = Just . divTopDecl + +processDeclOneLiner :: Bool -> Html -> Maybe Html +processDeclOneLiner True = Just +processDeclOneLiner False = Just . divTopDecl . declElem + groupTag :: Int -> Html -> Html groupTag lev | lev == 1 = h1 @@ -760,4 +768,3 @@ groupTag lev - diff --git a/src/Haddock/Backends/Xhtml/Layout.hs b/src/Haddock/Backends/Xhtml/Layout.hs index ac6f5021..86c722b7 100644 --- a/src/Haddock/Backends/Xhtml/Layout.hs +++ b/src/Haddock/Backends/Xhtml/Layout.hs @@ -11,6 +11,14 @@ -- Portability : portable ----------------------------------------------------------------------------- module Haddock.Backends.Xhtml.Layout ( + divPackageHeader, divModuleHeader, divFooter, + divTableOfContents, divDescription, divSynposis, divInterface, + + sectionName, + + shortDeclList, + divTopDecl, + topDeclElem, declElem, instHdr, atHdr, methHdr, constrHdr, @@ -29,10 +37,36 @@ import Text.XHtml hiding ( name, title, p, quote ) import FastString ( unpackFS ) import GHC +-- Sections of the document + +divPackageHeader, divModuleHeader, divFooter :: Html -> Html +divPackageHeader = thediv ! [identifier "package-header"] +divModuleHeader = thediv ! [identifier "module-header"] +divFooter = thediv ! [identifier "footer"] + +divTableOfContents, divDescription, divSynposis, divInterface :: Html -> Html +divTableOfContents = thediv ! [identifier "table-of-contents"] +divDescription = thediv ! [identifier "description"] +divSynposis = thediv ! [identifier "synopsis"] +divInterface = thediv ! [identifier "interface"] + +-- | The name of a section, used directly after opening a section +sectionName :: Html -> Html +sectionName = paragraph ! [theclass "caption"] + + +-- | Declaration containers + +shortDeclList :: [Html] -> Html +shortDeclList items = ulist << map (li ! [theclass "src short"] <<) items + +divTopDecl :: Html -> Html +divTopDecl = thediv ! [theclass "top"] + -- a box for displaying code declElem :: Html -> Html -declElem = paragraph ! [theclass "decl"] +declElem = paragraph ! [theclass "src"] -- a box for top level documented names -- it adds a source and wiki link at the right hand side of the box diff --git a/src/Haddock/Backends/Xhtml/Util.hs b/src/Haddock/Backends/Xhtml/Util.hs index 9e13acd6..826b69f1 100644 --- a/src/Haddock/Backends/Xhtml/Util.hs +++ b/src/Haddock/Backends/Xhtml/Util.hs @@ -16,7 +16,7 @@ module Haddock.Backends.Xhtml.Util ( namedAnchor, linkedAnchor, spliceURL, - (<+>), char, empty, + (<+>), char, empty, nonEmpty, keyword, punctuate, braces, brackets, pabrackets, parens, parenList, ubxParenList, @@ -110,6 +110,11 @@ char c = toHtml [c] empty :: Html empty = noHtml +-- | 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 + quote :: Html -> Html quote h = char '`' +++ h +++ '`' |