From be560eb290e2cf3e7e022c23741753e1543bb921 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 2 May 2007 02:05:14 +0000 Subject: [PATCH] make overview pull list from source file --- Makefile | 2 +- overview.hs | 35 +++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 2685e3a6d..a0545dfa9 100644 --- a/Makefile +++ b/Makefile @@ -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/' diff --git a/overview.hs b/overview.hs index 8cf6b2a19..00410da1c 100644 --- a/overview.hs +++ b/overview.hs @@ -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