make overview pull list from source file

This commit is contained in:
Simon Michael 2007-05-02 02:05:14 +00:00
parent f89cd1867d
commit be560eb290
2 changed files with 26 additions and 11 deletions

View File

@ -19,7 +19,7 @@ haddock:
haddock -h -o doc *.hs
overview:
runhaskell ./overview.hs >.ovtmp; mv .ovtmp OVERVIEW
./overview.hs hledger.hs
loc:
@darcs trackdown 'find . -name "*hs" |xargs wc -l |echo OUTPUT `tail -1`; false' |ruby -nae'puts $$F[1] if /^OUTPUT/'

View File

@ -1,8 +1,18 @@
-- overview.hs - update an OVERVIEW file
--
-- OVERVIEW should begin with a list of module names (updated manually);
-- below that we generate a list of filename, function, type entries.
-- Useful for getting the big picture and refactoring.
#!/usr/bin/env runhaskell
{-
overview.hs - print an overview of functions from a given list of modules
Usage: ./overview.hs somefile
where somefile, typically your main module, contains the word "overview"
followed by a blank-line-delimited list of module names, like so:
firstmodule
anothermodule
submodule
Useful for getting the big picture and refactoring.
-}
import System
import System.Process
@ -11,11 +21,16 @@ import Data.List
import Text.Printf
main = do
old <- readFile "OVERVIEW"
let preamble = takeWhile ((> 0) . length) $ lines old
putStr $ unlines preamble
let modules = concat $ map ((++ ".hs ") . dropWhile (== ' ')) preamble
let grep = "grep -H '^\\w[^=]*::' " ++ modules
args <- getArgs
file <- readFile $ head args
let mods = takeWhile ((> 0) . length) $
dropWhile ((== 0) . length) $
dropWhile ((> 0) . length) $
dropWhile (notElem "overview:" . words) $
lines file
putStr $ unlines mods
let files = concat $ map ((++ ".hs ") . dropWhile (== ' ')) mods
let grep = "grep -H '^\\w[^=]*::' " ++ files
(inp, out, err, pid) <- runInteractiveCommand grep
waitForProcess pid
grepoutput <- hGetContents out