[commit: haddock] alexbiehl-patch-1, ghc-head, ghc-head1, headdock-library-1.4.5, ie_avails, master, pr-filter-maps, pr/cabal-desc, travis, v2.18, wip/T14529, 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: Read files for hyperlinker eagerly (e0ada17)

git at git.haskell.org git at git.haskell.org
Tue Nov 28 11:50:44 UTC 2017


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

On branches: alexbiehl-patch-1,ghc-head,ghc-head1,headdock-library-1.4.5,ie_avails,master,pr-filter-maps,pr/cabal-desc,travis,v2.18,wip/T14529,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/e0ada1743cb722d2f82498a95b201f3ffb303137

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

commit e0ada1743cb722d2f82498a95b201f3ffb303137
Author: alexbiehl <alex.biehl at gmail.com>
Date:   Tue Apr 11 20:35:08 2017 +0200

    Read files for hyperlinker eagerly
    
    This also exposes Documentation.Haddock.Utf8


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

e0ada1743cb722d2f82498a95b201f3ffb303137
 haddock-api/src/Haddock/Interface/Create.hs | 12 ++++++++----
 haddock-library/haddock-library.cabal       |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index e594fea..d2ad929 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -19,6 +19,7 @@
 module Haddock.Interface.Create (createInterface) where
 
 import Documentation.Haddock.Doc (metaDocAppend)
+import Documentation.Haddock.Utf8 as Utf8
 import Haddock.Types
 import Haddock.Options
 import Haddock.GhcUtils
@@ -29,6 +30,7 @@ import Haddock.Backends.Hyperlinker.Types
 import Haddock.Backends.Hyperlinker.Ast as Hyperlinker
 import Haddock.Backends.Hyperlinker.Parser as Hyperlinker
 
+import qualified Data.ByteString as BS
 import qualified Data.Map as M
 import Data.Map (Map)
 import Data.List
@@ -38,6 +40,7 @@ import Data.Ord
 import Control.Applicative
 import Control.Arrow (second)
 import Control.DeepSeq
+import Control.Exception (evaluate)
 import Control.Monad
 import Data.Function (on)
 
@@ -976,10 +979,11 @@ mkMaybeTokenizedSrc flags tm
     summary = pm_mod_summary . tm_parsed_module $ tm
 
 mkTokenizedSrc :: ModSummary -> RenamedSource -> IO [RichToken]
-mkTokenizedSrc ms src =
-    Hyperlinker.enrich src . Hyperlinker.parse <$> rawSrc
-  where
-    rawSrc = readFile $ msHsFilePath ms
+mkTokenizedSrc ms src = do
+  -- make sure to read the whole file at once otherwise
+  -- we run out of file descriptors (see #495)
+  rawSrc <- BS.readFile (msHsFilePath ms) >>= evaluate
+  return $ Hyperlinker.enrich src (Hyperlinker.parse (decodeUtf8 rawSrc))
 
 -- | Find a stand-alone documentation comment by its name.
 findNamedDoc :: String -> [HsDecl Name] -> ErrMsgM (Maybe HsDocString)
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index cabfbc6..4e355dd 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -34,6 +34,7 @@ library
     Documentation.Haddock.Parser.Monad
     Documentation.Haddock.Types
     Documentation.Haddock.Doc
+    Documentation.Haddock.Utf8
 
   other-modules:
     Data.Attoparsec
@@ -48,7 +49,6 @@ library
     Data.Attoparsec.Internal.Types
     Data.Attoparsec.Number
     Documentation.Haddock.Parser.Util
-    Documentation.Haddock.Utf8
 
 test-suite spec
   type:             exitcode-stdio-1.0



More information about the ghc-commits mailing list