@@ -43,7 +43,7 @@ docgen (PSCDocsOptions showHierarchy input) = do
4343 hPutStrLn stderr $ show err
4444 exitFailure
4545 Right ms -> do
46− putStrLn . runDocs $ (renderModules showHierarchy) (map snd ms)
46+ putStrLn . runDocs $ renderModules showHierarchy (map snd ms)
4747 exitSuccess
4848
4949parseFile :: FilePath -> IO (FilePath, String)
@@ -78,45 +78,19 @@ renderModules showHierarchy ms = do
7878 mapM_ (renderModule showHierarchy) ms
7979
8080renderModule :: Bool -> P.Module -> Docs
81−renderModule showHierarchy mdl@(P.Module moduleName _ exps) =
82− let ds = P.exportedDeclarations mdl
83− hasTypes = any isTypeDeclaration ds
84− hasTypeclasses = any isTypeClassDeclaration ds
85− hasTypeclassInstances = any isTypeInstanceDeclaration ds
86− hasValues = any isValueDeclaration ds
87− in do
81+renderModule showHierarchy mdl@(P.Module moduleName _ exps) = do
8882 headerLevel 2 $ "Module " ++ P.runModuleName moduleName
8983 spacer
90− when hasTypes $ do
91− headerLevel 3 "Types"
92− spacer
93− renderTopLevel exps (filter isTypeDeclaration ds)
94− spacer
95− when hasTypeclasses $ do
96− headerLevel 3 "Type Classes"
97− spacer
98− when showHierarchy $ do
99− renderTypeclassImage moduleName
100− spacer
101− renderTopLevel exps (filter isTypeClassDeclaration ds)
102− spacer
103− when hasTypeclassInstances $ do
104− headerLevel 3 "Type Class Instances"
105− spacer
106− renderTopLevel exps (filter isTypeInstanceDeclaration ds)
107− spacer
108− when hasValues $ do
109− headerLevel 3 "Values"
110− spacer
111− renderTopLevel exps (filter isValueDeclaration ds)
112− spacer
84+ renderTopLevel exps (P.exportedDeclarations mdl)
85+ spacer
11386
11487renderTopLevel :: Maybe [P.DeclarationRef] -> [P.Declaration] -> Docs
115−renderTopLevel exps decls = forM_ decls $ \decl -> do
116− traverse_ (headerLevel 4) (ticks `fmap` getDeclarationTitle decl)
117− spacer
118− renderDeclaration exps decl
119− spacer
88+renderTopLevel exps decls = forM_ decls $ \decl ->
89+ when (canRenderDecl decl) $ do
90+ traverse_ (headerLevel 4) (ticks `fmap` getDeclarationTitle decl)
91+ spacer
92+ renderDeclaration exps decl
93+ spacer
12094
12195renderTypeclassImage :: P.ModuleName -> Docs
12296renderTypeclassImage name =
@@ -222,41 +196,29 @@ getName (P.TypeInstanceDeclaration name _ _ _ _) = show name
222196getName (P.PositionedDeclaration _ _ d) = getName d
223197getName _ = error "Invalid argument to getName"
224198
225−isValueDeclaration :: P.Declaration -> Bool
226−isValueDeclaration P.TypeDeclaration{} = True
227−isValueDeclaration P.ExternDeclaration{} = True
228−isValueDeclaration (P.PositionedDeclaration _ _ d) = isValueDeclaration d
229−isValueDeclaration _ = False
230−
231−isTypeDeclaration :: P.Declaration -> Bool
232−isTypeDeclaration P.DataDeclaration{} = True
233−isTypeDeclaration P.ExternDataDeclaration{} = True
234−isTypeDeclaration P.TypeSynonymDeclaration{} = True
235−isTypeDeclaration (P.PositionedDeclaration _ _ d) = isTypeDeclaration d
236−isTypeDeclaration _ = False
237−
238−isTypeClassDeclaration :: P.Declaration -> Bool
239−isTypeClassDeclaration P.TypeClassDeclaration{} = True
240−isTypeClassDeclaration (P.PositionedDeclaration _ _ d) = isTypeClassDeclaration d
241−isTypeClassDeclaration _ = False
242−
243−isTypeInstanceDeclaration :: P.Declaration -> Bool
244−isTypeInstanceDeclaration P.TypeInstanceDeclaration{} = True
245−isTypeInstanceDeclaration (P.PositionedDeclaration _ _ d) = isTypeInstanceDeclaration d
246−isTypeInstanceDeclaration _ = False
199+canRenderDecl :: P.Declaration -> Bool
200+canRenderDecl P.TypeDeclaration{} = True
201+canRenderDecl P.ExternDeclaration{} = True
202+canRenderDecl P.DataDeclaration{} = True
203+canRenderDecl P.ExternDataDeclaration{} = True
204+canRenderDecl P.TypeSynonymDeclaration{} = True
205+canRenderDecl P.TypeClassDeclaration{} = True
206+canRenderDecl P.TypeInstanceDeclaration{} = True
207+canRenderDecl (P.PositionedDeclaration _ _ d) = canRenderDecl d
208+canRenderDecl _ = False
247209
248210inputFile :: Parser FilePath
249211inputFile = strArgument $
250212 metavar "FILE"
251213 <> help "The input .purs file(s)"
252214
253−includeHeirarcy :: Parser Bool
254−includeHeirarcy = switch $
215+includeHierarcy :: Parser Bool
216+includeHierarcy = switch $
255217 long "hierarchy-images"
256218 <> help "Include markdown for type class hierarchy images in the output."
257219
258220pscDocsOptions :: Parser PSCDocsOptions
259−pscDocsOptions = PSCDocsOptions <$> includeHeirarcy
221+pscDocsOptions = PSCDocsOptions <$> includeHierarcy
260222 <*> many inputFile
261223
262224main :: IO ()