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 haddock -h -o doc *.hs
overview: overview:
runhaskell ./overview.hs >.ovtmp; mv .ovtmp OVERVIEW ./overview.hs hledger.hs
loc: loc:
@darcs trackdown 'find . -name "*hs" |xargs wc -l |echo OUTPUT `tail -1`; false' |ruby -nae'puts $$F[1] if /^OUTPUT/' @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 #!/usr/bin/env runhaskell
-- {-
-- OVERVIEW should begin with a list of module names (updated manually); overview.hs - print an overview of functions from a given list of modules
-- below that we generate a list of filename, function, type entries.
-- Useful for getting the big picture and refactoring. 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
import System.Process import System.Process
@ -11,11 +21,16 @@ import Data.List
import Text.Printf import Text.Printf
main = do main = do
old <- readFile "OVERVIEW" args <- getArgs
let preamble = takeWhile ((> 0) . length) $ lines old file <- readFile $ head args
putStr $ unlines preamble let mods = takeWhile ((> 0) . length) $
let modules = concat $ map ((++ ".hs ") . dropWhile (== ' ')) preamble dropWhile ((== 0) . length) $
let grep = "grep -H '^\\w[^=]*::' " ++ modules 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 (inp, out, err, pid) <- runInteractiveCommand grep
waitForProcess pid waitForProcess pid
grepoutput <- hGetContents out grepoutput <- hGetContents out