;Shake: comment all the website generation stuff, sphinx does it now
[ci skip]
This commit is contained in:
		
							parent
							
								
									24ce2686f4
								
							
						
					
					
						commit
						4b3103cbb1
					
				
							
								
								
									
										200
									
								
								Shake.hs
									
									
									
									
									
								
							
							
						
						
									
										200
									
								
								Shake.hs
									
									
									
									
									
								
							| @ -39,7 +39,7 @@ When developing/troubleshooting this script, these are useful: | |||||||
| watch Shake.hs for compile errors: make ghcid-shake | watch Shake.hs for compile errors: make ghcid-shake | ||||||
| load Shake.hs in GHCI: make ghci-shake | load Shake.hs in GHCI: make ghci-shake | ||||||
| rebuild things when files change with entr (file watcher), eg: | rebuild things when files change with entr (file watcher), eg: | ||||||
|  find hledger-lib hledger | entr ./Shake website |  find hledger-lib hledger | entr ./Shake manuals | ||||||
| view rule dependency graph: | view rule dependency graph: | ||||||
|  ./Shake --report, open report.html?mode=rule-graph&query=!name(/(doc%7Cimages%7Cjs%7Ccss%7Cfonts%7Ctime%7Capi%7Cui%7Ccsv)/) |  ./Shake --report, open report.html?mode=rule-graph&query=!name(/(doc%7Cimages%7Cjs%7Ccss%7Cfonts%7Ctime%7Capi%7Cui%7Ccsv)/) | ||||||
| 
 | 
 | ||||||
