3Copyright (C) 2006-2014 John MacFarlane <jgm@berkeley.edu>
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation; either version 2 of the License, or
8(at your option) any later version.
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20import Distribution.Simple
21import Distribution.Simple.PreProcess
22import Distribution.Simple.Setup
23 (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..),
25import Distribution.PackageDescription (PackageDescription(..), Executable(..))
26import Distribution.Simple.LocalBuildInfo
27 (LocalBuildInfo(..), absoluteInstallDirs)
28import Distribution.Verbosity ( Verbosity, silent )
29import Distribution.Simple.InstallDirs (mandir, CopyDest (NoCopyDest), toPathTemplate)
30import Distribution.Simple.Utils (installOrdinaryFiles, info)
31import Distribution.Simple.Test (test)
32import System.Process ( rawSystem )
33import System.FilePath ( (</>) )
34import System.Directory ( findExecutable )
39 defaultMainWithHooks $ simpleUserHooks {
40 postBuild = makeManPages
41 , testHook = \pkg lbi _ flags ->
42 -- pass build directory as first argument to test program
43 test pkg lbi flags{ testOptions =
44 toPathTemplate (buildDir lbi) : testOptions flags }
45 , postCopy = \ _ flags pkg lbi ->
46 installManpages pkg lbi (fromFlag $ copyVerbosity flags)
47 (fromFlag $ copyDest flags)
48 , postInst = \ _ flags pkg lbi ->
49 installManpages pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest
50 , copyHook = \pkgdescr ->
51 (copyHook simpleUserHooks) pkgdescr{ executables =
52 [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
53 , instHook = \pkgdescr ->
54 (instHook simpleUserHooks) pkgdescr{ executables =
55 [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
56 , hookedPreProcessors = [ppBlobSuffixHandler]
60-- | Build man pages from markdown sources in man/
61makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
62makeManPages _ flags _ lbi = do
63 let verbosity = fromFlag $ buildVerbosity flags
64 let args = ["--verbose" | verbosity /= silent]
65 rawSystem (buildDir lbi </> "make-pandoc-man-pages" </> "make-pandoc-man-pages")
69manpages = ["man1" </> "pandoc.1"
70 ,"man5" </> "pandoc_markdown.5"]
75installManpages :: PackageDescription -> LocalBuildInfo
76 -> Verbosity -> CopyDest -> IO ()
77installManpages pkg lbi verbosity copy =
78 installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy))
79 (zip (repeat manDir) manpages)
81ppBlobSuffixHandler :: PPSuffixHandler
82ppBlobSuffixHandler = ("hsb", \_ _ ->
84 platformIndependent = True,
85 runPreProcessor = mkSimplePreProcessor $ \infile outfile verbosity ->
86 do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile
87 hsb2hsPath <- findExecutable "hsb2hs"
89 Just p -> rawSystem p [infile, infile, outfile]
90 Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs"
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