[Pkg-haskell-commits] darcs: haskell-hoogle: Collect txt files from /usr/lib/ghc-doc/hoogle/ dir.
kiwamu at debian.or.jp
kiwamu at debian.or.jp
Thu Oct 4 13:20:35 UTC 2012
Thu Oct 4 13:16:14 UTC 2012 kiwamu at debian.or.jp
* Collect txt files from /usr/lib/ghc-doc/hoogle/ dir.
Ignore-this: 39b0b962a9653a129ea79c2c9bc339e5
R ./files_hoogle/haddock-collect.hs
M ./files_hoogle/update-hoogle -3 +7
M ./hoogle.triggers -1 +1
M ./rules -5
Thu Oct 4 13:16:14 UTC 2012 kiwamu at debian.or.jp
* Collect txt files from /usr/lib/ghc-doc/hoogle/ dir.
Ignore-this: 39b0b962a9653a129ea79c2c9bc339e5
diff -rN -u old-haskell-hoogle//files_hoogle/haddock-collect.hs new-haskell-hoogle//files_hoogle/haddock-collect.hs
--- old-haskell-hoogle//files_hoogle/haddock-collect.hs 2012-10-04 13:20:34.692061292 +0000
+++ new-haskell-hoogle//files_hoogle/haddock-collect.hs 1970-01-01 00:00:00.000000000 +0000
@@ -1,54 +0,0 @@
-#!/usr/bin/runhaskell
-{-# OPTIONS -Wall #-}
-
-import Data.List
-import Data.Char
-import System.Environment
-import System.FilePath
-import qualified Data.ByteString.Lazy as BL
-import qualified Data.ByteString.Lazy.Char8 as BL8
-import Codec.Compression.GZip
-
-type URL = String
-
--- copy from hoogle/src/Recipe/Hackage.hs
-haddockHacks :: [String] -> [String]
-haddockHacks = map (unwords . map f . words) . filter (not . isPrefixOf "@version ")
- where
- f "::" = "::"
- f (':':xs) = "(:" ++ xs ++ ")"
- f ('!':'!':x:xs) | isAlpha x = xs
- f ('!':x:xs) | isAlpha x || x `elem` "[(" = x:xs
- f x | x `elem` ["[overlap","ok]","[incoherent]"] = ""
- f x = x
-
-haddockPackageUrl :: URL -> [String] -> [String]
-haddockPackageUrl x = concatMap f
- where f y | "@package " `isPrefixOf` y = ["@url " ++ x, y]
- | otherwise = [y]
--- copy end
-
-filterHaddock :: URL -> String -> String
-filterHaddock url = unlines . haddockHacks . haddockPackageUrl url . lines
-
-readFileGz :: FilePath -> IO String
-readFileGz file
- | takeExtension file == ".gz" = do
- c <- BL.readFile file
- return $ BL8.unpack . decompress $ c
- | otherwise = readFile file
-
-readAndPrint :: URL -> FilePath -> FilePath -> IO ()
-readAndPrint prefix outdir file = do
- f <- readFileGz file
- writeFile outfile $ filterHaddock url f
- where dropgz f | takeExtension f == ".gz" = dropExtension f
- | otherwise = f
- outfile = outdir </> takeFileName (dropgz file)
- url = prefix ++ dropFileName file
-
-main :: IO ()
-main = do
- [p, o] <- getArgs
- c <- getContents
- mapM_ (readAndPrint p o) (lines c)
diff -rN -u old-haskell-hoogle//files_hoogle/update-hoogle new-haskell-hoogle//files_hoogle/update-hoogle
--- old-haskell-hoogle//files_hoogle/update-hoogle 2012-10-04 13:20:34.692061292 +0000
+++ new-haskell-hoogle//files_hoogle/update-hoogle 2012-10-04 13:20:34.700037141 +0000
@@ -15,9 +15,13 @@
# new database
$HOOGLE data keyword
-echo "Collect txt files from ghc-doc and libghc-*-doc"
-find /usr/share/doc -wholename "/usr/share/doc/ghc-doc/html/libraries/*/*.txt*" -or -wholename "/usr/share/doc/libghc-*-doc/html/*.txt" | \
- haddock-collect $URLPREFIX $DATABASE_DIR/
+TXTFILES=`find /usr/lib/ghc-doc/hoogle/ -name "*.txt" 2>/dev/null`
+if [ "$TXTFILES" = "" ]; then
+ echo "No txt files on /usr/lib/ghc-doc/hoogle/ dir..."
+else
+ echo "Collect txt files from /usr/lib/ghc-doc/hoogle/ dir"
+ cp $TXTFILES $DATABASE_DIR/
+fi
# convert
for i in $DATABASE_DIR/*.txt; do
diff -rN -u old-haskell-hoogle//hoogle.triggers new-haskell-hoogle//hoogle.triggers
--- old-haskell-hoogle//hoogle.triggers 2012-10-04 13:20:34.692061292 +0000
+++ new-haskell-hoogle//hoogle.triggers 2012-10-04 13:20:34.704054284 +0000
@@ -1 +1 @@
-interest /usr/lib/ghc-doc/haddock
+interest /usr/lib/ghc-doc/hoogle
diff -rN -u old-haskell-hoogle//rules new-haskell-hoogle//rules
--- old-haskell-hoogle//rules 2012-10-04 13:20:34.688069322 +0000
+++ new-haskell-hoogle//rules 2012-10-04 13:20:34.708094261 +0000
@@ -6,15 +6,10 @@
HOOGLE_RESDIR := debian/hoogle/usr/share/hoogle/resources
FILES_HOOGLE := debian/files_hoogle
-build/hoogle:: build-ghc-stamp
- cd $(FILES_HOOGLE)/ && ghc -Wall -O haddock-collect.hs
- cd $(FILES_HOOGLE)/ && strip haddock-collect
-
binary-fixup/hoogle::
sed -i -e "s/res\//hoogle\/res\//g" $(HOOGLE_RESDIR)/template.html
sed -i -e "s/action=\"\.\"/action=\"\.\/hoogle\"/g" $(HOOGLE_RESDIR)/template.html
install $(FILES_HOOGLE)/update-hoogle debian/hoogle/usr/sbin/
- install $(FILES_HOOGLE)/haddock-collect debian/hoogle/usr/sbin/
clean::
cd $(FILES_HOOGLE)/ && rm -f haddock-collect haddock-collect.hi haddock-collect.o
More information about the Pkg-haskell-commits
mailing list