From 9f2d1b933897a6330e5c8f9fa904e56ab40050ef Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Sat, 4 Aug 2018 11:51:30 -0400
Subject: Latex type families (#734)
* Support for type families in LaTeX
The code is ported over from the XHTML backend.
* Refactor XHTML and LaTeX family handling
This is mostly a consolidation effort: stripping extra exports,
inlining some short definitions, and trying to make the backends
match.
The LaTeX backend now has preliminary support for data families,
although the only the data instance head is printed (not the actual constructors).
Both backends also now use "newtype" for newtype data family
instances.
* Add some tests
---
haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 222 ++++++++++++-------------
1 file changed, 102 insertions(+), 120 deletions(-)
(limited to 'haddock-api/src/Haddock/Backends/Xhtml')
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
index cc271fef..12e65716 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
@@ -15,9 +15,7 @@
-----------------------------------------------------------------------------
module Haddock.Backends.Xhtml.Decl (
ppDecl,
-
- ppTyName, ppTyFamHeader, ppTypeApp, ppOrphanInstances,
- tyvarNames
+ ppOrphanInstances,
) where
import Haddock.Backends.Xhtml.DocMarkup
@@ -56,7 +54,7 @@ ppDecl :: Bool -- ^ print summary info only
-> Qualification
-> Html
ppDecl summ links (L loc decl) pats (mbDoc, fnArgsDoc) instances fixities subdocs splice unicode pkg qual = case decl of
- TyClD _ (FamDecl _ d) -> ppTyFam summ False links instances fixities loc mbDoc d splice unicode pkg qual
+ TyClD _ (FamDecl _ d) -> ppFamDecl summ False links instances fixities loc mbDoc d splice unicode pkg qual
TyClD _ d@(DataDecl {}) -> ppDataDecl summ links instances fixities subdocs loc mbDoc d pats splice unicode pkg qual
TyClD _ d@(SynDecl {}) -> ppTySyn summ links fixities loc (mbDoc, fnArgsDoc) d splice unicode pkg qual
TyClD _ d@(ClassDecl {}) -> ppClassDecl summ links instances fixities loc mbDoc subdocs d splice unicode pkg qual
@@ -67,7 +65,7 @@ ppDecl summ links (L loc decl) pats (mbDoc, fnArgsDoc) instances fixities subdoc
ForD _ d -> ppFor summ links loc (mbDoc, fnArgsDoc) d fixities splice unicode pkg qual
InstD _ _ -> noHtml
DerivD _ _ -> noHtml
- _ -> error "declaration not supported by ppDecl"
+ _ -> error "declaration not supported by ppDecl"
ppLFunSig :: Bool -> LinksInfo -> SrcSpan -> DocForDecl DocName ->
@@ -222,9 +220,6 @@ ppFixities fs qual = foldr1 (+++) (map ppFix uniq_fs) +++ rightEdge
ppTyVars :: Unicode -> Qualification -> [LHsTyVarBndr DocNameI] -> [Html]
ppTyVars unicode qual tvs = map (ppHsTyVarBndr unicode qual . unLoc) tvs
-tyvarNames :: LHsQTyVars DocNameI -> [Name]
-tyvarNames = map (getName . hsLTyVarName) . hsQTvExplicit
-
ppFor :: Bool -> LinksInfo -> SrcSpan -> DocForDecl DocName
-> ForeignDecl DocNameI -> [(DocName, Fixity)]
@@ -283,111 +278,111 @@ ppSimpleSig links splice unicode qual emptyCtxts loc names typ =
--------------------------------------------------------------------------------
-ppFamilyInfo :: Bool -> FamilyInfo DocNameI -> Html
-ppFamilyInfo assoc OpenTypeFamily
- | assoc = keyword "type"
- | otherwise = keyword "type family"
-ppFamilyInfo assoc DataFamily
- | assoc = keyword "data"
- | otherwise = keyword "data family"
-ppFamilyInfo _ (ClosedTypeFamily _) = keyword "type family"
-
-
-ppTyFamHeader :: Bool -> Bool -> FamilyDecl DocNameI
- -> Unicode -> Qualification -> Html
-ppTyFamHeader summary associated d@(FamilyDecl { fdInfo = info
- , fdResultSig = L _ result
- , fdInjectivityAnn = injectivity })
- unicode qual =
- (case info of
- OpenTypeFamily
- | associated -> keyword "type"
- | otherwise -> keyword "type family"
- DataFamily
- | associated -> keyword "data"
- | otherwise -> keyword "data family"
- ClosedTypeFamily _
- -> keyword "type family"
- ) <+>
-
- ppFamDeclBinderWithVars summary unicode qual d <+>
- ppResultSig result unicode qual <+>
-
- (case injectivity of
- Nothing -> noHtml
- Just (L _ injectivityAnn) -> ppInjectivityAnn unicode qual injectivityAnn
- ) <+>
-
- (case info of
- ClosedTypeFamily _ -> keyword "where ..."
- _ -> mempty
- )
-ppTyFamHeader _ _ (XFamilyDecl _) _ _ = panic "haddock;ppTyFamHeader"
-
-ppResultSig :: FamilyResultSig DocNameI -> Unicode -> Qualification -> Html
-ppResultSig result unicode qual = case result of
- NoSig _ -> noHtml
- KindSig _ kind -> dcolon unicode <+> ppLKind unicode qual kind
- TyVarSig _ (L _ bndr) -> equals <+> ppHsTyVarBndr unicode qual bndr
- XFamilyResultSig _ -> panic "haddock:ppResultSig"
-
-ppPseudoFamilyHeader :: Unicode -> Qualification -> PseudoFamilyDecl DocNameI
- -> Html
-ppPseudoFamilyHeader unicode qual (PseudoFamilyDecl { .. }) =
- ppFamilyInfo True pfdInfo <+>
- ppAppNameTypes (unLoc pfdLName) (map unLoc pfdTyVars) unicode qual <+>
- ppResultSig (unLoc pfdKindSig) unicode qual
-
-ppInjectivityAnn :: Bool -> Qualification -> InjectivityAnn DocNameI -> Html
-ppInjectivityAnn unicode qual (InjectivityAnn lhs rhs) =
- char '|' <+> ppLDocName qual Raw lhs <+> arrow unicode <+>
- hsep (map (ppLDocName qual Raw) rhs)
-
-
-ppTyFam :: Bool -> Bool -> LinksInfo -> [DocInstance DocNameI] ->
- [(DocName, Fixity)] -> SrcSpan -> Documentation DocName ->
- FamilyDecl DocNameI -> Splice -> Unicode -> Maybe Package ->
- Qualification -> Html
-ppTyFam summary associated links instances fixities loc doc decl splice unicode
- pkg qual
-
- | summary = ppTyFamHeader True associated decl unicode qual
+-- | Print a data\/type family declaration
+ppFamDecl :: Bool -- ^ is a summary
+ -> Bool -- ^ is an associated type
+ -> LinksInfo
+ -> [DocInstance DocNameI] -- ^ relevant instances
+ -> [(DocName, Fixity)] -- ^ relevant fixities
+ -> SrcSpan
+ -> Documentation DocName -- ^ this decl's documentation
+ -> FamilyDecl DocNameI -- ^ this decl
+ -> Splice -> Unicode -> Maybe Package -> Qualification -> Html
+ppFamDecl summary associated links instances fixities loc doc decl splice unicode pkg qual
+ | summary = ppFamHeader True associated decl unicode qual
| otherwise = header_ +++ docSection Nothing pkg qual doc +++ instancesBit
where
docname = unLoc $ fdLName decl
header_ = topDeclElem links loc splice [docname] $
- ppTyFamHeader summary associated decl unicode qual <+> ppFixities fixities qual
+ ppFamHeader summary associated decl unicode qual <+> ppFixities fixities qual
instancesBit
| FamilyDecl { fdInfo = ClosedTypeFamily mb_eqns } <- decl
, not summary
- = subEquations pkg qual $ map (ppTyFamEqn . unLoc) $ fromMaybe [] mb_eqns
+ = subEquations pkg qual $ map (ppFamDeclEqn . unLoc) $ fromMaybe [] mb_eqns
| otherwise
= ppInstances links (OriginFamily docname) instances splice unicode pkg qual
-- Individual equation of a closed type family
- ppTyFamEqn :: TyFamInstEqn DocNameI -> SubDecl
- ppTyFamEqn (HsIB { hsib_body = FamEqn { feqn_tycon = n, feqn_rhs = rhs
- , feqn_pats = ts } })
- = ( ppAppNameTypes (unLoc n) (map unLoc ts) unicode qual
+ ppFamDeclEqn :: TyFamInstEqn DocNameI -> SubDecl
+ ppFamDeclEqn (HsIB { hsib_body = FamEqn { feqn_tycon = L _ n
+ , feqn_rhs = rhs
+ , feqn_pats = ts } })
+ = ( ppAppNameTypes n (map unLoc ts) unicode qual
<+> equals <+> ppType unicode qual HideEmptyContexts (unLoc rhs)
- , Nothing, [] )
- ppTyFamEqn (XHsImplicitBndrs _) = panic "haddock:ppTyFam"
- ppTyFamEqn (HsIB { hsib_body = XFamEqn _}) = panic "haddock:ppTyFam"
-
+ , Nothing
+ , []
+ )
+ ppFamDeclEqn (XHsImplicitBndrs _) = panic "haddock:ppFamDecl"
+ ppFamDeclEqn (HsIB { hsib_body = XFamEqn _}) = panic "haddock:ppFamDecl"
-ppPseudoFamilyDecl :: LinksInfo -> Splice -> Unicode -> Qualification
- -> PseudoFamilyDecl DocNameI
- -> Html
-ppPseudoFamilyDecl links splice unicode qual
- decl@(PseudoFamilyDecl { pfdLName = L loc name, .. }) =
- wrapper $ ppPseudoFamilyHeader unicode qual decl
+-- | Print a pseudo family declaration
+ppPseudoFamDecl :: LinksInfo -> Splice
+ -> PseudoFamilyDecl DocNameI -- ^ this decl
+ -> Unicode -> Qualification -> Html
+ppPseudoFamDecl links splice
+ (PseudoFamilyDecl { pfdInfo = info
+ , pfdKindSig = L _ kindSig
+ , pfdTyVars = tvs
+ , pfdLName = L loc name })
+ unicode qual =
+ topDeclElem links loc splice [name] leader
+ where
+ leader = hsep [ ppFamilyLeader True info
+ , ppAppNameTypes name (map unLoc tvs) unicode qual
+ , ppResultSig kindSig unicode qual
+ ]
+
+-- | Print the LHS of a type\/data family declaration
+ppFamHeader :: Bool -- ^ is a summary
+ -> Bool -- ^ is an associated type
+ -> FamilyDecl DocNameI -- ^ family declaration
+ -> Unicode -> Qualification -> Html
+ppFamHeader _ _ (XFamilyDecl _) _ _ = panic "haddock;ppFamHeader"
+ppFamHeader summary associated (FamilyDecl { fdInfo = info
+ , fdResultSig = L _ result
+ , fdInjectivityAnn = injectivity
+ , fdLName = L _ name
+ , fdTyVars = tvs })
+ unicode qual =
+ hsep [ ppFamilyLeader associated info
+ , ppAppDocNameTyVarBndrs summary unicode qual name (hsq_explicit tvs)
+ , ppResultSig result unicode qual
+ , injAnn
+ , whereBit
+ ]
where
- wrapper = topDeclElem links loc splice [name]
+ whereBit = case info of
+ ClosedTypeFamily _ -> keyword "where ..."
+ _ -> noHtml
+
+ injAnn = case injectivity of
+ Nothing -> noHtml
+ Just (L _ (InjectivityAnn lhs rhs)) -> hsep ( keyword "|"
+ : ppLDocName qual Raw lhs
+ : arrow unicode
+ : map (ppLDocName qual Raw) rhs)
+
+-- | Print the keywords that begin the family declaration
+ppFamilyLeader :: Bool -> FamilyInfo DocNameI -> Html
+ppFamilyLeader assoc info = keyword (typ ++ if assoc then "" else " family")
+ where
+ typ = case info of
+ OpenTypeFamily -> "type"
+ ClosedTypeFamily _ -> "type"
+ DataFamily -> "data"
+
+-- | Print the signature attached to a family
+ppResultSig :: FamilyResultSig DocNameI -> Unicode -> Qualification -> Html
+ppResultSig result unicode qual = case result of
+ NoSig _ -> noHtml
+ KindSig _ kind -> dcolon unicode <+> ppLKind unicode qual kind
+ TyVarSig _ (L _ bndr) -> equals <+> ppHsTyVarBndr unicode qual bndr
+ XFamilyResultSig _ -> panic "haddock:ppResultSig"
--------------------------------------------------------------------------------
@@ -399,24 +394,9 @@ ppAssocType :: Bool -> LinksInfo -> DocForDecl DocName -> LFamilyDecl DocNameI
-> [(DocName, Fixity)] -> Splice -> Unicode -> Maybe Package
-> Qualification -> Html
ppAssocType summ links doc (L loc decl) fixities splice unicode pkg qual =
- ppTyFam summ True links [] fixities loc (fst doc) decl splice unicode pkg qual
+ ppFamDecl summ True links [] fixities loc (fst doc) decl splice unicode pkg qual
---------------------------------------------------------------------------------
--- * TyClDecl helpers
---------------------------------------------------------------------------------
-
--- | Print a type family and its variables
-ppFamDeclBinderWithVars :: Bool -> Unicode -> Qualification -> FamilyDecl DocNameI -> Html
-ppFamDeclBinderWithVars summ unicode qual (FamilyDecl { fdLName = lname, fdTyVars = tvs }) =
- ppAppDocNameTyVarBndrs summ unicode qual (unLoc lname) (hsq_explicit tvs)
-ppFamDeclBinderWithVars _ _ _ (XFamilyDecl _) = panic "haddock:ppFamDeclBinderWithVars"
-
--- | Print a newtype / data binder and its variables
-ppDataBinderWithVars :: Bool -> Unicode -> Qualification -> TyClDecl DocNameI -> Html
-ppDataBinderWithVars summ unicode qual decl =
- ppAppDocNameTyVarBndrs summ unicode qual (tcdName decl) (hsQTvExplicit $ tcdTyVars decl)
-
--------------------------------------------------------------------------------
-- * Type applications
--------------------------------------------------------------------------------
@@ -672,7 +652,9 @@ ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) m
, mdoc
, [subFamInstDetails iid pdecl mname])
where
- pdata = keyword "data" <+> typ
+ nd = dd_ND (tcdDataDefn dd)
+ pref = case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" }
+ pdata = pref <+> typ
pdecl = pdata <+> ppShortDataDecl False True dd [] unicode qual
where
mname = maybe noHtml (\m -> toHtml "Defined in" <+> ppModule m) mdl
@@ -684,9 +666,7 @@ ppInstanceAssocTys :: LinksInfo -> Splice -> Unicode -> Qualification
-> [PseudoFamilyDecl DocNameI]
-> [Html]
ppInstanceAssocTys links splice unicode qual =
- map ppFamilyDecl'
- where
- ppFamilyDecl' = ppPseudoFamilyDecl links splice unicode qual
+ map (\pseudo -> ppPseudoFamDecl links splice pseudo unicode qual)
ppInstanceSigs :: LinksInfo -> Splice -> Unicode -> Qualification
@@ -1060,10 +1040,12 @@ ppSideBySidePat fixities unicode qual lnames typ (doc, argDocs) =
-- | Print the LHS of a data\/newtype declaration.
-- Currently doesn't handle 'data instance' decls or kind signatures
ppDataHeader :: Bool -> TyClDecl DocNameI -> Unicode -> Qualification -> Html
-ppDataHeader summary decl@(DataDecl { tcdDataDefn =
- HsDataDefn { dd_ND = nd
- , dd_ctxt = ctxt
- , dd_kindSig = ks } })
+ppDataHeader summary (DataDecl { tcdDataDefn =
+ HsDataDefn { dd_ND = nd
+ , dd_ctxt = ctxt
+ , dd_kindSig = ks }
+ , tcdLName = L _ name
+ , tcdTyVars = tvs })
unicode qual
= -- newtype or data
(case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" })
@@ -1071,7 +1053,7 @@ ppDataHeader summary decl@(DataDecl { tcdDataDefn =
-- context
ppLContext ctxt unicode qual HideEmptyContexts <+>
-- T a b c ..., or a :+: b
- ppDataBinderWithVars summary unicode qual decl
+ ppAppDocNameTyVarBndrs summary unicode qual name (hsQTvExplicit tvs)
<+> case ks of
Nothing -> mempty
Just (L _ x) -> dcolon unicode <+> ppKind unicode qual x
@@ -1120,7 +1102,7 @@ ppHsTyVarBndr _ qual (UserTyVar _ (L _ name)) =
ppHsTyVarBndr unicode qual (KindedTyVar _ name kind) =
parens (ppDocName qual Raw False (unLoc name) <+> dcolon unicode <+>
ppLKind unicode qual kind)
-ppHsTyVarBndr _ _ (XTyVarBndr _) = error "haddock:ppHsTyVarBndr"
+ppHsTyVarBndr _ _ (XTyVarBndr _) = panic "haddock:ppHsTyVarBndr"
ppLKind :: Unicode -> Qualification -> LHsKind DocNameI -> Html
ppLKind unicode qual y = ppKind unicode qual (unLoc y)
--
cgit v1.2.3
From 6a7c5fef87106a92e710413259262ab2b1e78005 Mon Sep 17 00:00:00 2001
From: Nuno Alexandre
Date: Sat, 3 Feb 2018 21:39:30 +0100
Subject: Make the style consistent with hackage
Several things are addressed here:
- better responsive behaviour on the header
- better space usage
- consistent colors overall
- other nit PR comments
---
.../html/NewOcean.std-theme/new-ocean.css | 106 ++++++++++++---------
haddock-api/src/Haddock/Backends/Xhtml.hs | 4 +-
haddock-api/src/Haddock/Backends/Xhtml/Layout.hs | 4 +-
3 files changed, 66 insertions(+), 48 deletions(-)
(limited to 'haddock-api/src/Haddock/Backends/Xhtml')
diff --git a/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css b/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
index 4191c8b0..8a7fdf97 100644
--- a/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
+++ b/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
@@ -37,8 +37,8 @@ dd {
}
a { text-decoration: none; }
-a[href]:link { color: rgb(196,69,29); }
-a[href]:visited { color: rgb(171,105,84); }
+a[href]:link {color: #9C5791;}
+a[href]:visited {color: #5E3558;}
a[href]:hover { text-decoration:underline; }
a[href].def:link, a[href].def:visited { color: rgba(69, 59, 97, 0.8); }
@@ -57,45 +57,68 @@ body.js-enabled .hide-when-js-enabled {
/* @group responsive */
-@media only screen and (min-width: 950px) {
- #page-header {
- text-align: left;
- text-align: left;
- }
+#package-header .caption {
+ margin: 0px 1em 0 2em;
+}
+@media only screen and (min-width: 1280px) {
#content {
width: 60vw;
+ max-width: 1450px;
+ min-width: 830px;
}
+}
- #package-header .caption {
- margin: 0 0 0 20vw;
+@media only screen and (max-width: 1280px) {
+ #content {
+ width: 75vw;
}
+}
- ul.links {
- margin: 0px 20vw 0 0;
+@media only screen and (max-width: 950px) {
+ #content {
+ width: 88vw;
}
-
}
-@media only screen and (max-width: 950px) {
- #page-header {
- text-align: center;
+
+/* menu for wider screens
+
+ Display the package name at the left and the menu links at the right,
+ inline with each other:
+ The package name Source . Contents . Index
+*/
+@media only screen and (min-width: 1000px) {
+ #package-header .caption {
+ display: inline-block;
+ margin: 3px 1em 2px 2em;
}
- #content {
- width: 80vw;
+ #package-header ul.links {
+ float: right;
+ margin: 3px 2em 2px 1em;
}
+}
+/* menu for smaller screens
+
+Display the package name on top of the menu links and center both elements:
+ The package name
+ Source . Contents . Index
+*/
+@media only screen and (max-width: 1000px) {
#package-header .caption {
- margin: 0 0 0 10vw;
+ display: block;
+ margin: 4px 0;
+ text-align: center;
}
- ul.links {
- margin: 0px 10vw 0 0;
+ #package-header ul.links {
+ float: none;
+ text-align: center;
+ margin: 0.6em 0 0 0;
}
-}
-@media only screen and (max-width: 500px) {
#module-header table.info {
float: none;
top: 0;
@@ -107,6 +130,7 @@ body.js-enabled .hide-when-js-enabled {
/* @end */
+
/* @group Fonts & Sizes */
/* Basic technique & IE workarounds from YUI 3
@@ -115,7 +139,7 @@ body.js-enabled .hide-when-js-enabled {
*/
body {
- font: 300 13px/1.85 "Merriweather Sans", sans-serif;
+ font: 400 16px/1.6 'Open Sans', sans-serif;
*font-size:small; /* for IE */
*font:x-small; /* for IE in quirks mode */
}
@@ -150,18 +174,17 @@ pre, code, kbd, samp, tt, .src {
}
#module-header .caption sup {
- font-size: 70%;
+ font-size: 80%;
font-weight: normal;
}
+#package-header #page-menu a:link, #package-header #page-menu a:visited { color: white; }
+
+
.info {
font-size: 85%; /* 11pt */
}
-#table-of-contents, #synopsis {
- /* font-size: 85%; /* 11pt */
-}
-
/* @end */
@@ -169,11 +192,11 @@ pre, code, kbd, samp, tt, .src {
.caption, h1, h2, h3, h4, h5, h6, summary {
font-weight: bold;
- color: rgb(78,98,114);
- color: rgb(142, 80, 132);
+ color: #5E5184;
margin: 2em 0 1em 0;
}
+
* + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
margin-top: 2em;
}
@@ -190,15 +213,10 @@ ul + p {
margin-top: 2em;
}
-ul.links, #package-header p.caption {
- padding-top: 3px;
-}
-
ul.links {
list-style: none;
text-align: left;
- float: right;
- font-size: 13px;
+ font-size: 1em;
}
ul.links li {
@@ -258,7 +276,7 @@ details[open] > summary {
pre {
padding: 17px;
margin: 1em 0 2em 0;
- background-color: rgba(0, 0, 0, .025);
+ background-color: rgba(0, 0, 0, .033);
overflow: auto;
border-bottom: 0.25em solid white;
/* white border adds some space below the box to compensate
@@ -291,22 +309,21 @@ pre {
background: rgb(94, 81, 132);
border-bottom: 5px solid rgba(69, 59, 97, 0.5);
color: #ddd;
- padding: 8px 0;
+ padding: 0.6em 0 0.2em 0;
position: relative;
text-align: left;
margin: 0 auto;
+ overflow: hidden;
}
#package-header .caption {
- background: url(hslogo-16.png) no-repeat 0em;
color: white;
- font-weight: normal;
font-style: normal;
- padding-left: 35px;
+ font-size: 1.1rem;
+ font-weight: bold;
}
#module-header .caption {
- color: rgb(94, 81, 132);
font-weight: bold;
border-bottom: 1px solid #ddd;
}
@@ -414,11 +431,12 @@ div#style-menu-holder {
#synopsis {
display: block;
position: fixed;
- right: 0;
height: 80%;
- top: 10%;
+ top: 9vh;
+ right: 10px;
padding: 0;
max-width: 75%;
+ z-index: 1;
/* Ensure that synopsis covers everything (including MathJAX markup) */
z-index: 1;
}
diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs
index 0264b7f7..6f1f1f60 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml.hs
@@ -130,8 +130,8 @@ headHtml docTitle themes mathjax_url =
script ! [src mjUrl, thetype "text/javascript"] << noHtml
]
where
- fontUrl = "https://fonts.googleapis.com/css?family=Merriweather+Sans:300,300i,400,700"
- mjUrl = maybe "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" id mathjax_url
+ fontUrl = "https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700"
+ mjUrl = fromMaybe "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" mathjax_url
srcButton :: SourceURLs -> Maybe Interface -> Maybe Html
srcButton (Just src_base_url, _, _, _) Nothing =
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
index 1c44ffda..bdf989ed 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
@@ -74,8 +74,8 @@ sectionName = paragraph ! [theclass "caption"]
-- If it would have otherwise been empty, then give it the class ".empty".
nonEmptySectionName :: Html -> Html
nonEmptySectionName c
- | isNoHtml c = paragraph ! [theclass "caption empty"] $ spaceHtml
- | otherwise = paragraph ! [theclass "caption"] $ c
+ | isNoHtml c = thediv ! [theclass "caption empty"] $ spaceHtml
+ | otherwise = thediv ! [theclass "caption"] $ c
divPackageHeader, divContent, divModuleHeader, divFooter,
--
cgit v1.2.3
From 365c77dfc39a28e4b5fd7eaeb802edcc9df196f4 Mon Sep 17 00:00:00 2001
From: Nuno Alexandre
Date: Sat, 21 Apr 2018 16:25:56 +0200
Subject: Make package-header caption backward-compatible
The current html generator of this branch wraps the package-header
caption as a div, which does not work (without style adjustments) with
the old themes. Changing it from div to span does the trick, without
needing to adjust the old stylesheets.
---
haddock-api/src/Haddock/Backends/Xhtml/Layout.hs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'haddock-api/src/Haddock/Backends/Xhtml')
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
index bdf989ed..10a6d499 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
@@ -74,8 +74,8 @@ sectionName = paragraph ! [theclass "caption"]
-- If it would have otherwise been empty, then give it the class ".empty".
nonEmptySectionName :: Html -> Html
nonEmptySectionName c
- | isNoHtml c = thediv ! [theclass "caption empty"] $ spaceHtml
- | otherwise = thediv ! [theclass "caption"] $ c
+ | isNoHtml c = thespan ! [theclass "caption empty"] $ spaceHtml
+ | otherwise = thespan ! [theclass "caption"] $ c
divPackageHeader, divContent, divModuleHeader, divFooter,
--
cgit v1.2.3
From cd520e9907b9a56cae5a2e51413eef1522a37bbb Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Thu, 25 Oct 2018 20:16:46 -0700
Subject: Avoid more conflicts in generated ids (#954)
This fixes #953 by passing more names into the generated ids.
---
haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 16 ++-
html-test/ref/Bug953.html | 146 +++++++++++++++++++++++++
html-test/src/Bug953.hs | 17 +++
3 files changed, 173 insertions(+), 6 deletions(-)
create mode 100644 html-test/ref/Bug953.html
create mode 100644 html-test/src/Bug953.hs
(limited to 'haddock-api/src/Haddock/Backends/Xhtml')
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
index 12e65716..9df6acc0 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
@@ -122,12 +122,12 @@ ppTypeOrFunSig :: Bool -> LinksInfo -> SrcSpan -> [DocName] -> HsType DocNameI
ppTypeOrFunSig summary links loc docnames typ (doc, argDocs) (pref1, pref2, sep)
splice unicode pkg qual emptyCtxts
| summary = pref1
- | Map.null argDocs = topDeclElem links loc splice docnames pref1 +++ docSection curName pkg qual doc
+ | Map.null argDocs = topDeclElem links loc splice docnames pref1 +++ docSection curname pkg qual doc
| otherwise = topDeclElem links loc splice docnames pref2
+++ subArguments pkg qual (ppSubSigLike unicode qual typ argDocs [] sep emptyCtxts)
- +++ docSection curName pkg qual doc
+ +++ docSection curname pkg qual doc
where
- curName = getName <$> listToMaybe docnames
+ curname = getName <$> listToMaybe docnames
-- This splits up a type signature along `->` and adds docs (when they exist) to
@@ -290,10 +290,11 @@ ppFamDecl :: Bool -- ^ is a summary
-> Splice -> Unicode -> Maybe Package -> Qualification -> Html
ppFamDecl summary associated links instances fixities loc doc decl splice unicode pkg qual
| summary = ppFamHeader True associated decl unicode qual
- | otherwise = header_ +++ docSection Nothing pkg qual doc +++ instancesBit
+ | otherwise = header_ +++ docSection curname pkg qual doc +++ instancesBit
where
docname = unLoc $ fdLName decl
+ curname = Just $ getName docname
header_ = topDeclElem links loc splice [docname] $
ppFamHeader summary associated decl unicode qual <+> ppFixities fixities qual
@@ -528,9 +529,11 @@ ppClassDecl summary links instances fixities loc d subdocs
, tcdFDs = lfds, tcdSigs = lsigs, tcdATs = ats })
splice unicode pkg qual
| summary = ppShortClassDecl summary links decl loc subdocs splice unicode pkg qual
- | otherwise = classheader +++ docSection Nothing pkg qual d
+ | otherwise = classheader +++ docSection curname pkg qual d
+++ minimalBit +++ atBit +++ methodBit +++ instancesBit
where
+ curname = Just $ getName nm
+
sigs = map unLoc lsigs
classheader
@@ -759,10 +762,11 @@ ppDataDecl summary links instances fixities subdocs loc doc dataDecl pats
splice unicode pkg qual
| summary = ppShortDataDecl summary False dataDecl pats unicode qual
- | otherwise = header_ +++ docSection Nothing pkg qual doc +++ constrBit +++ patternBit +++ instancesBit
+ | otherwise = header_ +++ docSection curname pkg qual doc +++ constrBit +++ patternBit +++ instancesBit
where
docname = tcdName dataDecl
+ curname = Just $ getName docname
cons = dd_cons (tcdDataDefn dataDecl)
isH98 = case unLoc (head cons) of
ConDeclH98 {} -> True
diff --git a/html-test/ref/Bug953.html b/html-test/ref/Bug953.html
new file mode 100644
index 00000000..40b0f6a1
--- /dev/null
+++ b/html-test/ref/Bug953.html
@@ -0,0 +1,146 @@
+Bug953Documentation
data Foo #
A foo
Examples
Expand
Foo example body
data Bar #
A bar
Examples
Expand
Bar example body
\ No newline at end of file
diff --git a/html-test/src/Bug953.hs b/html-test/src/Bug953.hs
new file mode 100644
index 00000000..63f2c45a
--- /dev/null
+++ b/html-test/src/Bug953.hs
@@ -0,0 +1,17 @@
+module Bug953 where
+
+{- | A foo
+
+==== __Examples__
+
+Foo example body
+-}
+data Foo = Foo'
+
+{- | A bar
+
+==== __Examples__
+
+Bar example body
+-}
+data Bar = Bar'
--
cgit v1.2.3
From 8a491e437f1c8379b66a420f8584c1761b45aa7e Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Mon, 5 Nov 2018 13:58:11 -0800
Subject: Only run MathJax on entities with "mathjax" class (#960)
Correspondingly, we wrap all inline/diplay math in
... the math ....
This fixes #959.
---
haddock-api/src/Haddock/Backends/Xhtml.hs | 24 ++++++++++++++--------
.../src/Haddock/Backends/Xhtml/DocMarkup.hs | 4 ++--
html-test/ref/A.html | 4 +++-
html-test/ref/Bold.html | 4 +++-
html-test/ref/Bug1.html | 4 +++-
html-test/ref/Bug195.html | 4 +++-
html-test/ref/Bug2.html | 4 +++-
html-test/ref/Bug201.html | 4 +++-
html-test/ref/Bug253.html | 4 +++-
html-test/ref/Bug26.html | 4 +++-
html-test/ref/Bug280.html | 4 +++-
html-test/ref/Bug294.html | 4 +++-
html-test/ref/Bug298.html | 4 +++-
html-test/ref/Bug3.html | 4 +++-
html-test/ref/Bug308.html | 4 +++-
html-test/ref/Bug308CrossModule.html | 4 +++-
html-test/ref/Bug310.html | 4 +++-
html-test/ref/Bug313.html | 4 +++-
html-test/ref/Bug335.html | 4 +++-
html-test/ref/Bug387.html | 4 +++-
html-test/ref/Bug4.html | 4 +++-
html-test/ref/Bug458.html | 4 +++-
html-test/ref/Bug546.html | 4 +++-
html-test/ref/Bug548.html | 4 +++-
html-test/ref/Bug574.html | 4 +++-
html-test/ref/Bug6.html | 4 +++-
html-test/ref/Bug613.html | 4 +++-
html-test/ref/Bug647.html | 4 +++-
html-test/ref/Bug679.html | 4 +++-
html-test/ref/Bug7.html | 4 +++-
html-test/ref/Bug8.html | 4 +++-
html-test/ref/Bug85.html | 4 +++-
html-test/ref/Bug953.html | 4 +++-
html-test/ref/BugDeprecated.html | 4 +++-
html-test/ref/BugExportHeadings.html | 4 +++-
html-test/ref/Bugs.html | 4 +++-
html-test/ref/BundledPatterns.html | 4 +++-
html-test/ref/BundledPatterns2.html | 4 +++-
html-test/ref/ConstructorArgs.html | 4 +++-
html-test/ref/ConstructorPatternExport.html | 4 +++-
html-test/ref/DeprecatedClass.html | 4 +++-
html-test/ref/DeprecatedData.html | 4 +++-
html-test/ref/DeprecatedFunction.html | 4 +++-
html-test/ref/DeprecatedFunction2.html | 4 +++-
html-test/ref/DeprecatedFunction3.html | 4 +++-
html-test/ref/DeprecatedModule.html | 4 +++-
html-test/ref/DeprecatedModule2.html | 4 +++-
html-test/ref/DeprecatedNewtype.html | 4 +++-
html-test/ref/DeprecatedReExport.html | 4 +++-
html-test/ref/DeprecatedRecord.html | 4 +++-
html-test/ref/DeprecatedTypeFamily.html | 4 +++-
html-test/ref/DeprecatedTypeSynonym.html | 4 +++-
html-test/ref/DuplicateRecordFields.html | 4 +++-
html-test/ref/Examples.html | 4 +++-
html-test/ref/Extensions.html | 4 +++-
html-test/ref/FunArgs.html | 4 +++-
html-test/ref/GADTRecords.html | 4 +++-
html-test/ref/GadtConstructorArgs.html | 4 +++-
html-test/ref/Hash.html | 4 +++-
html-test/ref/HiddenInstances.html | 4 +++-
html-test/ref/HiddenInstancesB.html | 4 +++-
html-test/ref/Hyperlinks.html | 4 +++-
html-test/ref/ImplicitParams.html | 4 +++-
html-test/ref/Instances.html | 4 +++-
html-test/ref/Math.html | 22 ++++++++++++++------
html-test/ref/Minimal.html | 4 +++-
html-test/ref/ModuleWithWarning.html | 4 +++-
html-test/ref/NamedDoc.html | 4 +++-
html-test/ref/Nesting.html | 4 +++-
html-test/ref/NoLayout.html | 4 +++-
html-test/ref/NonGreedy.html | 4 +++-
html-test/ref/Operators.html | 4 +++-
html-test/ref/OrphanInstances.html | 4 +++-
html-test/ref/OrphanInstancesClass.html | 4 +++-
html-test/ref/OrphanInstancesType.html | 4 +++-
html-test/ref/PR643.html | 4 +++-
html-test/ref/PR643_1.html | 4 +++-
html-test/ref/PatternSyns.html | 4 +++-
html-test/ref/PromotedTypes.html | 4 +++-
html-test/ref/Properties.html | 4 +++-
html-test/ref/PruneWithWarning.html | 4 +++-
html-test/ref/QuantifiedConstraints.html | 4 +++-
html-test/ref/QuasiExpr.html | 4 +++-
html-test/ref/QuasiQuote.html | 4 +++-
html-test/ref/SpuriousSuperclassConstraints.html | 4 +++-
html-test/ref/TH.html | 4 +++-
html-test/ref/TH2.html | 4 +++-
html-test/ref/Table.html | 10 ++++++---
html-test/ref/Test.html | 4 +++-
html-test/ref/Threaded.html | 4 +++-
html-test/ref/Threaded_TH.html | 4 +++-
html-test/ref/Ticket112.html | 4 +++-
html-test/ref/Ticket61.html | 4 +++-
html-test/ref/Ticket75.html | 4 +++-
html-test/ref/TitledPicture.html | 4 +++-
html-test/ref/TypeFamilies.html | 4 +++-
html-test/ref/TypeFamilies2.html | 4 +++-
html-test/ref/TypeFamilies3.html | 4 +++-
html-test/ref/TypeOperators.html | 4 +++-
html-test/ref/Unicode.html | 4 +++-
html-test/ref/Unicode2.html | 4 +++-
html-test/ref/Visible.html | 4 +++-
102 files changed, 334 insertions(+), 118 deletions(-)
(limited to 'haddock-api/src/Haddock/Backends/Xhtml')
diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs
index 6da6a2e8..0a11ca08 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml.hs
@@ -120,17 +120,23 @@ copyHtmlBits odir libdir themes withQuickjump = do
headHtml :: String -> Themes -> Maybe String -> Html
headHtml docTitle themes mathjax_url =
- header << [
- meta ! [httpequiv "Content-Type", content "text/html; charset=UTF-8"],
- thetitle << docTitle,
- styleSheet themes,
- thelink ! [ rel "stylesheet", thetype "text/css", href quickJumpCssFile] << noHtml,
- script ! [src haddockJsFile, emptyAttr "async", thetype "text/javascript"] << noHtml,
- script ! [src mjUrl, thetype "text/javascript"] << noHtml
+ header <<
+ [ meta ! [httpequiv "Content-Type", content "text/html; charset=UTF-8"]
+ , thetitle << docTitle
+ , styleSheet themes
+ , thelink ! [ rel "stylesheet", thetype "text/css", href quickJumpCssFile] << noHtml
+ , script ! [src haddockJsFile, emptyAttr "async", thetype "text/javascript"] << noHtml
+ , script ! [thetype "text/x-mathjax-config"] << primHtml mjConf
+ , script ! [src mjUrl, thetype "text/javascript"] << noHtml
]
where
- mjUrl = maybe "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" id mathjax_url
-
+ mjUrl = maybe "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" id mathjax_url
+ mjConf = unwords [ "MathJax.Hub.Config({"
+ , "tex2jax: {"
+ , "processClass: \"mathjax\","
+ , "ignoreClass: \".*\""
+ , "}"
+ , "});" ]
srcButton :: SourceURLs -> Maybe Interface -> Maybe Html
srcButton (Just src_base_url, _, _, _) Nothing =
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs b/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
index ed323a90..38aa7b7e 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
@@ -69,8 +69,8 @@ parHtmlMarkup qual insertAnchors ppId = Markup {
then namedAnchor aname << ""
else noHtml,
markupPic = \(Picture uri t) -> image ! ([src uri] ++ fromMaybe [] (return . title <$> t)),
- markupMathInline = \mathjax -> toHtml ("\\(" ++ mathjax ++ "\\)"),
- markupMathDisplay = \mathjax -> toHtml ("\\[" ++ mathjax ++ "\\]"),
+ markupMathInline = \mathjax -> thespan ! [theclass "mathjax"] << toHtml ("\\(" ++ mathjax ++ "\\)"),
+ markupMathDisplay = \mathjax -> thespan ! [theclass "mathjax"] << toHtml ("\\[" ++ mathjax ++ "\\]"),
markupProperty = pre . toHtml,
markupExample = examplesToHtml,
markupHeader = \(Header l t) -> makeHeader l t,
diff --git a/html-test/ref/A.html b/html-test/ref/A.html
index e4802966..75fbb9ed 100644
--- a/html-test/ref/A.html
+++ b/html-test/ref/A.html
@@ -7,7 +7,9 @@
/>
normalDensity\[
+ >\[
\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}
- \]
\(\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\)
\(\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\)Math (inline) for normalDensity
- \(\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\)
- \[\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\]\(\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\)
+ \[\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\]
\[
+ > \[
f(n) = \sum_{i=1}
- \] | |
Date: Wed, 7 Nov 2018 10:22:31 -0800
Subject: Fix issues around plus/minus
* swap the minimize unicode to something more intuitive
* use new unicode expander/collapser for instance lists
* address some alignment issues in the "index" page
---
ghc.mk | 3 ---
haddock-api/haddock-api.cabal | 3 ---
haddock-api/resources/html/NewOcean.std-theme/minus.gif | Bin 56 -> 0 bytes
.../resources/html/NewOcean.std-theme/new-ocean.css | 14 ++++++--------
haddock-api/resources/html/NewOcean.std-theme/plus.gif | Bin 59 -> 0 bytes
haddock-api/src/Haddock/Backends/Xhtml.hs | 1 +
haddock-api/src/Haddock/Backends/Xhtml/Layout.hs | 7 ++++---
7 files changed, 11 insertions(+), 17 deletions(-)
delete mode 100644 haddock-api/resources/html/NewOcean.std-theme/minus.gif
delete mode 100644 haddock-api/resources/html/NewOcean.std-theme/plus.gif
(limited to 'haddock-api/src/Haddock/Backends/Xhtml')
diff --git a/ghc.mk b/ghc.mk
index a10fd61a..d3b02b6e 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -45,10 +45,7 @@ utils/haddock_dist_DATA_FILES += html/Ocean.theme/minus.gif
utils/haddock_dist_DATA_FILES += html/Ocean.theme/ocean.css
utils/haddock_dist_DATA_FILES += html/Ocean.theme/plus.gif
utils/haddock_dist_DATA_FILES += html/Ocean.theme/synopsis.png
-utils/haddock_dist_DATA_FILES += html/NewOcean.std-theme/hslogo-16.png
-utils/haddock_dist_DATA_FILES += html/NewOcean.std-theme/minus.gif
utils/haddock_dist_DATA_FILES += html/NewOcean.std-theme/new-ocean.css
-utils/haddock_dist_DATA_FILES += html/NewOcean.std-theme/plus.gif
utils/haddock_dist_DATA_FILES += html/NewOcean.std-theme/synopsis.png
utils/haddock_dist_DATA_FILES += html/solarized.css
utils/haddock_dist_DATA_FILES += html/highlight.js
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index d5c976b6..a410f436 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -34,10 +34,7 @@ data-files:
html/Ocean.theme/ocean.css
html/Ocean.theme/plus.gif
html/Ocean.theme/synopsis.png
- html/NewOcean.std-theme/hslogo-16.png
- html/NewOcean.std-theme/minus.gif
html/NewOcean.std-theme/new-ocean.css
- html/NewOcean.std-theme/plus.gif
html/NewOcean.std-theme/synopsis.png
latex/haddock.sty
diff --git a/haddock-api/resources/html/NewOcean.std-theme/minus.gif b/haddock-api/resources/html/NewOcean.std-theme/minus.gif
deleted file mode 100644
index 1deac2fe..00000000
Binary files a/haddock-api/resources/html/NewOcean.std-theme/minus.gif and /dev/null differ
diff --git a/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css b/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
index 8416176c..7568032f 100644
--- a/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
+++ b/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
@@ -352,7 +352,7 @@ ul.links li a {
.show { display: inherit; }
.clear { clear: both; }
-.collapser:before, .expander:before {
+.collapser:before, .expander:before, .noexpander:before {
font-size: 1.2em;
color: #9C5791;
display: inline-block;
@@ -360,11 +360,15 @@ ul.links li a {
}
.collapser:before {
- content: '⊗';
+ content: '⊖';
}
.expander:before {
content: "⊕";
}
+.noexpander:before {
+ content: "⊕";
+ visibility: hidden;
+}
.collapser, .expander {
cursor: pointer;
@@ -380,12 +384,6 @@ ul.links li a {
summary {
cursor: pointer;
outline: none;
- list-style-image: url(plus.gif);
- list-style-position: outside;
-}
-
-details[open] > summary {
- list-style-image: url(minus.gif);
}
pre {
diff --git a/haddock-api/resources/html/NewOcean.std-theme/plus.gif b/haddock-api/resources/html/NewOcean.std-theme/plus.gif
deleted file mode 100644
index 2d15c141..00000000
Binary files a/haddock-api/resources/html/NewOcean.std-theme/plus.gif and /dev/null differ
diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs
index 2b8bdd69..2206b7dc 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml.hs
@@ -324,6 +324,7 @@ mkNode pkg qual ss p (Node s leaf _pkg srcPkg short ts) =
cBtn = case (ts, leaf) of
(_:_, Just _) -> thespan ! collapseControl p "" << spaceHtml
+ ([] , Just _) -> thespan ! [theclass "noexpander"] << spaceHtml
(_, _ ) -> noHtml
-- We only need an explicit collapser button when the module name
-- is also a leaf, and so is a link to a module page. Indeed, the
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
index 10a6d499..c935bc5f 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
@@ -195,17 +195,18 @@ subEquations :: Maybe Package -> Qualification -> [SubDecl] -> Html
subEquations pkg qual = divSubDecls "equations" "Equations" . subTable pkg qual
--- | Generate sub table for instance declarations, with source
+-- | Generate collapsible sub table for instance declarations, with source
subInstances :: Maybe Package -> Qualification
-> String -- ^ Class name, used for anchor generation
-> LinksInfo -> Bool
-> [(SubDecl, Maybe Module, Located DocName)] -> Html
subInstances pkg qual nm lnks splice = maybe noHtml wrap . instTable
where
- wrap contents = subSection (collapseDetails id_ DetailsOpen (summary +++ contents))
+ wrap contents = subSection (hdr +++ collapseDetails id_ DetailsOpen (summary +++ contents))
instTable = subTableSrc pkg qual lnks splice
subSection = thediv ! [theclass "subs instances"]
- summary = thesummary << "Instances"
+ hdr = h4 ! collapseControl id_ "instances" << "Instances"
+ summary = thesummary ! [ theclass "hide-when-js-enabled" ] << "Instances details"
id_ = makeAnchorId $ "i:" ++ nm
--
cgit v1.2.3
From ad157c408cd7ad4badec71a84551a836a343f27b Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Wed, 7 Nov 2018 13:31:19 -0800
Subject: Allow "Contents" summary to scroll in a fixed div
In the unfortunate event that the "Contents" summary doesn't fit
vertically (like in the "Prelude"), it will be scrollable.
---
.../resources/html/NewOcean.std-theme/new-ocean.css | 18 ++++++++----------
haddock-api/src/Haddock/Backends/Xhtml.hs | 4 ++--
haddock-api/src/Haddock/Backends/Xhtml/Layout.hs | 5 +++--
3 files changed, 13 insertions(+), 14 deletions(-)
(limited to 'haddock-api/src/Haddock/Backends/Xhtml')
diff --git a/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css b/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
index 7568032f..906b3954 100644
--- a/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
+++ b/haddock-api/resources/html/NewOcean.std-theme/new-ocean.css
@@ -81,6 +81,9 @@ body.js-enabled .hide-when-js-enabled {
position: fixed;
max-width: 10vw;
top: 10.2em;
+ left: 2em;
+ bottom: 1em;
+ overflow-y: scroll;
}
#synopsis {
@@ -96,10 +99,6 @@ body.js-enabled .hide-when-js-enabled {
z-index: 1;
}
- #table-of-contents {
- left: 2em;
- }
-
#synopsis .show {
border: 1px solid #5E5184;
padding: 0.7em;
@@ -518,7 +517,7 @@ div#style-menu-holder {
/* @group Front Matter */
#synopsis .caption,
-#table-of-contents .caption {
+#contents-list .caption {
font-size: 1rem;
}
@@ -526,26 +525,25 @@ div#style-menu-holder {
font-size: 16px;
}
-#table-of-contents {
+#contents-list {
background: #f7f7f7;
padding: 1em;
margin: 0;
- margin-top: 1em;
}
-#table-of-contents .caption {
+#contents-list .caption {
text-align: left;
margin: 0;
}
-#table-of-contents ul {
+#contents-list ul {
list-style: none;
margin: 0;
margin-top: 10px;
font-size: 14px;
}
-#table-of-contents ul ul {
+#contents-list ul ul {
margin-left: 1.5em;
}
diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs
index 2206b7dc..e2fdc509 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml.hs
@@ -633,9 +633,9 @@ ppModuleContents pkg qual exports orphan
| null sections && not orphan = noHtml
| otherwise = contentsDiv
where
- contentsDiv = divTableOfContents << (
+ contentsDiv = divTableOfContents << (divContentsList << (
sectionName << "Contents" +++
- unordList (sections ++ orphanSection))
+ unordList (sections ++ orphanSection)))
(sections, _leftovers{-should be []-}) = process 0 exports
orphanSection
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
index c935bc5f..25d8b07a 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
@@ -15,7 +15,7 @@ module Haddock.Backends.Xhtml.Layout (
divPackageHeader, divContent, divModuleHeader, divFooter,
divTableOfContents, divDescription, divSynopsis, divInterface,
- divIndex, divAlphabet, divModuleList,
+ divIndex, divAlphabet, divModuleList, divContentsList,
sectionName,
nonEmptySectionName,
@@ -80,7 +80,7 @@ nonEmptySectionName c
divPackageHeader, divContent, divModuleHeader, divFooter,
divTableOfContents, divDescription, divSynopsis, divInterface,
- divIndex, divAlphabet, divModuleList
+ divIndex, divAlphabet, divModuleList, divContentsList
:: Html -> Html
divPackageHeader = sectionDiv "package-header"
@@ -88,6 +88,7 @@ divContent = sectionDiv "content"
divModuleHeader = sectionDiv "module-header"
divFooter = sectionDiv "footer"
divTableOfContents = sectionDiv "table-of-contents"
+divContentsList = sectionDiv "contents-list"
divDescription = sectionDiv "description"
divSynopsis = sectionDiv "synopsis"
divInterface = sectionDiv "interface"
--
cgit v1.2.3