[commit: haddock] 2.17.3.1-spanfix, alexbiehl-patch-1, ghc-8.0, ghc-8.0-facebook, ghc-head, ghc-head1, haddock-quick, headdock-library-1.4.5, ie_avails, issue-303, issue-475, master, pr-filter-maps, pr/cabal-desc, travis, v2.17, v2.17.3, v2.18, wip-located-module-as, wip/D2418, wip/T11080-open-data-kinds, wip/T11430, wip/T12105, wip/T12105-2, wip/T12942, wip/T13163, wip/T14529, wip/T3384, wip/embelleshed-rdr, wip/new-tree-one-param, wip/rae, wip/remove-frames, wip/remove-frames1, wip/revert-ttg-2017-11-20, wip/ttg-2017-10-13, wip/ttg-2017-10-31, wip/ttg-2017-11-06, wip/ttg2-2017-11-10, wip/ttg3-2017-11-12, wip/ttg4-constraints-2017-11-13, wip/ttg6-unrevert-2017-11-22: Refactor existing code to use XHTML printer instead of XML one. (2555cc3)

git at git.haskell.org git at git.haskell.org
Tue Nov 28 11:38:30 UTC 2017


Repository : ssh://git@git.haskell.org/haddock

On branches: 2.17.3.1-spanfix,alexbiehl-patch-1,ghc-8.0,ghc-8.0-facebook,ghc-head,ghc-head1,haddock-quick,headdock-library-1.4.5,ie_avails,issue-303,issue-475,master,pr-filter-maps,pr/cabal-desc,travis,v2.17,v2.17.3,v2.18,wip-located-module-as,wip/D2418,wip/T11080-open-data-kinds,wip/T11430,wip/T12105,wip/T12105-2,wip/T12942,wip/T13163,wip/T14529,wip/T3384,wip/embelleshed-rdr,wip/new-tree-one-param,wip/rae,wip/remove-frames,wip/remove-frames1,wip/revert-ttg-2017-11-20,wip/ttg-2017-10-13,wip/ttg-2017-10-31,wip/ttg-2017-11-06,wip/ttg2-2017-11-10,wip/ttg3-2017-11-12,wip/ttg4-constraints-2017-11-13,wip/ttg6-unrevert-2017-11-22
Link       : http://git.haskell.org/haddock.git/commitdiff/2555cc37c9e9c0eeb9f7fbddb9599bb6fae3e982

>---------------------------------------------------------------

commit 2555cc37c9e9c0eeb9f7fbddb9599bb6fae3e982
Author: Ɓukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Fri Aug 21 19:51:24 2015 +0200

    Refactor existing code to use XHTML printer instead of XML one.


>---------------------------------------------------------------

2555cc37c9e9c0eeb9f7fbddb9599bb6fae3e982
 haddock-test/src/Test/Haddock/Xhtml.hs | 41 +++++++++++++++++-----------------
 html-test/Main.hs                      |  8 +++----
 hypsrc-test/Main.hs                    |  6 ++---
 3 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/haddock-test/src/Test/Haddock/Xhtml.hs b/haddock-test/src/Test/Haddock/Xhtml.hs
index 21fda36..69361f7 100644
--- a/haddock-test/src/Test/Haddock/Xhtml.hs
+++ b/haddock-test/src/Test/Haddock/Xhtml.hs
@@ -3,8 +3,8 @@
 
 
 module Test.Haddock.Xhtml
