shake: also generate static html from wiki pages
A copy of the github wiki is assumed to be checked out in ./wiki/ [ci skip]
This commit is contained in:
		
							parent
							
								
									ba1abae7c9
								
							
						
					
					
						commit
						ce2ef2497a
					
				
							
								
								
									
										32
									
								
								Shake.hs
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								Shake.hs
									
									
									
									
									
								
							| @ -68,6 +68,8 @@ usage = unlines | |||||||
|   ,"./Shake website          build the website and web manuals" |   ,"./Shake website          build the website and web manuals" | ||||||
|   ,"./Shake all              build all the above" |   ,"./Shake all              build all the above" | ||||||
|   ,"" |   ,"" | ||||||
|  |   ,"./Shake mainpages                   build the web pages from the main repo" | ||||||
|  |   ,"./Shake wikipages                   build the web pages from the wiki repo" | ||||||
|   ,"./Shake FILE                        build any individual file" |   ,"./Shake FILE                        build any individual file" | ||||||
|   ,"./Shake setversion                  update all packages from PKG/.version" |   ,"./Shake setversion                  update all packages from PKG/.version" | ||||||
|   ,"./Shake changelogs                  update the changelogs with any new commits" |   ,"./Shake changelogs                  update the changelogs with any new commits" | ||||||
| @ -107,6 +109,8 @@ main = do | |||||||
|   let commandsdir = "hledger/Hledger/Cli/Commands" |   let commandsdir = "hledger/Hledger/Cli/Commands" | ||||||
|   commandmds <- filter (".md" `isSuffixOf`) . map (commandsdir </>) <$> S.getDirectoryContents commandsdir |   commandmds <- filter (".md" `isSuffixOf`) . map (commandsdir </>) <$> S.getDirectoryContents commandsdir | ||||||
|   let commandtxts = map (-<.> "txt") commandmds |   let commandtxts = map (-<.> "txt") commandmds | ||||||
|  |   let wikidir = "wiki" | ||||||
|  |   wikipagenames <- map dropExtension . filter (".md" `isSuffixOf`) <$> S.getDirectoryContents wikidir | ||||||
| 
 | 
 | ||||||