| @ -70,25 +70,25 @@ usage = unlines | |||||||
|     ---------------------------------------79-------------------------------------- |     ---------------------------------------79-------------------------------------- | ||||||
|   ["Usage:" |   ["Usage:" | ||||||
|   ,"./Shake.hs               (re)compile this script" |   ,"./Shake.hs               (re)compile this script" | ||||||
|   ,"./Shake commandhelp      build embedded help texts for the hledger CLI" |   ,"./Shake commandhelp      build help texts for the hledger CLI" | ||||||
|   ,"./Shake manuals          build html/txt/man/info manuals for all packages" |   ,"./Shake manuals          build txt/man/info/web manuals for all packages" | ||||||
|   ,"./Shake htmlmanuals      build html manuals for all packages" |   -- ,"./Shake htmlmanuals      build html manuals for all packages" | ||||||
|   ,"./Shake oldmanuals       build old versions of html manuals for all packages" |   -- ,"./Shake oldmanuals       build old versions of html manuals for all packages" | ||||||
|   ,"./Shake PKG              build a single hledger package and its embedded docs" |   ,"./Shake PKG              build a single hledger package and its embedded docs" | ||||||
|   ,"./Shake build            build all hledger packages and their embedded docs" |   ,"./Shake build            build all hledger packages and their embedded docs" | ||||||
|   ,"./Shake website          build the website and web manuals" |   -- ,"./Shake website          build the website and web manuals" | ||||||
|   ,"./Shake website-all      build the website and all web manual versions" |   -- ,"./Shake website-all      build the website and all web manual versions" | ||||||
|   ,"./Shake all              build all the above" |   ,"./Shake all              build all the above" | ||||||
|   ,"./Shake hledgerorg       update the hledger.org website (when run on prod)" |   -- ,"./Shake hledgerorg       update the hledger.org website (when run on prod)" | ||||||
|   ,"" |   ,"" | ||||||
|   ,"./Shake mainpages                   build the web pages from the main repo" |   -- ,"./Shake mainpages                   build the web pages from the main repo" | ||||||
|   -- ,"./Shake site/index.md               update wiki links on the website home page" |   -- ,"./Shake site/index.md               update wiki links on the website home page" | ||||||
|   ,"./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" | ||||||
|   ,"./Shake [PKG/]CHANGES.md[-dry]      update or preview this changelog" |   ,"./Shake [PKG/]CHANGES.md[-dry]      update or preview this changelog" | ||||||
|   ,"./Shake [PKG/]CHANGES.md-finalise   set final release heading in this changelog" |   ,"./Shake [PKG/]CHANGES.md-finalise   set final release heading in this changelog" | ||||||
|   ,"./Shake site/doc/VERSION/.snapshot  save current web manuals as this snapshot" |   -- ,"./Shake site/doc/VERSION/.snapshot  save current web manuals as this snapshot" | ||||||
|   ,"" |   ,"" | ||||||
|   ,"./Shake clean            clean help texts, manuals, staged site content" |   ,"./Shake clean            clean help texts, manuals, staged site content" | ||||||
|   ,"./Shake Clean            also clean rendered site, object files, Shake's cache" |   ,"./Shake Clean            also clean rendered site, object files, Shake's cache" | ||||||
| @ -144,7 +144,7 @@ main = do | |||||||
| 
 | 
 | ||||||
|     phony "help" $ liftIO $ putStrLn usage |     phony "help" $ liftIO $ putStrLn usage | ||||||
| 
 | 
 | ||||||
|     phony "all" $ need ["commandhelp", "manuals", "build", "website"] |     phony "all" $ need ["commandhelp", "manuals", "build"]  --, "website"] | ||||||
| 
 | 
 | ||||||
|     -- phony "compile" $ need ["Shake"] |     -- phony "compile" $ need ["Shake"] | ||||||
|     -- "Shake" %> \out -> do |     -- "Shake" %> \out -> do | ||||||
| @ -197,33 +197,33 @@ main = do | |||||||
|       -- These may include additional files using m4. |       -- These may include additional files using m4. | ||||||
|       m4manuals = [manualDir m </> m <.> "m4.md" | m <- manualNames] |       m4manuals = [manualDir m </> m <.> "m4.md" | m <- manualNames] | ||||||
| 
 | 
 | ||||||
|       -- manuals rendered to nroff, ready for man (hledger/hledger.1) |       -- manuals as plain text, ready for embedding as CLI help (hledger/hledger.txt) | ||||||
|       nroffmanuals = [manpageDir m </> m | m <- manpageNames] |  | ||||||
| 
 |  | ||||||
|       -- manuals rendered to plain text, ready for embedding (hledger/hledger.txt) |  | ||||||
|       txtmanuals = [manualDir m </> m <.> "txt" | m <- manualNames] |       txtmanuals = [manualDir m </> m <.> "txt" | m <- manualNames] | ||||||
| 
 | 
 | ||||||
|       -- manuals rendered to info, ready for info (hledger/hledger.info) |       -- manuals as nroff, ready for man (hledger/hledger.1) | ||||||
|  |       nroffmanuals = [manpageDir m </> m | m <- manpageNames] | ||||||
|  | 
 | ||||||
|  |       -- manuals as info, ready for info (hledger/hledger.info) | ||||||
|       infomanuals = [manualDir m </> m <.> "info" | m <- manualNames] |       infomanuals = [manualDir m </> m <.> "info" | m <- manualNames] | ||||||
| 
 | 
 | ||||||
|       -- individual manuals rendered to markdown, ready for conversion to html (site/hledger.md) |       -- manuals as web-ready markdown, written into the website for Sphinx (site/hledger.md) | ||||||
|       mdmanuals = ["site" </> manpageNameToUri m <.> "md" | m <- manpageNames] |       webmanuals = ["site" </> manpageNameToUri m <.> "md" | m <- manpageNames] | ||||||
| 
 | 
 | ||||||
|       -- latest version of the manuals rendered to html |       -- -- latest version of the manuals rendered to html (site/_site/hledger.html) | ||||||
|       htmlmanuals = ["site/_site" </> manpageNameToUri m <.> "html" | m <- manpageNames] |       -- htmlmanuals = ["site/_site" </> manpageNameToUri m <.> "html" | m <- manpageNames] | ||||||
| 
 | 
 | ||||||
|       -- old versions of the manuals rendered to html |       -- -- old versions of the manuals rendered to html (site/_site/doc/1.14/hledger.html) | ||||||
|       oldhtmlmanuals = map (normalise . ("site/_site/doc" </>) . (<.> "html")) $ |       -- oldhtmlmanuals = map (normalise . ("site/_site/doc" </>) . (<.> "html")) $ | ||||||
|         [ v </> manpageNameToUri p | v <- docversions, v>="1.0", p <- manpageNames ++ ["manual"] ] ++ |       --   [ v </> manpageNameToUri p | v <- docversions, v>="1.0", p <- manpageNames ++ ["manual"] ] ++ | ||||||
|         [ v </> "manual"           | v <- docversions, v <"1.0" ]  -- before 1.0 there was only the combined manual |       --   [ v </> "manual"           | v <- docversions, v <"1.0" ]  -- before 1.0 there was only the combined manual | ||||||
| 
 | 
 | ||||||
|       -- the html for website pages kept in the main repo |       -- the html for website pages kept in the main repo | ||||||
|       mainpageshtml = map (normalise . ("site/_site" </>) . (<.> "html")) pages |       -- mainpageshtml = map (normalise . ("site/_site" </>) . (<.> "html")) pages | ||||||
| 
 | 
 | ||||||
|       -- TODO: make website URIs lower-case ? |       -- TODO: make website URIs lower-case ? | ||||||
| 
 | 
 | ||||||
|       -- extensions of static web asset files, to be copied to the website |       -- extensions of static web asset files, to be copied to the website | ||||||
|       webassetexts = ["png", "gif", "cur", "js", "css", "eot", "ttf", "woff", "svg"] |       -- webassetexts = ["png", "gif", "cur", "js", "css", "eot", "ttf", "woff", "svg"] | ||||||
| 
 | 
 | ||||||
|       -- The directory in which to find this man page. |       -- The directory in which to find this man page. | ||||||
|       -- hledger.1 -> hledger/doc, hledger_journal.5 -> hledger-lib/doc |       -- hledger.1 -> hledger/doc, hledger_journal.5 -> hledger-lib/doc | ||||||
| @ -249,14 +249,14 @@ main = do | |||||||
| 
 | 
 | ||||||
|     -- MANUALS |     -- MANUALS | ||||||
| 
 | 
 | ||||||
|     -- Generate the manuals in nroff, plain text and info formats. |     -- Generate the manuals in plain text, nroff, info, and markdown formats. | ||||||
|     phony "manuals" $ need $ |     phony "manuals" $ need $ | ||||||
|       "commandhelp" : |       "commandhelp" : | ||||||
|       concat [ |       concat [ | ||||||
|        nroffmanuals |        nroffmanuals | ||||||
|       ,infomanuals |       ,infomanuals | ||||||
|       ,txtmanuals |       ,txtmanuals | ||||||
|       ,htmlmanuals |       ,webmanuals | ||||||
|       ] |       ] | ||||||
| 
 | 
 | ||||||
|     -- Generate nroff man pages suitable for man output. |     -- Generate nroff man pages suitable for man output. | ||||||
| @ -318,8 +318,8 @@ main = do | |||||||
| 
 | 
 | ||||||
|     -- Generate the individual web manuals' markdown source, using m4 |     -- Generate the individual web manuals' markdown source, using m4 | ||||||
|     -- and pandoc to tweak content. |     -- and pandoc to tweak content. | ||||||
|     phony "mdmanuals" $ need mdmanuals |     phony "webmanuals" $ need webmanuals | ||||||
|     mdmanuals |%> \out -> do -- site/hledger.md |     webmanuals |%> \out -> do -- site/hledger.md | ||||||
|       let manpage   = manpageUriToName $ dropExtension $ takeFileName out -- hledger |       let manpage   = manpageUriToName $ dropExtension $ takeFileName out -- hledger | ||||||
|           manual    = manpageNameToManualName manpage |           manual    = manpageNameToManualName manpage | ||||||
|           dir       = manpageDir manpage |           dir       = manpageDir manpage | ||||||
| @ -343,67 +343,67 @@ main = do | |||||||
| 
 | 
 | ||||||
|     -- Copy some extra markdown files from the main repo into the site |     -- Copy some extra markdown files from the main repo into the site | ||||||
|     -- TODO adding table of contents placeholders |     -- TODO adding table of contents placeholders | ||||||
|     [ |     -- [ | ||||||
|       -- "site/README.md", |     --   -- "site/README.md", | ||||||
|       -- "site/CONTRIBUTING.md" |     --   -- "site/CONTRIBUTING.md" | ||||||
|       ]  |%> \out -> |     --   ]  |%> \out -> | ||||||
|       copyFile' (dropDirectory1 out) out -- XXX (map toLower out) |     --   copyFile' (dropDirectory1 out) out -- XXX (map toLower out) | ||||||
| 
 | 
 | ||||||
|     -- WEBSITE HTML & ASSETS |     -- WEBSITE HTML & ASSETS | ||||||
| 
 | 
 | ||||||
|     phony "website" $ need [ |     -- phony "website" $ need [ | ||||||
|        "webassets" |     --    "webassets" | ||||||
|       ,"mainpages" |     --   -- ,"mainpages" | ||||||
|       ,"htmlmanuals" |     --   -- ,"htmlmanuals" | ||||||
|       ] |     --   ] | ||||||
| 
 | 
 | ||||||
|     phony "website-all" $ need [ |     -- phony "website-all" $ need [ | ||||||
|        "website" |     --    "website" | ||||||
|       ,"oldmanuals" |     --   -- ,"oldmanuals" | ||||||
|       ] |     --   ] | ||||||
| 
 | 
 | ||||||
|     -- 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/ | ||||||
|     phony "webassets" $ do |     -- phony "webassets" $ do | ||||||
|         assets <- getDirectoryFiles "site" (map ("//*" <.>) webassetexts) |     --     assets <- getDirectoryFiles "site" (map ("//*" <.>) webassetexts) | ||||||
|         need [ "site/_site" </> file |     --     need [ "site/_site" </> file | ||||||
|                 | file <- assets ++ [ |     --             | file <- assets ++ [ | ||||||
|                     "files/README" |     --                 "files/README" | ||||||
|                     ] |     --                 ] | ||||||
|                 , not ("_site//*" ?== file) |     --             , not ("_site//*" ?== file) | ||||||
|              ] |     --          ] | ||||||
| 
 | 
 | ||||||
|     -- copy any one of the static asset files to sites/_site/ |     -- copy any one of the static asset files to sites/_site/ | ||||||
|     "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 web pages from the main repo (manuals, home, download, relnotes etc) as html, saved in site/_site/ |     -- render all web pages from the main repo (manuals, home, download, relnotes etc) as html, saved in site/_site/ | ||||||
|     phony "mainpages" $ need mainpageshtml |     -- phony "mainpages" $ need mainpageshtml | ||||||
| 
 | 
 | ||||||
|     phony "htmlmanuals" $ need htmlmanuals |     -- phony "htmlmanuals" $ need htmlmanuals | ||||||
| 
 | 
 | ||||||
|     phony "oldmanuals" $ need oldhtmlmanuals |     -- phony "oldmanuals" $ need oldhtmlmanuals | ||||||
| 
 | 
 | ||||||
|     -- Render one website page as html, saved in sites/_site/. |     -- Render one website page as html, saved in sites/_site/. | ||||||
|     -- Github-style wiki links will be hyperlinked. |     -- Github-style wiki links will be hyperlinked. | ||||||
|     "site/_site//*.html" %> \out -> do |     -- "site/_site//*.html" %> \out -> do | ||||||
|         let filename = takeBaseName out |     --     let filename = takeBaseName out | ||||||
|             pagename = fileNameToPageName filename |     --         pagename = fileNameToPageName filename | ||||||
|             isdownloadpage = filename == "download" |     --         isdownloadpage = filename == "download" | ||||||
|             isoldmanual = "site/_site/doc/" `isPrefixOf` out |     --         isoldmanual = "site/_site/doc/" `isPrefixOf` out | ||||||
|             source |     --         source | ||||||
|               | isoldmanual = "site" </> (drop 11 $ dropExtension out) <.> "md" |     --           | isoldmanual = "site" </> (drop 11 $ dropExtension out) <.> "md" | ||||||
|               | otherwise   = "site" </> filename <.> "md" |     --           | otherwise   = "site" </> filename <.> "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] | ||||||
|         -- read markdown source, link any wikilinks, pipe it to pandoc, write html out |     --     -- read markdown source, link any wikilinks, pipe it to pandoc, write html out | ||||||
|         Stdin . wikiLink <$> (readFile' source) >>= |     --     Stdin . wikiLink <$> (readFile' source) >>= | ||||||
|           (cmd Shell pandoc "-" fromsrcmd "-t html" |     --       (cmd Shell pandoc "-" fromsrcmd "-t html" | ||||||
|                            "--template" template |     --                        "--template" template | ||||||
|                            ("--metadata=siteRoot:" ++ siteRoot) |     --                        ("--metadata=siteRoot:" ++ siteRoot) | ||||||
|                            ("--metadata=\"title:" ++ pagename ++ "\"") |     --                        ("--metadata=\"title:" ++ pagename ++ "\"") | ||||||
|                            "-o" out ) |     --                        "-o" out ) | ||||||
| 
 | 
 | ||||||
|     -- This rule, for updating the live hledger.org site, gets called by: |     -- This rule, for updating the live hledger.org site, gets called by: | ||||||
|     -- 1. github-post-receive (github webhook handler), when something is pushed |     -- 1. github-post-receive (github webhook handler), when something is pushed | ||||||
| @ -412,23 +412,23 @@ main = do | |||||||
|     --     /etc/github-post-receive.conf |     --     /etc/github-post-receive.conf | ||||||
|     -- 2. cron, nightly. Config: /etc/crontab |     -- 2. cron, nightly. Config: /etc/crontab | ||||||
|     -- 3. manually (make site). |     -- 3. manually (make site). | ||||||
|     phony "hledgerorg" $ do |     -- phony "hledgerorg" $ do | ||||||
|       -- XXX ideally we would ensure here that output is logged in site.log, |     --   -- XXX ideally we would ensure here that output is logged in site.log, | ||||||
|       -- but I don't know how to do that for the Shake rules. |     --   -- but I don't know how to do that for the Shake rules. | ||||||
|       -- Instead we'll do the logging in "make site". |     --   -- Instead we'll do the logging in "make site". | ||||||
|       cmd_ Shell |     --   cmd_ Shell | ||||||
| 
 | 
 | ||||||
|         -- print timestamp. On mac, use brew-installed GNU date. |     --     -- print timestamp. On mac, use brew-installed GNU date. | ||||||
|         "PATH=\"/usr/local/opt/coreutils/libexec/gnubin:$PATH\" date --rfc-3339=seconds" |     --     "PATH=\"/usr/local/opt/coreutils/libexec/gnubin:$PATH\" date --rfc-3339=seconds" | ||||||
|         -- pull latest code and site repos - sometimes already done by webhook, not always |     --     -- pull latest code and site repos - sometimes already done by webhook, not always | ||||||
|         "&& printf 'code repo: ' && git pull" |     --     "&& printf 'code repo: ' && git pull" | ||||||
|         "&& printf 'site repo: ' && git -C site pull" |     --     "&& printf 'site repo: ' && git -C site pull" | ||||||
| 
 | 
 | ||||||
|       -- Shake.hs might have been updated, but we won't execute the |     --   -- Shake.hs might have been updated, but we won't execute the | ||||||
|       -- new one, too insecure. Continue with this one. |     --   -- new one, too insecure. Continue with this one. | ||||||
| 
 | 
 | ||||||
|       -- update the live site based on all latest content |     --   -- update the live site based on all latest content | ||||||
|       need [ "website-all" ] |     --   need [ "website-all" ] | ||||||
| 
 | 
 | ||||||
|     -- HLEDGER PACKAGES/EXECUTABLES |     -- HLEDGER PACKAGES/EXECUTABLES | ||||||
| 
 | 
 | ||||||
| @ -650,14 +650,14 @@ main = do | |||||||
|     -- Generate the web manuals based on the current checkout and save |     -- Generate the web manuals based on the current checkout and save | ||||||
|     -- them as the specified versioned snapshot in site/doc/VER/ . |     -- them as the specified versioned snapshot in site/doc/VER/ . | ||||||
|     -- .snapshot is a dummy file. |     -- .snapshot is a dummy file. | ||||||
|     "site/doc/*/.snapshot" %> \out -> do |     -- "site/doc/*/.snapshot" %> \out -> do | ||||||
|       need mdmanuals |     --   need webmanuals | ||||||
|       let snapshot = takeDirectory out |     --   let snapshot = takeDirectory out | ||||||
|       cmd_ Shell "mkdir -p" snapshot |     --   cmd_ Shell "mkdir -p" snapshot | ||||||
|       forM_ mdmanuals $ \f -> -- site/hledger.md, site/journal.md |     --   forM_ webmanuals $ \f -> -- site/hledger.md, site/journal.md | ||||||
|         cmd_ Shell "cp" f (snapshot </> takeFileName f) |     --     cmd_ Shell "cp" f (snapshot </> takeFileName f) | ||||||
|       cmd_ Shell "cp -r site/images" snapshot |     --   cmd_ Shell "cp -r site/images" snapshot | ||||||
|       cmd_ Shell "touch" out |     --   cmd_ Shell "touch" out | ||||||
| 
 | 
 | ||||||
|     -- Cleanup. |     -- Cleanup. | ||||||
| 
 | 
 | ||||||
| @ -665,7 +665,7 @@ main = do | |||||||
|       -- putNormal "Cleaning generated help texts, manuals, staged site content" |       -- putNormal "Cleaning generated help texts, manuals, staged site content" | ||||||
|       -- removeFilesAfter "." commandtxts |       -- removeFilesAfter "." commandtxts | ||||||
|       putNormal "Cleaning generated manuals, staged site content" |       putNormal "Cleaning generated manuals, staged site content" | ||||||
|       removeFilesAfter "." mdmanuals |       removeFilesAfter "." webmanuals | ||||||
|       removeFilesAfter "." [ |       removeFilesAfter "." [ | ||||||
|         -- "site/README.md", |         -- "site/README.md", | ||||||
|         -- "site/CONTRIBUTING.md" |         -- "site/CONTRIBUTING.md" | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user