Generate man page in cabal build process and include in data/.

The pandoc.1 man page is generated automatically after the cabal
build process.  It goes in `data/pandoc.1`.  It can be obtained
by the user who installs pandoc via cabal thus:

    pandoc --print-default-data-file pandoc.1 > pandoc.1
This commit is contained in:
John MacFarlane 2015-07-01 16:29:44 -07:00
parent 958a615b75
commit 28cb50503b
6 changed files with 23 additions and 16 deletions

View file

@ -77,7 +77,7 @@ Quick install
To build the `pandoc.1` man page:
make man/man1/pandoc.1
pandoc --print-default-data-file pandoc.1 > pandoc.1
To build the `pandoc-citeproc` man pages, go to the pandoc-citeproc
build directory, and

View file

@ -40,21 +40,11 @@ debpkg:
osxpkg:
./make_osx_package.sh
man/man1/pandoc.1: README man/pandoc.1.template
@[ -n "$(pandoc)" ] || \
(echo "Could not find pandoc in dist/" && exit 1)
$(pandoc) $< -t man -s --template man/pandoc.1.template \
--filter man/capitalizeHeaders.hs \
--filter man/removeNotes.hs \
--filter man/removeLinks.hs \
-o $@
download_stats:
curl https://api.github.com/repos/jgm/pandoc/releases | \
jq '[.[] | .assets | .[] | {name: .name, download_count: .download_count}]'
clean:
cabal clean
-rm man/man1/pandoc.1
.PHONY: deps quick full install man clean test bench haddock osxpkg dist bindist prof download_stats
.PHONY: deps quick full install clean test bench osxpkg dist prof download_stats

View file

@ -31,6 +31,8 @@ main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks {
-- enable hsb2hs preprocessor for .hsb files
hookedPreProcessors = [ppBlobSuffixHandler]
, postBuild = \args bf pkgdescr lbi ->
makeManPages args bf pkgdescr lbi
}
ppBlobSuffixHandler :: PPSuffixHandler
@ -45,3 +47,18 @@ ppBlobSuffixHandler = ("hsb", \_ _ ->
Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs"
return ()
})
makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo
-> IO ()
makeManPages _ bf _ LocalBuildInfo{buildDir=buildDir}
= do info verbosity "Creating data/pandoc.1"
rawSystemExit verbosity progPath args
where verbosity = fromFlagOrDefault normal $ buildVerbosity bf
progPath = buildDir </> "pandoc" </> "pandoc"
args = ["README", "-t", "man", "-s",
"--template", "man/pandoc.1.template",
"--filter", "man/capitalizeHeaders.hs",
"--filter", "man/removeNotes.hs",
"--filter", "man/removeLinks.hs",
"-o", "data/pandoc.1"]

View file

@ -30,7 +30,6 @@ echo Building pandoc...
cabal clean
cabal install --force --reinstall --flags="embed_data_files make-pandoc-man-pages" . pandoc-citeproc
make -B man/man1/pandoc.1
# get pandoc-citeproc man page:
PANDOC_CITEPROC_PATH=`cabal unpack -d make_binary_package.tmp.$$ pandoc-citeproc | awk '{print $3;}'`
strip $SANDBOX/bin/pandoc
@ -43,7 +42,7 @@ mkdir -p $DEST/share/doc/pandoc-citeproc
find $DIST -type d | xargs chmod 755
cp $SANDBOX/bin/pandoc $DEST/bin/
cp $SANDBOX/bin/pandoc-citeproc $DEST/bin/
cp man/man1/pandoc.1 $DEST/share/man/man1/pandoc.1
$SANDBOX/bin/pandoc --print-default-data-file pandoc.1 > $DEST/share/man/man1/pandoc.1
gzip -9 $DEST/share/man/man1/pandoc.1
cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
gzip -9 $DEST/share/man/man1/pandoc-citeproc.1

View file

@ -27,7 +27,6 @@ cabal clean
cabal install cpphs hsb2hs
cabal install --ghc-options="-optl-mmacosx-version-min=10.6" --reinstall --flags="embed_data_files make-pandoc-man-pages" --ghc-options "-pgmP$CPPHS -optP--cpp" . pandoc-citeproc
make -B man/man1/pandoc.1
# get pandoc-citeproc man page:
PANDOC_CITEPROC_PATH=`cabal unpack -d $DIST pandoc-citeproc | awk '{print $3;}'`
@ -38,7 +37,7 @@ for f in pandoc pandoc-citeproc; do
cp $SANDBOX/bin/$f $DEST/bin/;
done
cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
cp man/man1/pandoc.1 $DEST/share/man/man1/pandoc.1
$SANDBOX/bin/pandoc --print-default-data-file pandoc.1 > $DEST/share/man/man1/pandoc.1
chown -R $ME:staff $DIST

View file

@ -106,6 +106,8 @@ Data-Files:
data/sample.lua
-- documentation
README, COPYRIGHT
-- man page (generated by Setup.hs after build:)
data/pandoc.1
Extra-Source-Files:
-- documentation
INSTALL, BUGS, CONTRIBUTING.md, changelog