git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove hierarchy options
446d7c1Gary Burgess
psc-docs/Main.hs+9−16
@@ -31,19 +31,18 @@ import System.Exit (exitSuccess, exitFailure)
31import System.IO (hPutStrLn, stderr)
31import System.IO (hPutStrLn, stderr)
32
32
33data PSCDocsOptions = PSCDocsOptions
33data PSCDocsOptions = PSCDocsOptions
34− { pscdIncludeHeir :: Bool
35− , pscdInputFiles :: [FilePath]
34+ { pscdInputFiles :: [FilePath]
36 }
35 }
37
36
38docgen :: PSCDocsOptions -> IO ()
37docgen :: PSCDocsOptions -> IO ()
39−docgen (PSCDocsOptions showHierarchy input) = do
38+docgen (PSCDocsOptions input) = do
40 e <- P.parseModulesFromFiles (fromMaybe "") <$> mapM (fmap (first Just) . parseFile) (nub input)
39 e <- P.parseModulesFromFiles (fromMaybe "") <$> mapM (fmap (first Just) . parseFile) (nub input)
41 case e of
40 case e of
42 Left err -> do
41 Left err -> do
43 hPutStrLn stderr $ show err
42 hPutStrLn stderr $ show err
44 exitFailure
43 exitFailure
45 Right ms -> do
44 Right ms -> do
46− putStrLn . runDocs $ renderModules showHierarchy (map snd ms)
45+ putStrLn . runDocs $ renderModules (map snd ms)
47 exitSuccess
46 exitSuccess
48
47
49parseFile :: FilePath -> IO (FilePath, String)
48parseFile :: FilePath -> IO (FilePath, String)
@@ -71,14 +70,14 @@ atIndent indent text =
71ticks :: String -> String
70ticks :: String -> String
72ticks = ("`" ++) . (++ "`")
71ticks = ("`" ++) . (++ "`")
73
72
74−renderModules :: Bool -> [P.Module] -> Docs
73+renderModules :: [P.Module] -> Docs
75−renderModules showHierarchy ms = do
74+renderModules ms = do
76 headerLevel 1 "Module Documentation"
75 headerLevel 1 "Module Documentation"
77 spacer
76 spacer
78− mapM_ (renderModule showHierarchy) ms
77+ mapM_ renderModule ms
79
78
80−renderModule :: Bool -> P.Module -> Docs
79+renderModule :: P.Module -> Docs
81−renderModule showHierarchy mdl@(P.Module moduleName _ exps) = do
80+renderModule mdl@(P.Module moduleName _ exps) = do
82 headerLevel 2 $ "Module " ++ P.runModuleName moduleName
81 headerLevel 2 $ "Module " ++ P.runModuleName moduleName
83 spacer
82 spacer
84 renderTopLevel exps (P.exportedDeclarations mdl)
83 renderTopLevel exps (P.exportedDeclarations mdl)
@@ -212,14 +211,8 @@ inputFile = strArgument $
212 metavar "FILE"
211 metavar "FILE"
213 <> help "The input .purs file(s)"
212 <> help "The input .purs file(s)"
214
213
215−includeHierarcy :: Parser Bool
216−includeHierarcy = switch $
217− long "hierarchy-images"
218− <> help "Include markdown for type class hierarchy images in the output."
219−
220pscDocsOptions :: Parser PSCDocsOptions
214pscDocsOptions :: Parser PSCDocsOptions
221−pscDocsOptions = PSCDocsOptions <$> includeHierarcy
215+pscDocsOptions = PSCDocsOptions <$> many inputFile
222− <*> many inputFile
223
216
224main :: IO ()
217main :: IO ()
225main = execParser opts >>= docgen
218main = execParser opts >>= docgen