;tools: shake: cleanup, note dependency issues
This commit is contained in:
parent
e79f45a737
commit
2c7c2c6d05
42
Shake.hs
42
Shake.hs
@ -57,7 +57,7 @@ usage =
|
|||||||
let scriptname = "Shake" in replaceRe [re|/Shake|] ('/':scriptname) $
|
let scriptname = "Shake" in replaceRe [re|/Shake|] ('/':scriptname) $
|
||||||
unlines
|
unlines
|
||||||
---------------------------------------79--------------------------------------
|
---------------------------------------79--------------------------------------
|
||||||
["Shake: heavy project scripting. See also: justfile, Makefile"
|
["Shake: for heavy project scripting. See also: Justfile"
|
||||||
,"Usage:"
|
,"Usage:"
|
||||||
,"./Shake.hs [CMD [ARGS]] run CMD, compiling this script first if needed"
|
,"./Shake.hs [CMD [ARGS]] run CMD, compiling this script first if needed"
|
||||||
,"./Shake [CMD [ARGS]] run CMD, using the compiled version of this script"
|
,"./Shake [CMD [ARGS]] run CMD, using the compiled version of this script"
|
||||||
@ -66,10 +66,9 @@ usage =
|
|||||||
,"./Shake setversion [VER] [PKGS] [-c]"
|
,"./Shake setversion [VER] [PKGS] [-c]"
|
||||||
," update versions in source files to */.version or VER"
|
," update versions in source files to */.version or VER"
|
||||||
," and update */*.cabal files"
|
," and update */*.cabal files"
|
||||||
-- ,"./Shake flagdocs [-c] update flags in hledger CLI command docs"
|
-- ,"./Shake optdocs [-c] update options in hledger CLI command docs"
|
||||||
-- ," (run after changing command flags)"
|
-- ," (run after changing command flags)"
|
||||||
,"./Shake cmddocs [-c] update hledger command help (including command flags,"
|
,"./Shake cmddocs [-c] update hledger command help after changing opts/docs"
|
||||||
," but not main flags) after changing command flags/docs)"
|
|
||||||
,"./Shake mandates update the date shown in some manual formats"
|
,"./Shake mandates update the date shown in some manual formats"
|
||||||
,"./Shake manuals [-c] update all packages' txt/man/info/web manuals"
|
,"./Shake manuals [-c] update all packages' txt/man/info/web manuals"
|
||||||
-- ,"./Shake webmanuals update just the web manuals"
|
-- ,"./Shake webmanuals update just the web manuals"
|
||||||
@ -595,16 +594,28 @@ main = do
|
|||||||
| pkg <- pkgs
|
| pkg <- pkgs
|
||||||
]
|
]
|
||||||
|
|
||||||
-- Update each Hledger/Cli/Commands/*.md, replacing the flags block with latest --help output,
|
-- Regenerate Hledger/Cli/Commands/*.txt, rendering the corresponding .md files as plain text.
|
||||||
-- or a placeholder if there are no command-specific flags.
|
-- Also updates cmddocs first.
|
||||||
-- For hledger manual and also for cmddocs below.
|
-- For commands' --help output.
|
||||||
phony "flagdocs" $ do
|
-- NB this assumes the hledger executables are up to date. XXX
|
||||||
need commandmdsnew
|
phony "cmddocs" $ do
|
||||||
when commit $ commitIfChanged ";doc: update command flag docs" commandmds
|
-- need ["build"] -- XXX circular dep, how would this work ?
|
||||||
|
liftIO $ putStrLn "please ensure the hledger build is up to date" -- XXX never printed, why ?
|
||||||
|
need commandtxts
|
||||||
|
when commit $ commitIfChanged ";doc: update help" commandtxts
|
||||||
|
|
||||||
|
-- -- Update each Hledger/Cli/Commands/*.md, replacing the flags block with latest --help output,
|
||||||
|
-- -- or a placeholder if there are no command-specific flags.
|
||||||
|
-- -- For hledger manual and also for cmddocs below.
|
||||||
|
-- -- NB hledger executables should be up to date, see cmddocs
|
||||||
|
-- phony "optdocs" $ do
|
||||||
|
-- need commandmdsnew
|
||||||
|
-- when commit $ commitIfChanged ";doc: update command flag docs" commandmds
|
||||||
|
|
||||||
-- hledger/Hledger/Cli/Commands/CMD.md.new: a phony target that updates the flags doc
|
-- hledger/Hledger/Cli/Commands/CMD.md.new: a phony target that updates the flags doc
|
||||||
-- within hledger/Hledger/Cli/Commands/CMD.md. Runs "stack run -- hledger CMD -h" to get the latest.
|
-- within hledger/Hledger/Cli/Commands/CMD.md. Runs "stack run -- hledger CMD -h" to get the latest.
|
||||||
-- If that fails, a warning is printed and it carries on, keeping the old flags doc.
|
-- If that fails, a warning is printed and it carries on, keeping the old flags doc.
|
||||||
|
-- NB this needs the hledger build to be up to date, see cmddocs.
|
||||||
phonys $ \out ->
|
phonys $ \out ->
|
||||||
if not $ "hledger/Hledger/Cli/Commands/" `isPrefixOf` out && ".md.new" `isSuffixOf` out
|
if not $ "hledger/Hledger/Cli/Commands/" `isPrefixOf` out && ".md.new" `isSuffixOf` out
|
||||||
then Nothing
|
then Nothing
|
||||||
@ -618,7 +629,7 @@ main = do
|
|||||||
let cmdname = map toLower $ takeBaseName src
|
let cmdname = map toLower $ takeBaseName src
|
||||||
do
|
do
|
||||||
let shellcmd = "stack exec -- hledger -h " <> cmdname
|
let shellcmd = "stack exec -- hledger -h " <> cmdname
|
||||||
liftIO $ putStrLn ("running " <> shellcmd <> " to update flags in " <> src)
|
liftIO $ putStrLn $ "running " <> shellcmd <> " to get options help"
|
||||||
cmdhelp <- lines . fromStdout <$> (cmd Shell shellcmd :: Action (Stdout String))
|
cmdhelp <- lines . fromStdout <$> (cmd Shell shellcmd :: Action (Stdout String))
|
||||||
let
|
let
|
||||||
cmdflagshelp = takeWhile (not.null) $ dropWhile (/="Flags:") cmdhelp
|
cmdflagshelp = takeWhile (not.null) $ dropWhile (/="Flags:") cmdhelp
|
||||||
@ -635,13 +646,6 @@ main = do
|
|||||||
-- | otherwise = err
|
-- | otherwise = err
|
||||||
-- in \(e::C.IOException) -> liftIO $ hPutStrLn stderr $ elide $ show e -- not used
|
-- in \(e::C.IOException) -> liftIO $ hPutStrLn stderr $ elide $ show e -- not used
|
||||||
|
|
||||||
-- Regenerate Hledger/Cli/Commands/*.txt, rendering the corresponding .md files as plain text.
|
|
||||||
-- Also updates cmddocs first.
|
|
||||||
-- For commands' --help output.
|
|
||||||
phony "cmddocs" $ do
|
|
||||||
need commandtxts
|
|
||||||
when commit $ commitIfChanged ";doc: update help" commandtxts
|
|
||||||
|
|
||||||
commandtxts |%> \out -> do
|
commandtxts |%> \out -> do
|
||||||
let src = out -<.> "md"
|
let src = out -<.> "md"
|
||||||
liftIO $ putStrLn ("generating " <> out)
|
liftIO $ putStrLn ("generating " <> out)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user