X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FhsSyn%2FHsDoc.hs;h=fd721c00c0d7f5fecc820b18d65322b9d6ac3442;hb=431453c003b867a2fe33d8634ee830d062be5a96;hp=57dcfbe24dba285199e6eb72da7d16d3ebed16c8;hpb=ad94d40948668032189ad22a0ad741ac1f645f50;p=ghc-hetmet.git diff --git a/compiler/hsSyn/HsDoc.hs b/compiler/hsSyn/HsDoc.hs index 57dcfbe..fd721c0 100644 --- a/compiler/hsSyn/HsDoc.hs +++ b/compiler/hsSyn/HsDoc.hs @@ -1,10 +1,3 @@ -{-# OPTIONS -w #-} --- The above warning supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and fix --- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings --- for details - module HsDoc ( HsDoc(..), LHsDoc, @@ -34,6 +27,7 @@ data HsDoc id | DocDefList [(HsDoc id, HsDoc id)] | DocCodeBlock (HsDoc id) | DocURL String + | DocPic String | DocAName String deriving (Eq, Show) @@ -42,6 +36,7 @@ type LHsDoc a = Located (HsDoc a) instance Outputable (HsDoc a) where ppr _ = text "" +ppr_mbDoc :: Maybe (LHsDoc a) -> SDoc ppr_mbDoc (Just doc) = ppr doc ppr_mbDoc Nothing = empty @@ -68,16 +63,34 @@ docAppend d1 d2 -- is a DocMonospaced and make it into a DocCodeBlock docParagraph :: HsDoc id -> HsDoc id docParagraph (DocMonospaced p) - = DocCodeBlock p + = DocCodeBlock (docCodeBlock p) docParagraph (DocAppend (DocString s1) (DocMonospaced p)) | all isSpace s1 - = DocCodeBlock p + = DocCodeBlock (docCodeBlock p) docParagraph (DocAppend (DocString s1) (DocAppend (DocMonospaced p) (DocString s2))) | all isSpace s1 && all isSpace s2 - = DocCodeBlock p + = DocCodeBlock (docCodeBlock p) docParagraph (DocAppend (DocMonospaced p) (DocString s2)) | all isSpace s2 - = DocCodeBlock p + = DocCodeBlock (docCodeBlock p) docParagraph p = DocParagraph p + + +-- Drop trailing whitespace from @..@ code blocks. Otherwise this: +-- +-- -- @ +-- -- foo +-- -- @ +-- +-- turns into (DocCodeBlock "\nfoo\n ") which when rendered in HTML +-- gives an extra vertical space after the code block. The single space +-- on the final line seems to trigger the extra vertical space. +-- +docCodeBlock :: HsDoc id -> HsDoc id +docCodeBlock (DocString s) + = DocString (reverse $ dropWhile (`elem` " \t") $ reverse s) +docCodeBlock (DocAppend l r) + = DocAppend l (docCodeBlock r) +docCodeBlock d = d