Skip to content
Permalink
Browse files

;shake: refactor; add _info_ m4 macro

[ci skip]
  • Loading branch information
simonmichael committed Jan 29, 2020
1 parent e31f644 commit ccac3d6cfa27dbdd23cbb07c552e947dbc6617d3
Showing with 23 additions and 17 deletions.
  1. +17 −17 Shake.hs
  2. +6 −0 doc/common.m4
@@ -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"
@@ -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.

0 comments on commit ccac3d6

Please sign in to comment.
You can’t perform that action at this time.