doc: use macros not divs to select web/man content
Use slightly clearer m4 macros instead of special divs to mark content as web only/man only. The temporary doc/*.md files are no longer needed, slightly more redundant work is done.
This commit is contained in:
		
							parent
							
								
									6787decca2
								
							
						
					
					
						commit
						4c291dc54e
					
				
							
								
								
									
										44
									
								
								Shake.hs
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								Shake.hs
									
									
									
									
									
								
							| @ -97,8 +97,6 @@ main = do | ||||
|         ] | ||||
|       -- manuals m4 source, may include other files (hledger/doc/hledger.1.m4.md) | ||||
|       m4manpages = [manpageDir m </> m <.> "m4.md" | m <- manpageNames] | ||||
|       --  manuals rendered to markdown, ready for adjusting to web or man pages by pandoc (hledger/doc/hledger.1.md) | ||||
|       mdmanpages = [manpageDir m </> m <.> "md" | m <- manpageNames] | ||||
|       --   manuals rendered to nroff, ready for man (hledger/doc/hledger.1) | ||||
|       nroffmanpages = [manpageDir m </> m | m <- manpageNames] | ||||
|       --    manuals rendered to text, ready for embedding (hledger/doc/hledger.1.txt) | ||||
| @ -135,26 +133,21 @@ main = do | ||||
| 
 | ||||
|     -- man pages | ||||
| 
 | ||||
|     -- process m4 includes and macros to get markdown, ready for further processing by pandoc | ||||
|     mdmanpages |%> \out -> do -- hledger/doc/hledger.1.md | ||||
|       let dir = takeDirectory out | ||||
|           src = out -<.> "m4.md" | ||||
|           lib = "doc/lib.m4" | ||||
|       -- 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 | ||||
|       need $ src : lib : deps | ||||
|       cmd Shell "m4 -P -DWEB -DMAN -I" dir lib src ">" out | ||||
| 
 | ||||
|     -- adjust man page mds for man output and convert to nroff, with pandoc | ||||
|     -- use m4 and pandoc to process macros, filter content, and convert to nroff suitable for man output | ||||
|     phony "manpages" $ need nroffmanpages | ||||
| 
 | ||||
|     nroffmanpages |%> \out -> do -- hledger/doc/hledger.1 | ||||
|       let src  = out <.> "md" | ||||
|       let src = out <.> "m4.md" | ||||
|           lib = "doc/lib.m4" | ||||
|           dir = takeDirectory out | ||||
|           tmpl = "doc/manpage.nroff" | ||||
|       need $ src : tmpl : pandocFilters | ||||
|       cmd pandoc src "-s --template" tmpl | ||||
|         "--filter doc/pandoc-drop-web-blocks" | ||||
|       -- 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 | ||||
|       need $ src : lib : tmpl : deps ++ pandocFilters | ||||
|       cmd Shell | ||||
|         "m4 -P -DMAN -I" dir lib src "|" | ||||
|         pandoc "-f markdown -s --template" tmpl | ||||
|         -- "--filter doc/pandoc-drop-web-blocks" | ||||
|         "--filter doc/pandoc-drop-html-blocks" | ||||
|         "--filter doc/pandoc-drop-html-inlines" | ||||
|         "--filter doc/pandoc-drop-links" | ||||
| @ -180,19 +173,25 @@ main = do | ||||
|         ] | ||||
|       cmd Shell (Cwd "site") "hakyll-std/hakyll-std" "build" | ||||
| 
 | ||||
|     -- adjust man page mds for web output, with pandoc | ||||
|     -- use m4 and pandoc to process macros and filter content, leaving markdown suitable for web output | ||||
|     phony "webmanpages" $ need webmanpages | ||||
| 
 | ||||
|     webmanpages |%> \out -> do -- site/hledger.md | ||||
|       let m       = manpageUriToName $ dropExtension $ takeFileName out -- hledger.1 | ||||
|           src     = manpageDir m </> m <.> "md" -- hledger/doc/hledger.1.md | ||||
|           dir     = manpageDir m | ||||
|           src     = dir </> m <.> "m4.md" | ||||
|           lib     = "doc/lib.m4" | ||||
|           heading = let h = dropExtension m | ||||
|                     in if "hledger_" `isPrefixOf` h | ||||
|                        then drop 8 h ++ " format" | ||||
|                        else h | ||||
|       need $ src : pandocFilters | ||||
|       -- 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 | ||||
|       need $ src : lib : deps ++ pandocFilters | ||||
|       liftIO $ writeFile out $ "# " ++ heading ++ "\n\n" | ||||
|       cmd Shell pandoc src "-t markdown --atx-headers" | ||||
|       cmd Shell | ||||
|         "m4 -P -DMAN -DWEB -I" dir lib src "|" | ||||
|         pandoc "-f markdown -t markdown --atx-headers" | ||||
|         "--filter doc/pandoc-demote-headers" | ||||
|         -- "--filter doc/pandoc-add-toc" | ||||
|         -- "--filter doc/pandoc-drop-man-blocks" | ||||
| @ -231,7 +230,6 @@ main = do | ||||
| 
 | ||||
|     phony "clean" $ do | ||||
|       putNormal "Cleaning generated files" | ||||
|       removeFilesAfter "." mdmanpages | ||||
|       removeFilesAfter "." webmanpages | ||||
|       removeFilesAfter "." [webmanual] | ||||
| 
 | ||||
|  | ||||
| @ -2,12 +2,12 @@ | ||||
| % | ||||
| % January 2016 | ||||
| 
 | ||||
| <div class="web"> | ||||
| _web_({{ | ||||
| _versions_({{hledger-api}}) | ||||
| 
 | ||||
| * toc | ||||
| </div> | ||||
| <div class="man"> | ||||
| }}) | ||||
| _man_({{ | ||||
| 
 | ||||
| # NAME | ||||
| 
 | ||||
| @ -24,7 +24,7 @@ hledger is a cross-platform program for tracking money, time, or any other commo | ||||
| using double-entry accounting and a simple, editable file format. | ||||
| hledger is inspired by and largely compatible with ledger(1). | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
| 
 | ||||
| hledger-api is a simple web API server, intended to support | ||||
| client-side web apps operating on hledger data. It comes with a series | ||||
| @ -110,7 +110,7 @@ access. | ||||
| <!-- `-B --cost` --> | ||||
| <!-- : show amounts in their cost price's commodity --> | ||||
| 
 | ||||
| <div class="man"> | ||||
| _man_({{ | ||||
| 
 | ||||
| # ENVIRONMENT | ||||
| 
 | ||||
| @ -142,4 +142,4 @@ The need to precede options with `--` when invoked from hledger is awkward. | ||||
| <!-- appear to run normally, but you will be seeing pages served from the --> | ||||
| <!-- first one. --> | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
|  | ||||
| @ -2,12 +2,12 @@ | ||||
| % | ||||
| % April 2016 | ||||
| 
 | ||||
| <div class="web"> | ||||
| _web_({{ | ||||
| _versions_({{csv}}) | ||||
| 
 | ||||
| * toc | ||||
| </div> | ||||
| <div class="man"> | ||||
| }}) | ||||
| _man_({{ | ||||
| 
 | ||||
| # NAME | ||||
| 
 | ||||
| @ -15,7 +15,7 @@ CSV - how hledger reads CSV data, and the CSV rules file format | ||||
| 
 | ||||
| # DESCRIPTION | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
| 
 | ||||
| hledger can read | ||||
| [CSV](http://en.wikipedia.org/wiki/Comma-separated_values) files, | ||||
|  | ||||
| @ -2,12 +2,12 @@ | ||||
| % | ||||
| % April 2016 | ||||
| 
 | ||||
| <div class="web"> | ||||
| _web_({{ | ||||
| _versions_({{journal}}) | ||||
| 
 | ||||
| * toc | ||||
| </div> | ||||
| <div class="man"> | ||||
| }}) | ||||
| _man_({{ | ||||
| 
 | ||||
| # NAME | ||||
| 
 | ||||
| @ -15,7 +15,7 @@ Journal - hledger's default file format, representing a General Journal | ||||
| 
 | ||||
| # DESCRIPTION | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
| 
 | ||||
| hledger's usual data source is a plain text file containing journal entries in hledger journal format. | ||||
| This file represents a standard accounting [general journal](http://en.wikipedia.org/wiki/General_journal). | ||||
|  | ||||
| @ -2,12 +2,12 @@ | ||||
| %  | ||||
| % April 2016 | ||||
| 
 | ||||
| <div class="web"> | ||||
| _web_({{ | ||||
| _versions_({{timeclock}}) | ||||
| 
 | ||||
| * toc | ||||
| </div> | ||||
| <div class="man"> | ||||
| }}) | ||||
| _man_({{ | ||||
| 
 | ||||
| # NAME | ||||
| 
 | ||||
| @ -15,7 +15,7 @@ Timeclock - the time logging format of timeclock.el, as read by hledger | ||||
| 
 | ||||
| # DESCRIPTION | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
| 
 | ||||
| hledger can read timeclock files. | ||||
| [As with Ledger](http://ledger-cli.org/3.0/doc/ledger3.html#Time-Keeping), | ||||
|  | ||||
| @ -2,12 +2,12 @@ | ||||
| % | ||||
| % April 2016 | ||||
| 
 | ||||
| <div class="web"> | ||||
| _web_({{ | ||||
| _versions_({{timedot}}) | ||||
| 
 | ||||
| * toc | ||||
| </div> | ||||
| <div class="man"> | ||||
| }}) | ||||
| _man_({{ | ||||
| 
 | ||||
| # NAME | ||||
| 
 | ||||
| @ -15,7 +15,7 @@ Timedot - hledger's human-friendly time logging format | ||||
| 
 | ||||
| # DESCRIPTION | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
| 
 | ||||
| Timedot is a plain text format for logging dated, categorised quantities (eg time), supported by hledger. | ||||
| It is convenient for approximate and retroactive time logging, | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| % | ||||
| % October 2015 | ||||
| 
 | ||||
| <div class="web"> | ||||
| _web_({{ | ||||
| _versions_({{hledger-ui}}) | ||||
| 
 | ||||
| * toc | ||||
| @ -20,8 +20,8 @@ _versions_({{hledger-ui}}) | ||||
| <a href="images/hledger-ui/hledger-ui-bcexample-acc.png" class="highslide" onclick="return hs.expand(this)"><img src="images/hledger-ui/hledger-ui-bcexample-acc.png" title="beancount example accounts" /></a> | ||||
| <a href="images/hledger-ui/hledger-ui-bcexample-acc-etrade:cash.png" class="highslide" onclick="return hs.expand(this)"><img src="images/hledger-ui/hledger-ui-bcexample-acc-etrade:cash.png" title="beancount example's etrade cash subaccount" /></a> | ||||
| <a href="images/hledger-ui/hledger-ui-bcexample-acc-etrade.png" class="highslide" onclick="return hs.expand(this)"><img src="images/hledger-ui/hledger-ui-bcexample-acc-etrade.png" title="beancount example's etrade investments, all commoditiess" /></a> | ||||
| </div> | ||||
| <div class="man"> | ||||
| }}) | ||||
| _man_({{ | ||||
| 
 | ||||
| # NAME | ||||
| 
 | ||||
| @ -38,13 +38,13 @@ hledger is a cross-platform program for tracking money, time, or any other commo | ||||
| using double-entry accounting and a simple, editable file format. | ||||
| hledger is inspired by and largely compatible with ledger(1). | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
| 
 | ||||
| hledger-ui is hledger's curses-style interface. | ||||
| It reads a hledger journal file | ||||
| <div class="man"> | ||||
| _man_({{ | ||||
| (~/.hledger.journal, $LEDGER_FILE, or -f FILE; see hledger(1) or hledger_journal(5)) | ||||
| </div> | ||||
| }}) | ||||
| and provides a simple full-screen console interface for viewing account balances and transactions. | ||||
| 
 | ||||
| It is simpler and more convenient for | ||||
| @ -231,7 +231,7 @@ This screen will appear if there is a problem, such as a parse error, | ||||
| when you press g to reload. Once you have fixed the problem described, | ||||
| press g again to reload and restore normal operation. | ||||
| 
 | ||||
| <div class="man"> | ||||
| _man_({{ | ||||
| 
 | ||||
| # ENVIRONMENT | ||||
| 
 | ||||
| @ -263,4 +263,4 @@ The register screen's switching between historic balance and running | ||||
| total based on query arguments may be confusing, and there is no | ||||
| column heading to indicate which is being displayed. | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
|  | ||||
| @ -2,12 +2,12 @@ | ||||
| % | ||||
| % October 2015 | ||||
| 
 | ||||
| <div class="web"> | ||||
| _web_({{ | ||||
| _versions_({{hledger-web}}) | ||||
| 
 | ||||
| * toc | ||||
| </div> | ||||
| <div class="man"> | ||||
| }}) | ||||
| _man_({{ | ||||
| # NAME | ||||
| 
 | ||||
| hledger-web - web interface for the hledger accounting tool | ||||
| @ -32,7 +32,7 @@ hledger-web - web interface for the hledger accounting tool | ||||
| hledger is a cross-platform program for tracking money, time, or any other commodity, | ||||
| using double-entry accounting and a simple, editable file format. | ||||
| hledger is inspired by and largely compatible with ledger(1). | ||||
| </div> | ||||
| }}) | ||||
| 
 | ||||
| hledger-web is hledger's web interface.  It starts a simple web | ||||
| application for browsing and adding transactions, and optionally | ||||
| @ -176,7 +176,7 @@ The following common hledger options should also work: | ||||
| `-B --cost` | ||||
| : show amounts in their cost price's commodity | ||||
| 
 | ||||
| <div class="man"> | ||||
| _man_({{ | ||||
| 
 | ||||
| # ENVIRONMENT | ||||
| 
 | ||||
| @ -208,4 +208,4 @@ If you start two instances on the same port, the second one will | ||||
| appear to run normally, but you will be seeing pages served from the | ||||
| first one. | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
|  | ||||
| @ -2,12 +2,12 @@ | ||||
| % | ||||
| % April 2016 | ||||
| 
 | ||||
| <div class="web"> | ||||
| _web_({{ | ||||
| _versions_({{hledger}}) | ||||
| 
 | ||||
| * toc | ||||
| </div> | ||||
| <div class="man"> | ||||
| }}) | ||||
| _man_({{ | ||||
| 
 | ||||
| # NAME | ||||
| 
 | ||||
| @ -26,16 +26,14 @@ file format. It is inspired by and largely compatible with ledger(1). | ||||
| Tested on unix, mac, windows, hledger aims to be a reliable, practical | ||||
| tool for daily use. | ||||
| 
 | ||||
| </div> | ||||
| 
 | ||||
| }}) | ||||
| _include_(description.m4.md) | ||||
| _include_(examples.m4.md) | ||||
| _include_(options.m4.md) | ||||
| _include_(queries.m4.md) | ||||
| _include_(commands.m4.md) | ||||
| _include_(troubleshooting.m4.md) | ||||
| 
 | ||||
| <div class="man"> | ||||
| _man_({{ | ||||
| 
 | ||||
| # ENVIRONMENT | ||||
| 
 | ||||
| @ -60,4 +58,4 @@ hledger can't render non-ascii characters when run from a Windows command prompt | ||||
| When input data contains non-ascii characters, a suitable system locale must be configured (or there will be an unhelpful error). | ||||
| Eg on POSIX, set LANG to something other than C. | ||||
| 
 | ||||
| </div> | ||||
| }}) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user