diff options
author | Ian Lynagh <igloo@earth.li> | 2010-08-22 15:55:14 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2010-08-22 15:55:14 +0000 |
commit | ab90e5fa171913fe777b2b6909030e3967e72bc6 (patch) | |
tree | 77684e18f29ef622181eba6b740e6de2aea8aab7 /utils/mkUserGuidePart/Main.hs | |
parent | c07d7849d440a1ff371690654205c02c06b56fd0 (diff) | |
download | haskell-ab90e5fa171913fe777b2b6909030e3967e72bc6.tar.gz |
Generate the bit in the user guide where we say what -fglasgow-exts does
Stops the docs going out of sync with the code.
Diffstat (limited to 'utils/mkUserGuidePart/Main.hs')
-rw-r--r-- | utils/mkUserGuidePart/Main.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/utils/mkUserGuidePart/Main.hs b/utils/mkUserGuidePart/Main.hs new file mode 100644 index 0000000000..114114ca1c --- /dev/null +++ b/utils/mkUserGuidePart/Main.hs @@ -0,0 +1,39 @@ + +module Main (main) where + +import DynFlags + +import Data.List +import System.Environment + +main :: IO () +main = do args <- getArgs + case args of + [] -> error "Need to give filename to generate as an argument" + [f] -> + case f of + "docs/users_guide/what_glasgow_exts_does.gen.xml" -> + writeFile f whatGlasgowExtsDoes + _ -> + error ("Don't know what to do for " ++ show f) + _ -> error "Bad args" + +whatGlasgowExtsDoes :: String +whatGlasgowExtsDoes = case maybeInitLast glasgowExtsFlags of + Just (xs, x) -> + let xs' = map mkInitLine xs + x' = mkLastLine x + in unlines (xs' ++ [x']) + Nothing -> + error "glasgowExtsFlags is empty?" + where mkInitLine = mkLine ',' + mkLastLine = mkLine '.' + mkLine c f = case stripPrefix "Opt_" (show f) of + Just ext -> "<option>-X" ++ ext ++ "</option>" ++ [c] + Nothing -> error ("Can't parse extension: " ++ show f) + +maybeInitLast :: [a] -> Maybe ([a], a) +maybeInitLast xs = case reverse xs of + (y : ys) -> Just (reverse ys, y) + _ -> Nothing + |