doc: allow per-package m4 defs, to override things like version
[ci skip]
This commit is contained in:
		
							parent
							
								
									3f4473639a
								
							
						
					
					
						commit
						bf6acf52ef
					
				
							
								
								
									
										23
									
								
								Shake.hs
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								Shake.hs
									
									
									
									
									
								
							| @ -242,15 +242,16 @@ main = do | |||||||
|     phony "manmanuals" $ need nroffmanuals |     phony "manmanuals" $ need nroffmanuals | ||||||
|     nroffmanuals |%> \out -> do -- hledger/hledger.1 |     nroffmanuals |%> \out -> do -- hledger/hledger.1 | ||||||
|       let src       = manpageNameToManualName out <.> "m4.md" |       let src       = manpageNameToManualName out <.> "m4.md" | ||||||
|           lib = "doc/common.m4" |           commonm4  = "doc/common.m4" | ||||||
|           dir       = takeDirectory out |           dir       = takeDirectory out | ||||||
|  |           packagem4 = dir </> "defs.m4" | ||||||
|           tmpl      = "doc/manpage.nroff" |           tmpl      = "doc/manpage.nroff" | ||||||
|       -- assume all other m4 files in dir are included by this one XXX not true in hledger-lib |       -- assume all other m4 files in dir are included by this one XXX not true in hledger-lib | ||||||
|       deps <- liftIO $ filter (/= src) . filter (".m4.md" `isSuffixOf`) . map (dir </>) <$> S.getDirectoryContents dir |       deps <- liftIO $ filter (/= src) . filter (".m4.md" `isSuffixOf`) . map (dir </>) <$> S.getDirectoryContents dir | ||||||
|       need $ src : lib : tmpl : deps |       need $ [src, commonm4, packagem4, tmpl] ++ deps | ||||||
|       when (dir=="hledger") $ need commandmds |       when (dir=="hledger") $ need commandmds | ||||||
|       cmd Shell |       cmd Shell | ||||||
|         "m4 -P -DMAN -I" dir lib src "|" |         "m4 -P -DMAN -I" dir commonm4 packagem4 src "|" | ||||||
|         pandoc fromsrcmd "-s" "--template" tmpl |         pandoc fromsrcmd "-s" "--template" tmpl | ||||||
|         "--lua-filter tools/pandoc-drop-html-blocks.lua" |         "--lua-filter tools/pandoc-drop-html-blocks.lua" | ||||||
|         "--lua-filter tools/pandoc-drop-html-inlines.lua" |         "--lua-filter tools/pandoc-drop-html-inlines.lua" | ||||||
| @ -269,14 +270,15 @@ main = do | |||||||
|     phony "infomanuals" $ need infomanuals |     phony "infomanuals" $ need infomanuals | ||||||
|     infomanuals |%> \out -> do -- hledger/hledger.info |     infomanuals |%> \out -> do -- hledger/hledger.info | ||||||
|       let src       = out -<.> "m4.md" |       let src       = out -<.> "m4.md" | ||||||
|           lib = "doc/common.m4" |           commonm4  = "doc/common.m4" | ||||||
|           dir       = takeDirectory out |           dir       = takeDirectory out | ||||||
|  |           packagem4 = dir </> "defs.m4" | ||||||
|       -- assume all other m4 files in dir are included by this one XXX not true in hledger-lib |       -- assume all other m4 files in dir are included by this one XXX not true in hledger-lib | ||||||
|       deps <- liftIO $ filter (/= src) . filter (".m4.md" `isSuffixOf`) . map (dir </>) <$> S.getDirectoryContents dir |       deps <- liftIO $ filter (/= src) . filter (".m4.md" `isSuffixOf`) . map (dir </>) <$> S.getDirectoryContents dir | ||||||
|       need $ src : lib : deps |       need $ [src, commonm4, packagem4] ++ deps | ||||||
|       when (dir=="hledger") $ need commandmds |       when (dir=="hledger") $ need commandmds | ||||||
|       cmd Shell |       cmd Shell | ||||||
|         "m4 -P -I" dir lib src "|" |         "m4 -P -I" dir commonm4 packagem4 src "|" | ||||||
|         pandoc fromsrcmd |         pandoc fromsrcmd | ||||||
|         "--lua-filter tools/pandoc-drop-html-blocks.lua" |         "--lua-filter tools/pandoc-drop-html-blocks.lua" | ||||||
|         "--lua-filter tools/pandoc-drop-html-inlines.lua" |         "--lua-filter tools/pandoc-drop-html-inlines.lua" | ||||||
| @ -295,18 +297,19 @@ main = do | |||||||
|           manual    = manpageNameToManualName manpage |           manual    = manpageNameToManualName manpage | ||||||
|           dir       = manpageDir manpage |           dir       = manpageDir manpage | ||||||
|           src       = dir </> manual <.> "m4.md" |           src       = dir </> manual <.> "m4.md" | ||||||
|           lib     = "doc/common.m4" |           commonm4  = "doc/common.m4" | ||||||
|  |           packagem4 = dir </> "defs.m4" | ||||||
|           heading   = let h = manual |           heading   = let h = manual | ||||||
|                       in if "hledger_" `isPrefixOf` h |                       in if "hledger_" `isPrefixOf` h | ||||||
|                          then drop 8 h ++ " format" |                          then drop 8 h ++ " format" | ||||||
|                          else h |                          else h | ||||||
|       -- assume all other m4 files in dir are included by this one XXX not true in hledger-lib |       -- assume all other m4 files in dir are included by this one XXX not true in hledger-lib | ||||||
|       deps <- liftIO $ filter (/= src) . filter (".m4.md" `isSuffixOf`) . map (dir </>) <$> S.getDirectoryContents dir |       deps <- liftIO $ filter (/= src) . filter (".m4.md" `isSuffixOf`) . map (dir </>) <$> S.getDirectoryContents dir | ||||||
|       need $ src : lib : deps |       need $ [src, commonm4, packagem4] ++ deps | ||||||
|       when (manual=="hledger") $ need commandmds |       when (manual=="hledger") $ need commandmds | ||||||
|       liftIO $ writeFile out $ "# " ++ heading ++ "\n\n" |       liftIO $ writeFile out $ "# " ++ heading ++ "\n\n" | ||||||
|       cmd Shell |       cmd Shell | ||||||
|         "m4 -P -DMAN -DWEB -I" dir lib src "|" |         "m4 -P -DMAN -DWEB -I" dir commonm4 packagem4 src "|" | ||||||
|         pandoc fromsrcmd towebmd |         pandoc fromsrcmd towebmd | ||||||
|         "--lua-filter tools/pandoc-demote-headers.lua" |         "--lua-filter tools/pandoc-demote-headers.lua" | ||||||
|         ">>" out |         ">>" out | ||||||
| @ -380,10 +383,8 @@ main = do | |||||||
|      |      | ||||||
|     commandtxts |%> \out -> do |     commandtxts |%> \out -> do | ||||||
|       let src = out -<.> "md" |       let src = out -<.> "md" | ||||||
|           -- lib = "doc/common.m4" |  | ||||||
|       need [src] |       need [src] | ||||||
|       cmd Shell |       cmd Shell | ||||||
|         -- "m4 -P -DHELP -I" commandsdir lib src "|" |  | ||||||
|         pandoc fromsrcmd src "--lua-filter" "tools/pandoc-dedent-code-blocks.lua" "-t plain" ">" out |         pandoc fromsrcmd src "--lua-filter" "tools/pandoc-dedent-code-blocks.lua" "-t plain" ">" out | ||||||
| 
 | 
 | ||||||
