aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Haddock/Backends/LaTeX.hs52
1 files changed, 19 insertions, 33 deletions
diff --git a/src/Haddock/Backends/LaTeX.hs b/src/Haddock/Backends/LaTeX.hs
index 814c4fb9..4254810e 100644
--- a/src/Haddock/Backends/LaTeX.hs
+++ b/src/Haddock/Backends/LaTeX.hs
@@ -88,8 +88,11 @@ ppLaTeX title packageStr visible_ifaces odir prologue maybe_style libdir
ppLaTeXTop title packageStr odir prologue maybe_style visible_ifaces
mapM_ (ppLaTeXModule title odir) visible_ifaces
+
+haddockSty :: String
haddockSty = "haddock.sty"
+
type LaTeX = Pretty.Doc
ppLaTeXTop
@@ -174,7 +177,7 @@ exportListItem (ExportDecl decl _doc subdocs _insts)
= ppDocBinder (declName decl) <>
case subdocs of
[] -> empty
- xs -> parens (sep (punctuate comma (map (ppDocBinder . fst) subdocs)))
+ _ -> parens (sep (punctuate comma (map (ppDocBinder . fst) subdocs)))
exportListItem (ExportNoDecl y [])
= ppDocBinder y
exportListItem (ExportNoDecl y subs)
@@ -275,15 +278,19 @@ ppDecl (L loc decl) (mbDoc, fnArgsDoc) instances subdocs = case decl of
where
unicode = False
+ppTyFam :: t -> t1 -> t2 -> t3 -> t4 -> a
ppTyFam _ _ _ _ _ =
error "type family declarations are currently not supported by --latex"
+ppDataInst :: t -> t1 -> t2 -> a
ppDataInst _ _ _ =
error "data instance declarations are currently not supported by --latex"
+ppTyInst :: t -> t1 -> t2 -> t3 -> t4 -> a
ppTyInst _ _ _ _ _ =
error "type instance declarations are currently not supported by --latex"
+ppFor :: t -> t1 -> t2 -> t3 -> a
ppFor _ _ _ _ =
error "foreign declarations are currently not supported by --latex"
@@ -319,7 +326,7 @@ ppTypeOrFunSig :: SrcSpan -> DocName -> HsType DocName ->
DocForDecl DocName -> (LaTeX, LaTeX, LaTeX)
-> Bool -> Bool -> LaTeX
ppTypeOrFunSig _loc _docname typ (doc, argDocs) (pref1, pref2, sep0)
- unicode methods
+ unicode _
| Map.null argDocs =
declWithDoc pref1 (fmap docToLaTeX doc)
| otherwise =
@@ -425,7 +432,7 @@ ppClassDecl :: [DocInstance DocName] -> SrcSpan
-> Maybe (Doc DocName) -> [(DocName, DocForDecl DocName)]
-> TyClDecl DocName -> Bool -> LaTeX
ppClassDecl instances loc mbDoc subdocs
- decl@(ClassDecl lctxt lname ltyvars lfds lsigs _ ats _) unicode
+ (ClassDecl lctxt lname ltyvars lfds lsigs _ _ _) unicode
= declWithDoc classheader (if null body then Nothing else Just (vcat body)) $$
instancesBit
where
@@ -433,15 +440,14 @@ ppClassDecl instances loc mbDoc subdocs
| null lsigs = hdr unicode
| otherwise = hdr unicode <+> keyword "where"
- nm = unLoc $ tcdLName decl
-
hdr = ppClassHdr False lctxt (unLoc lname) ltyvars lfds
body = catMaybes [fmap docToLaTeX mbDoc, body_]
body_
- | null lsigs, null ats = Nothing
- | null ats = Just methodTable
+ | null lsigs = Nothing
+ | otherwise = Just methodTable
+
-- | otherwise = atTable $$ methodTable
methodTable =
@@ -490,14 +496,13 @@ ppDataDecl :: [DocInstance DocName] ->
[(DocName, DocForDecl DocName)] ->
SrcSpan -> Maybe (Doc DocName) -> TyClDecl DocName -> Bool ->
LaTeX
-ppDataDecl instances subdocs loc mbDoc dataDecl unicode
+ppDataDecl instances subdocs _ mbDoc dataDecl unicode
= declWithDoc (ppDataHeader dataDecl unicode <+> whereBit)
(if null body then Nothing else Just (vcat body))
$$ instancesBit
where
- docname = unLoc . tcdLName $ dataDecl
cons = tcdCons dataDecl
resTy = (con_res . unLoc . head) cons
@@ -522,11 +527,6 @@ ppDataDecl instances subdocs loc mbDoc dataDecl unicode
declWithDoc (vcat (map (ppInstDecl unicode) (map fst instances))) Nothing
| otherwise = vcat (map (ppDocInstance unicode) instances)
-isRecCon :: Located (ConDecl a) -> Bool
-isRecCon lcon = case con_details (unLoc lcon) of
- RecCon _ -> True
- _ -> False
-
-- ppConstrHdr is for (non-GADT) existentials constructors' syntax
#if __GLASGOW_HASKELL__ == 612
@@ -868,11 +868,6 @@ ppBinder n
| isVarSym n = parens $ ppOccName n
| otherwise = ppOccName n
-ppVerbBinder :: OccName -> LaTeX
-ppVerbBinder n
- | isVarSym n = parens $ ppVerbOccName n
- | otherwise = ppVerbOccName n
-
ppSymName :: Name -> LaTeX
ppSymName name
| isNameSym name = parens $ ppName name
@@ -899,21 +894,16 @@ ppLDocName (L _ d) = ppDocName d
ppDocBinder :: DocName -> LaTeX
ppDocBinder = ppBinder . docNameOcc
-ppVerbDocBinder :: DocName -> LaTeX
-ppVerbDocBinder = ppVerbBinder . docNameOcc
-
ppName :: Name -> LaTeX
ppName = ppOccName . nameOccName
-ppVerbName :: Name -> LaTeX
-ppVerbName = ppVerbOccName . nameOccName
-
latexFilter :: String -> String
latexFilter = foldr latexMunge ""
latexMonoFilter :: String -> String
latexMonoFilter = foldr latexMonoMunge ""
+latexMunge :: Char -> String -> String
latexMunge '#' s = "{\\char '43}" ++ s
latexMunge '$' s = "{\\char '44}" ++ s
latexMunge '%' s = "{\\char '45}" ++ s
@@ -928,6 +918,7 @@ latexMunge '[' s = "{\\char 91}" ++ s
latexMunge ']' s = "{\\char 93}" ++ s
latexMunge c s = c : s
+latexMonoMunge :: Char -> String -> String
latexMonoMunge ' ' s = '\\' : ' ' : s
latexMonoMunge '\n' s = '\\' : '\\' : s
latexMonoMunge c s = latexMunge c s
@@ -943,11 +934,11 @@ parLatexMarkup ppId isTyCon = Markup {
markupString = \s v -> text (fixString v s),
markupAppend = \l r v -> l v <> r v,
markupIdentifier = markupId,
- markupModule = \m v -> let (mdl,_ref) = break (=='#') m in tt (text mdl),
+ markupModule = \m _ -> let (mdl,_ref) = break (=='#') m in tt (text mdl),
markupEmphasis = \p v -> emph (p v),
- markupMonospaced = \p v -> tt (p Mono),
+ markupMonospaced = \p _ -> tt (p Mono),
markupUnorderedList = \p v -> itemizedList (map ($v) p) $$ text "",
- markupPic = \path v -> parens (text "image: " <> text path),
+ markupPic = \path _ -> parens (text "image: " <> text path),
markupOrderedList = \p v -> enumeratedList (map ($v) p) $$ text "",
markupDefList = \l v -> descriptionList (map (\(a,b) -> (a v, b v)) l),
markupCodeBlock = \p _ -> quote (verb (p Verb)) $$ text "",
@@ -1006,11 +997,6 @@ latexStripTrailingWhitespace (DocParagraph p) =
latexStripTrailingWhitespace p
latexStripTrailingWhitespace other = other
-latexStripLeadingPara :: Doc a -> Doc a
-latexStripLeadingPara (DocParagraph p) = p
-latexStripLeadingPara (DocAppend l r) = DocAppend (latexStripLeadingPara l) r
-latexStripLeadingPara d = d
-
-- -----------------------------------------------------------------------------
-- LaTeX utils