-    ( Xhtml(..)
-    , parseXhtml, dumpXhtml
+    ( Xml(..)
+    , parseXml, dumpXml
     , stripLinks, stripLinksWhen, stripAnchorsWhen, stripFooter
     ) where
 
@@ -13,11 +13,12 @@ import Data.Generics.Aliases
 import Data.Generics.Schemes
 
 import Text.XML.Light
-import Text.XHtml
+import Text.XHtml (Html, HtmlAttr, (!))
+import qualified Text.XHtml as Xhtml
 
 
-newtype Xhtml = Xhtml
-    { xhtmlElement :: Element
+newtype Xml = Xml
+    { xmlElement :: Element
     } deriving Eq
 
 
@@ -27,19 +28,19 @@ deriving instance Eq Content
 deriving instance Eq CData
 
 
-parseXhtml :: String -> Maybe Xhtml
-parseXhtml = fmap Xhtml . parseXMLDoc
+parseXml :: String -> Maybe Xml
+parseXml = fmap Xml . parseXMLDoc
 
 
-dumpXhtml :: Xhtml -> String
-dumpXhtml = ppElement . xhtmlElement
+dumpXml :: Xml -> String
+dumpXml = Xhtml.renderHtmlFragment. xmlElementToXhtml . xmlElement
 
 
-stripLinks :: Xhtml -> Xhtml
+stripLinks :: Xml -> Xml
 stripLinks = stripLinksWhen (const True)
 
 
-stripLinksWhen :: (String -> Bool) -> Xhtml -> Xhtml
+stripLinksWhen :: (String -> Bool) -> Xml -> Xml
 stripLinksWhen p =
     processAnchors unlink
   where
@@ -48,7 +49,7 @@ stripLinksWhen p =
         | otherwise = attr
 
 
-stripAnchorsWhen :: (String -> Bool) -> Xhtml -> Xhtml
+stripAnchorsWhen :: (String -> Bool) -> Xml -> Xml
 stripAnchorsWhen p =
     processAnchors unname
   where
@@ -57,13 +58,13 @@ stripAnchorsWhen p =
         | otherwise = attr
 
 
-processAnchors :: (Attr -> Attr) -> Xhtml -> Xhtml
-processAnchors f = Xhtml . everywhere (mkT f) . xhtmlElement
+processAnchors :: (Attr -> Attr) -> Xml -> Xml
+processAnchors f = Xml . everywhere (mkT f) . xmlElement
 
 
-stripFooter :: Xhtml -> Xhtml
+stripFooter :: Xml -> Xml
 stripFooter =
-    Xhtml . everywhere (mkT defoot) . xhtmlElement
+    Xml . everywhere (mkT defoot) . xmlElement
   where
     defoot el
         | isFooter el = el { elContent = [] }
@@ -77,7 +78,7 @@ stripFooter =
 
 xmlElementToXhtml :: Element -> Html
 xmlElementToXhtml (Element { .. }) =
-    tag (qName elName) contents ! attrs
+    Xhtml.tag (qName elName) contents ! attrs
   where
     contents = mconcat $ map xmlContentToXhtml elContent
     attrs = map xmlAttrToXhtml elAttribs
@@ -85,9 +86,9 @@ xmlElementToXhtml (Element { .. }) =
 
 xmlContentToXhtml :: Content -> Html
 xmlContentToXhtml (Elem el) = xmlElementToXhtml el
-xmlContentToXhtml (Text text) = toHtml $ cdData text
-xmlContentToXhtml (CRef cref) = noHtml
+xmlContentToXhtml (Text text) = Xhtml.toHtml $ cdData text
+xmlContentToXhtml (CRef _) = Xhtml.noHtml
 
 
 xmlAttrToXhtml :: Attr -> HtmlAttr
-xmlAttrToXhtml (Attr { .. }) = strAttr (qName attrKey) attrVal
+xmlAttrToXhtml (Attr { .. }) = Xhtml.strAttr (qName attrKey) attrVal
diff --git a/html-test/Main.hs b/html-test/Main.hs
index 724d35e..3880fc3 100755
--- a/html-test/Main.hs
+++ b/html-test/Main.hs
@@ -10,10 +10,10 @@ import Test.Haddock
 import Test.Haddock.Xhtml
 
 
-checkConfig :: CheckConfig Xhtml
+checkConfig :: CheckConfig Xml
 checkConfig = CheckConfig
-    { ccfgRead = \mdl input -> stripIfRequired mdl <$> parseXhtml input
-    , ccfgDump = dumpXhtml
+    { ccfgRead = \mdl input -> stripIfRequired mdl <$> parseXml input
+    , ccfgDump = dumpXml
     , ccfgEqual = (==)
     }
 
@@ -32,7 +32,7 @@ main = do
         }
 
 
-stripIfRequired :: String -> Xhtml -> Xhtml
+stripIfRequired :: String -> Xml -> Xml
 stripIfRequired mdl =
     stripLinks' . stripFooter
   where
diff --git a/hypsrc-test/Main.hs b/hypsrc-test/Main.hs
index 06cf854..0490be4 100644
--- a/hypsrc-test/Main.hs
+++ b/hypsrc-test/Main.hs
@@ -11,10 +11,10 @@ import Test.Haddock
 import Test.Haddock.Xhtml
 
 
-checkConfig :: CheckConfig Xhtml
+checkConfig :: CheckConfig Xml
 checkConfig = CheckConfig
-    { ccfgRead = \_ input -> strip <$> parseXhtml input
-    , ccfgDump = dumpXhtml
+    { ccfgRead = \_ input -> strip <$> parseXml input
+    , ccfgDump = dumpXml
     , ccfgEqual = (==)
     }
   where



More information about the ghc-commits mailing list