|     -- CHANGELOGS |     -- CHANGELOGS | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| m4_dnl Common m4 macro definitions used in hledger docs (all packages). | m4_dnl m4 macro definitions used in all hledger package docs. | ||||||
|  | m4_dnl m4 commands in Shake.hs always load this file first. | ||||||
| m4_dnl | m4_dnl | ||||||
| m4_dnl "m4_dnl" causes the rest of the line to be ignored. | m4_dnl "m4_dnl" causes the rest of the line to be ignored. | ||||||
| m4_dnl | m4_dnl | ||||||
| @ -8,6 +9,17 @@ m4_dnl | |||||||
| m4_dnl _MACRO_ will be the naming convention for our macros | m4_dnl _MACRO_ will be the naming convention for our macros | ||||||
| m4_define({{_include_}},     m4_defn({{m4_include}})              )m4_dnl | m4_define({{_include_}},     m4_defn({{m4_include}})              )m4_dnl | ||||||
| m4_dnl | m4_dnl | ||||||
|  | m4_dnl These can be defined here or (with higher precedence) in PACKAGE/defs.m4: | ||||||
|  | m4_dnl | ||||||
|  | m4_dnl Author to show in man pages. | ||||||
|  | m4_define({{_author_}}, {{}})m4_dnl | ||||||
|  | m4_dnl | ||||||
|  | m4_dnl Date to show in man pages. Updated by make setdate. | ||||||
|  | m4_define({{_monthyear_}}, {{February 2019}})m4_dnl | ||||||
|  | m4_dnl | ||||||
|  | m4_dnl Program version. Updated by make setversion. | ||||||
|  | m4_define({{_version_}}, {{1.13}})m4_dnl | ||||||
|  | m4_dnl | ||||||
| m4_dnl Macros for conditionally including format-specific content | 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 $1 is the manual's web slug: hledger, hledger-ui, journal, csv etc. | ||||||
| m4_define({{_man_}},         m4_ifdef({{MAN}},{{$1}})             )m4_dnl | m4_define({{_man_}},         m4_ifdef({{MAN}},{{$1}})             )m4_dnl | ||||||
| @ -15,11 +27,6 @@ m4_define({{_web_}},         m4_ifdef({{WEB}},{{$1}})             )m4_dnl | |||||||
| m4_define({{_webseparate_}}, m4_ifdef({{WEB && SEPARATE}},{{$1}}) )m4_dnl | m4_define({{_webseparate_}}, m4_ifdef({{WEB && SEPARATE}},{{$1}}) )m4_dnl | ||||||
| m4_define({{_webcombined_}}, m4_ifdef({{WEB && COMBINED}},{{$1}}) )m4_dnl | m4_define({{_webcombined_}}, m4_ifdef({{WEB && COMBINED}},{{$1}}) )m4_dnl | ||||||
| m4_dnl | m4_dnl | ||||||
| m4_dnl Author/date/version macros. These are updated by make setdate, setversion etc. |  | ||||||
| m4_define({{_author_}}, {{}})m4_dnl |  | ||||||
| m4_define({{_monthyear_}}, {{February 2019}})m4_dnl |  | ||||||
| m4_define({{_version_}}, {{1.13}})m4_dnl |  | ||||||
| m4_dnl |  | ||||||
| m4_dnl Links to dev and recent release versions of a manual. | 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. | m4_dnl The actual links are inserted dynamically by site.js, static generation was much too painful. | ||||||
| m4_dnl There should be a " (dev)" suffix here except when generating release docs. | m4_dnl There should be a " (dev)" suffix here except when generating release docs. | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								hledger-api/defs.m4
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								hledger-api/defs.m4
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | m4_dnl m4 macro definitions used in this package's docs. | ||||||
|  | m4_dnl | ||||||
|  | m4_define({{_version_}}, {{1.13}})m4_dnl | ||||||
							
								
								
									
										3
									
								
								hledger-lib/defs.m4
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								hledger-lib/defs.m4
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | m4_dnl m4 macro definitions used in this package's docs. | ||||||
|  | m4_dnl | ||||||
|  | m4_define({{_version_}}, {{1.13.1}})m4_dnl | ||||||
							
								
								
									
										3
									
								
								hledger-ui/defs.m4
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								hledger-ui/defs.m4
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | m4_dnl m4 macro definitions used in this package's docs. | ||||||
|  | m4_dnl | ||||||
|  | m4_define({{_version_}}, {{1.13}})m4_dnl | ||||||
							
								
								
									
										3
									
								
								hledger-web/defs.m4
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								hledger-web/defs.m4
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | m4_dnl m4 macro definitions used in this package's docs. | ||||||
|  | m4_dnl | ||||||
|  | m4_define({{_version_}}, {{1.13}})m4_dnl | ||||||
							
								
								
									
										3
									
								
								hledger/defs.m4
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								hledger/defs.m4
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | m4_dnl m4 macro definitions used in this package's docs. | ||||||
|  | m4_dnl | ||||||
|  | m4_define({{_version_}}, {{1.13.2}})m4_dnl | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user