|   shakeArgs |   shakeArgs | ||||||
|     shakeOptions{ |     shakeOptions{ | ||||||
| @ -185,9 +189,10 @@ main = do | |||||||
|       -- individual manuals rendered to markdown, ready for conversion to html (site/hledger.md) |       -- individual manuals rendered to markdown, ready for conversion to html (site/hledger.md) | ||||||
|       webmanuals = ["site" </> manpageNameToUri m <.> "md" | m <- manpageNames] |       webmanuals = ["site" </> manpageNameToUri m <.> "md" | m <- manpageNames] | ||||||
| 
 | 
 | ||||||
|       -- website html pages - all manual versions plus misc pages in site/ or copied from elsewhere. |       -- website pages kept in the main repo: all manual versions, | ||||||
|  |       -- misc pages in site/, some pages copied from elsewhere. | ||||||
|       -- TODO: make all have lower-case URIs on the final website. |       -- TODO: make all have lower-case URIs on the final website. | ||||||
|       webhtmlpages |       mainpageshtml | ||||||
|         = map (normalise . ("site/_site" </>)) |         = map (normalise . ("site/_site" </>)) | ||||||
|             $ ( [ prefix </> manpageNameToUri mPage <.> "html" |             $ ( [ prefix </> manpageNameToUri mPage <.> "html" | ||||||
|                    | prefix <- "" : [ "doc" </> v | v <- docversions ] |                    | prefix <- "" : [ "doc" </> v | v <- docversions ] | ||||||
| @ -210,6 +215,9 @@ main = do | |||||||
|                 ] |                 ] | ||||||
|               ) |               ) | ||||||
| 
 | 
 | ||||||
|  |       -- website pages kept in the wiki: cookbook content | ||||||
|  |       wikipageshtml = map (normalise . ("site/_site" </>) . (<.> ".html")) wikipagenames | ||||||
|  | 
 | ||||||
|       -- manuals rendered to markdown and combined, ready for web rendering |       -- manuals rendered to markdown and combined, ready for web rendering | ||||||
|       webmancombined = "site/manual.md" |       webmancombined = "site/manual.md" | ||||||
| 
 | 
 | ||||||
| @ -343,7 +351,7 @@ main = do | |||||||
| 
 | 
 | ||||||
|     -- WEBSITE HTML & ASSETS |     -- WEBSITE HTML & ASSETS | ||||||
| 
 | 
 | ||||||
|     phony "website" $ need [ "webassets" , "webhtml" ] |     phony "website" $ need [ "webassets" , "mainpages", "wikipages" ] | ||||||
| 
 | 
 | ||||||
|     -- copy all static asset files (files with certain extensions |     -- copy all static asset files (files with certain extensions | ||||||
|     -- found under sites, plus one or two more) to sites/_site/ |     -- found under sites, plus one or two more) to sites/_site/ | ||||||
| @ -360,23 +368,31 @@ main = do | |||||||
|     "site/_site/files/README" : [ "site/_site//*" <.> ext | ext <- webassetexts ] |%> \out -> do |     "site/_site/files/README" : [ "site/_site//*" <.> ext | ext <- webassetexts ] |%> \out -> do | ||||||
|         copyFile' ("site" </> dropDirectory2 out) out |         copyFile' ("site" </> dropDirectory2 out) out | ||||||
| 
 | 
 | ||||||
|     -- render all website pages as html, saved in sites/_site/ |     -- render all web pages from the main repo (manuals, home, download, relnotes etc) as html, saved in site/_site/ | ||||||
|     phony "webhtml" $ need webhtmlpages |     phony "mainpages" $ need mainpageshtml | ||||||
|  | 
 | ||||||
|  |     -- render all pages from the wiki as html, saved in site/_site/. | ||||||
|  |     -- We assume there are no path collisions with mainrepopages. | ||||||
|  |     phony "wikipages" $ need wikipageshtml | ||||||
| 
 | 
 | ||||||
|     -- render one website page as html, saved in sites/_site/ |     -- render one website page as html, saved in sites/_site/ | ||||||
|     "site/_site//*.html" %> \out -> do |     "site/_site//*.html" %> \out -> do | ||||||
|         let source    = "site" </> dropDirectory2 out -<.> "md" |         let name = takeBaseName out | ||||||
|             pageTitle = takeBaseName out |             source | ||||||
|  |               | name `elem` wikipagenames = "wiki" </> name <.> "md" | ||||||
|  |               | otherwise                 = "site" </> name <.> "md" | ||||||
|             template  = "site/site.tmpl" |             template  = "site/site.tmpl" | ||||||
|             siteRoot  = if "site/_site/doc//*" ?== out then "../.." else "." |             siteRoot  = if "site/_site/doc//*" ?== out then "../.." else "." | ||||||
|         need [source, template] |         need [source, template] | ||||||
|         cmd Shell pandoc fromsrcmd "-t html" source |         cmd Shell pandoc fromsrcmd "-t html" source | ||||||
|                          "--template"                template |                          "--template"                template | ||||||
|                          ("--metadata=siteRoot:"  ++ siteRoot) |                          ("--metadata=siteRoot:"  ++ siteRoot) | ||||||
|                          ("--metadata=title:"     ++ pageTitle) |                          ("--metadata=title:"     ++ name) | ||||||
|                          "--lua-filter"              "tools/pandoc-site.lua" |                          "--lua-filter"              "tools/pandoc-site.lua" | ||||||
|                          "--output"                  out |                          "--output"                  out | ||||||
| 
 | 
 | ||||||
|  |     -- render one wiki page as html, saved in site/_site/. | ||||||
|  | 
 | ||||||
|     -- HLEDGER PACKAGES/EXECUTABLES |     -- HLEDGER PACKAGES/EXECUTABLES | ||||||
| 
 | 
 | ||||||
|     phony "build" $ need packages |     phony "build" $ need packages | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user