From a45ecd3779cc8c715cf7243ff29cb1012a871cc3 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Tue, 12 Jul 2022 22:13:31 +0100 Subject: [PATCH] scripts: Drop obsolete grabDescriptions.hs We haven't used this for a while, and since we dropped descriptions in X.D.Extending in favor of the haddock-generated index in 839302533bed6c6ece709a9d8508cc9b773b3975, it's useless. --- scripts/grabDescriptions.hs | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100755 scripts/grabDescriptions.hs diff --git a/scripts/grabDescriptions.hs b/scripts/grabDescriptions.hs deleted file mode 100755 index f6c0bbf7..00000000 --- a/scripts/grabDescriptions.hs +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env runhaskell - -import Control.Applicative -import Control.Arrow -import Control.Monad -import Data.Char -import Data.List -import Data.Maybe -import System.Directory -import System.Environment - --- needs haskell-src-exts -import qualified Language.Haskell.Exts.Annotated as H - -getComments = (fmap . fmap) (map (\(H.Comment _ _ x) -> x) . snd) - . H.parseFileWithComments H.defaultParseMode - --- | Used to grab the description fields from all the modules in the current --- directory for updating XMonad.Docs.Extending -main = putStrLn . intercalate "\n" - =<< mapM (fmap . handleFailure description <*> getComments) =<< filterM doesFileExist . sort - =<< getDirectoryContents . fromMaybe "." . listToMaybe - =<< getArgs -- somehow only the "." fallback works... - -handleFailure :: (String -> [String] -> String) -> String -> H.ParseResult [String] -> String -handleFailure f n (H.ParseOk x) = f n x -handleFailure f n (H.ParseFailed _ msg) = n ++ " Parse Failure: " ++ msg - -description :: String -> [String] -> String -description path xs = - let (hs,desc) - = uncurry (\x (y,descr) -> (x++y,takeWhile (not . or . sequence [null,("* Usage" `isInfixOf`),all (=='-'),all isSpace]) . dropWhile (all isSpace) $ descr)) - . second (splitAt 1) - . break (isPrefixOf "Portability") - . map (dropWhile isSpace) $ concatMap lines xs - modName = maybe path (takeWhile (not . isSpace) . dropWhile isSpace . drop 1 . dropWhile (/=':')) $ find ("Module" `isInfixOf`) hs - in "* \""++modName++"\":\n"++unlines (map (" "++) desc)