From ccac3d6cfa27dbdd23cbb07c552e947dbc6617d3 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 29 Jan 2020 06:01:09 -0800 Subject: [PATCH] ;shake: refactor; add _info_ m4 macro [ci skip] --- Shake.hs | 34 +++++++++++++++++----------------- doc/common.m4 | 6 ++++++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Shake.hs b/Shake.hs index f65ad9c28..07dc62ee2 100755 --- a/Shake.hs +++ b/Shake.hs @@ -260,21 +260,7 @@ main = do ,webmanuals ] - -- Generate plain text manuals suitable for embedding in - -- executables and viewing with a pager. - phony "txtmanuals" $ need txtmanuals - txtmanuals |%> \out -> do -- hledger/hledger.txt - let src = manualNameToManpageName $ dropExtension out - need [src] - -- cmd Shell groff "-t -e -mandoc -Tascii" src "| col -b >" out -- http://www.tldp.org/HOWTO/Man-Page/q10.html - -- Workaround: groff 1.22.4 always calls grotty in a way that adds ANSI/SGR escape codes. - -- (groff -c is supposed to switch those to backspaces, which we could - -- remove with col -b, but it doesn't as can be seen with groff -V.) - -- To get plain text, we run groff's lower-level commands (from -V) and add -cbuo. - -- -Wall silences most troff warnings, remove to see them - cmd Shell "tbl" src "| eqn -Tascii | troff -Wall -mandoc -Tascii | grotty -cbuo >" out - - -- Generate nroff man pages suitable for man output. + -- Generate nroff man pages suitable for man output, from the .m4.md source. phony "nroffmanuals" $ need nroffmanuals nroffmanuals |%> \out -> do -- hledger/hledger.1 let src = manpageNameToManualName out <.> "m4.md" @@ -294,7 +280,21 @@ main = do "--lua-filter tools/pandoc-drop-links.lua" "-o" out - -- Generate Info manuals suitable for viewing with info. + -- Generate plain text manuals suitable for embedding in + -- executables and viewing with a pager, from the man pages. + phony "txtmanuals" $ need txtmanuals + txtmanuals |%> \out -> do -- hledger/hledger.txt + let src = manualNameToManpageName $ dropExtension out + need [src] + -- cmd Shell groff "-t -e -mandoc -Tascii" src "| col -b >" out -- http://www.tldp.org/HOWTO/Man-Page/q10.html + -- Workaround: groff 1.22.4 always calls grotty in a way that adds ANSI/SGR escape codes. + -- (groff -c is supposed to switch those to backspaces, which we could + -- remove with col -b, but it doesn't as can be seen with groff -V.) + -- To get plain text, we run groff's lower-level commands (from -V) and add -cbuo. + -- -Wall silences most troff warnings, remove to see them + cmd Shell "tbl" src "| eqn -Tascii | troff -Wall -mandoc -Tascii | grotty -cbuo >" out + + -- Generate Info manuals suitable for viewing with info, from the .m4.md source. phony "infomanuals" $ need infomanuals infomanuals |%> \out -> do -- hledger/hledger.info let src = out -<.> "m4.md" @@ -306,7 +306,7 @@ main = do need $ [src, commonm4, packagem4] ++ deps when (dir=="hledger") $ need commandmds cmd Shell - "m4 -P -I" dir commonm4 packagem4 src "|" + "m4 -P -DINFO -I" dir commonm4 packagem4 src "|" pandoc fromsrcmd "--lua-filter tools/pandoc-drop-html-blocks.lua" "--lua-filter tools/pandoc-drop-html-inlines.lua" diff --git a/doc/common.m4 b/doc/common.m4 index 4eb5077e7..4ae37efbc 100644 --- a/doc/common.m4 +++ b/doc/common.m4 @@ -15,8 +15,14 @@ m4_define({{_author_}}, {{}})m4_dnl m4_dnl m4_dnl Macros for conditionally including format-specific content m4_dnl $1 is the manual's web slug: hledger, hledger-ui, journal, csv etc. +m4_dnl include in man pages only m4_define({{_man_}}, m4_ifdef({{MAN}},{{$1}}) )m4_dnl +m4_dnl include in web manuals only m4_define({{_web_}}, m4_ifdef({{WEB}},{{$1}}) )m4_dnl +m4_dnl include in info manuals only +m4_define({{_info_}}, m4_ifdef({{INFO}},{{$1}}) )m4_dnl +m4_dnl include in text manuals only - not implemented +m4_dnl m4_define({{_txt_}}, m4_ifdef({{TXT}},{{$1}}) )m4_dnl m4_dnl m4_dnl Links to dev and recent release versions of a manual. m4_dnl The actual links are inserted dynamically by site.js, static generation was much too painful.