1import Distribution.Simple
2import Distribution.PackageDescription ( emptyHookedBuildInfo )
3import Control.Exception ( bracket_ )
4import System.Process ( runCommand, runProcess, waitForProcess )
5import System.FilePath ( (</>), (<.>) )
7import System.IO ( stderr )
10import System.IO.Error ( isDoesNotExistError )
11import Data.Maybe ( fromJust, isNothing, catMaybes )
13main = defaultMainWithHooks $
14 simpleUserHooks { runTests = runTestSuite
15 , postBuild = makeManPages }
18runTestSuite _ _ _ _ = do
19 inDirectory "tests" $ runCommand "runhaskell -i.. RunTests.hs" >>= waitForProcess
22-- | Build man pages from markdown sources in man/man1/.
23makeManPages _ _ _ _ = do
24 mapM makeManPage ["pandoc.1", "hsmarkdown.1", "html2markdown.1", "markdown2pdf.1"]
27-- | Build a man page from markdown source in man/man1.
28makeManPage manpage = do
29 let manDir = "man" </> "man1"
30 let pandoc = "dist" </> "build" </> "pandoc" </> "pandoc"
31 let page = manDir </> manpage
32 let source = manDir </> manpage <.> "md"
33 modifiedDeps <- modifiedDependencies page [source]
37 ec <- runProcess pandoc ["-s", "-S", "-r", "markdown", "-w", "man", "-o", page, source]
38 Nothing Nothing Nothing Nothing (Just stderr) >>= waitForProcess
40 ExitSuccess -> putStrLn $ "Created " ++ manDir </> manpage
41 _ -> error $ "Error creating " ++ manDir </> manpage
43-- | Returns a list of 'dependencies' that have been modified after 'file'.
44modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath]
45modifiedDependencies file dependencies = do
46 fileModTime <- catch (getModificationTime file) $
47 \e -> if isDoesNotExistError e
48 then return (TOD 0 0) -- the minimum ClockTime
50 depModTimes <- mapM getModificationTime dependencies
51 let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes
52 return $ catMaybes modified
54-- | Perform an IO action in a directory.
55inDirectory :: FilePath -> IO a -> IO a
56inDirectory dir action = do
57 oldDir <- getCurrentDirectory
58 bracket_ (setCurrentDirectory dir) (setCurrentDirectory oldDir) action
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list