[Pkg-haskell-commits] darcs: haskell-hoogle: Rename haddock_collect.hs
kiwamu at debian.or.jp
kiwamu at debian.or.jp
Wed Sep 12 16:51:24 UTC 2012
Wed Sep 12 16:49:07 UTC 2012 kiwamu at debian.or.jp
* Rename haddock_collect.hs
Ignore-this: acd90eee46df3e322b032219d18b39ea
./files_hoogle/haddock_collect.hs -> ./files_hoogle/haddock-collect.hs
M ./files_hoogle/update-hoogle -2 +2
M ./rules -4 +4
Wed Sep 12 16:49:07 UTC 2012 kiwamu at debian.or.jp
* Rename haddock_collect.hs
Ignore-this: acd90eee46df3e322b032219d18b39ea
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 1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hoogle//files_hoogle/haddock-collect.hs 2012-09-12 16:51:24.588847017 +0000
@@ -0,0 +1,54 @@
+#!/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/haddock_collect.hs new-haskell-hoogle//files_hoogle/haddock_collect.hs
--- old-haskell-hoogle//files_hoogle/haddock_collect.hs 2012-09-12 16:51:24.461031862 +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-09-12 16:51:24.568830564 +0000
+++ new-haskell-hoogle//files_hoogle/update-hoogle 2012-09-12 16:51:24.592838152 +0000
@@ -17,11 +17,11 @@
echo "Collect txt files on ghc-doc"
find /usr/share/doc/ghc-doc/html/libraries/*/ -name "*.txt*" 2>/dev/null | \
- haddock_collect $URLPREFIX $DATABASE_DIR/
+ haddock-collect $URLPREFIX $DATABASE_DIR/
echo "Collect txt files on libghc-*-doc"
find /usr/share/doc/libghc-*-doc/html -wholename "/usr/share/doc/libghc-*-doc/html/*.txt" 2>/dev/null | \
- haddock_collect $URLPREFIX $DATABASE_DIR/
+ haddock-collect $URLPREFIX $DATABASE_DIR/
# convert
for i in $DATABASE_DIR/*.txt; do
diff -rN -u old-haskell-hoogle//rules new-haskell-hoogle//rules
--- old-haskell-hoogle//rules 2012-09-12 16:51:24.564830803 +0000
+++ new-haskell-hoogle//rules 2012-09-12 16:51:24.600844124 +0000
@@ -7,14 +7,14 @@
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
+ 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/
+ install $(FILES_HOOGLE)/haddock-collect debian/hoogle/usr/sbin/
clean::
- cd $(FILES_HOOGLE)/ && rm -f haddock_collect haddock_collect.hi haddock_collect.o
+ cd $(FILES_HOOGLE)/ && rm -f haddock-collect haddock-collect.hi haddock-collect.o
More information about the Pkg-haskell-commits
mailing list