diff options
-rw-r--r-- | html/xhaddock.css | 27 | ||||
-rw-r--r-- | src/Haddock/Backends/Xhtml/Decl.hs | 34 | ||||
-rw-r--r-- | src/Haddock/Backends/Xhtml/Layout.hs | 5 |
3 files changed, 42 insertions, 24 deletions
diff --git a/html/xhaddock.css b/html/xhaddock.css index ae2d2121..e0a4922a 100644 --- a/html/xhaddock.css +++ b/html/xhaddock.css @@ -206,9 +206,9 @@ div.top h5 { .src { - padding: 3px; - background-color: #f0f0f0; - font-family: monospace; + padding: 3px; + background-color: #f0f0f0; + font-family: monospace; margin-bottom: 0; } @@ -261,10 +261,31 @@ div.subs { margin-left: 0; } +.arguments .caption, .fields .caption { display: none; } +/* need extra .subs in the selector to make it override the rules for .subs and .subs table */ + +.subs.arguments { + margin: 0; +} + +.subs.arguments table { + border-spacing: 0; + margin-top: 0; + margin-bottom: 0; +} + +.subs.arguments td.src { + white-space: nowrap; +} + +.subs.arguments + p { + margin-top: 0; +} + p.arg { margin-bottom: 0; } diff --git a/src/Haddock/Backends/Xhtml/Decl.hs b/src/Haddock/Backends/Xhtml/Decl.hs index ffee5bd7..f5aa4fcf 100644 --- a/src/Haddock/Backends/Xhtml/Decl.hs +++ b/src/Haddock/Backends/Xhtml/Decl.hs @@ -67,40 +67,32 @@ ppTypeOrFunSig summary links loc docname typ (doc, argDocs) (pref1, pref2, sep) | summary = declElem pref1 | Map.null argDocs = topDeclElem links loc docname pref1 +++ maybeDocToHtml doc | otherwise = topDeclElem links loc docname pref2 +++ - (vanillaTable << ( - do_args 0 sep typ </> - (case doc of - Just d -> ndocBox (docToHtml d) - Nothing -> emptyTable) - )) + subArguments (do_args 0 sep typ) +++ maybeDocToHtml doc where - argDocHtml n = case Map.lookup n argDocs of - Just adoc -> docToHtml adoc - Nothing -> noHtml + argDoc n = Map.lookup n argDocs do_largs n leader (L _ t) = do_args n leader t - do_args :: Int -> Html -> (HsType DocName) -> HtmlTable + do_args :: Int -> Html -> (HsType DocName) -> [SubDecl] do_args n leader (HsForAllTy Explicit tvs lctxt ltype) - = (argBox ( - leader <+> + = (leader <+> hsep (forallSymbol unicode : ppTyVars tvs ++ [dot]) <+> - ppLContextNoArrow lctxt unicode) - <-> rdocBox noHtml) </> - do_largs n (darrow unicode) ltype + ppLContextNoArrow lctxt unicode, + Nothing, []) + : do_largs n (darrow unicode) ltype do_args n leader (HsForAllTy Implicit _ lctxt ltype) | not (null (unLoc lctxt)) - = (argBox (leader <+> ppLContextNoArrow lctxt unicode) - <-> rdocBox noHtml) </> - do_largs n (darrow unicode) ltype + = (leader <+> ppLContextNoArrow lctxt unicode, + Nothing, []) + : do_largs n (darrow unicode) ltype -- if we're not showing any 'forall' or class constraints or -- anything, skip having an empty line for the context. | otherwise = do_largs n leader ltype do_args n leader (HsFunTy lt r) - = (argBox (leader <+> ppLFunLhType unicode lt) <-> rdocBox (argDocHtml n)) - </> do_largs (n+1) (arrow unicode) r + = (leader <+> ppLFunLhType unicode lt, argDoc n, []) + : do_largs (n+1) (arrow unicode) r do_args n leader t - = argBox (leader <+> ppType unicode t) <-> rdocBox (argDocHtml n) + = (leader <+> ppType unicode t, argDoc n, []) : [] ppTyVars :: [LHsTyVarBndr DocName] -> [Html] diff --git a/src/Haddock/Backends/Xhtml/Layout.hs b/src/Haddock/Backends/Xhtml/Layout.hs index 3c695042..440d8e1e 100644 --- a/src/Haddock/Backends/Xhtml/Layout.hs +++ b/src/Haddock/Backends/Xhtml/Layout.hs @@ -20,6 +20,7 @@ module Haddock.Backends.Xhtml.Layout ( divTopDecl, SubDecl, + subArguments, subConstructors, subFields, topDeclElem, declElem, @@ -98,6 +99,10 @@ subTable decls = Just $ table << aboves (concatMap subRow decls) td << nonEmpty (fmap docToHtml mdoc)) : map (cell . (td <<)) subs + +subArguments :: [(Html, Maybe (Doc DocName), [Html])] -> Html +subArguments = divSubDecls "arguments" "Arguments" . subTable + subConstructors :: [(Html, Maybe (Doc DocName), [Html])] -> Html subConstructors = divSubDecls "constructors" "Constructors" . subTable |