@@ -77,10 +77,19 @@ generateDocs ist nss' out =
78-- ----------------------------------------------------------------- [ Types ]
78-- ----------------------------------------------------------------- [ Types ]
80+-- | Either an error message or a result
80type Failable = Either String
81type Failable = Either String
83+-- | Internal representation of a fully qualified namespace name
81type NsName = [T.Text]
84type NsName = [T.Text]
86+-- | All information to be documented about a single namespace member
82type NsItem = (Name, Maybe Docs, Accessibility)
87type NsItem = (Name, Maybe Docs, Accessibility)
89+-- | All information to be documented about a namespace
83type NsInfo = [NsItem]
90type NsInfo = [NsItem]
92+-- | A map from namespace names to information about them
84type NsDict = M.Map NsName NsInfo
93type NsDict = M.Map NsName NsInfo
86-- --------------------------------------------------------------- [ Utility ]
95-- --------------------------------------------------------------- [ Utility ]
@@ -133,10 +142,11 @@ fetchInfo :: IState -- ^ IState to fetch info from
133fetchInfo ist nss =
142fetchInfo ist nss =
134 do let originNss = S.fromList nss
143 do let originNss = S.fromList nss
135 info <- nsDict ist
144 info <- nsDict ist
136− let info' = M.map (filter (filterName . (\(n, _, _) -> n))) info
145+ let info' = M.map (filter filterInclude) info
137 info'' = M.map removeOrphans info'
146 info'' = M.map removeOrphans info'
147+ info''' = M.filter (not . null) info''
138− reachedNss = traceNss info'' originNss S.empty
148+ reachedNss = traceNss info''' originNss S.empty
139− return $ M.filterWithKey (\k _ -> S.member k reachedNss) info''
149+ return $ M.filterWithKey (\k _ -> S.member k reachedNss) info'''
142-- | Removes loose class methods and data constructors,
152-- | Removes loose class methods and data constructors,
@@ -160,6 +170,16 @@ filterName (NS n _) = filterName n
160filterName _ = False
170filterName _ = False
173+-- | Whether a NsItem should be included in the documentation.
174+-- It must not be Hidden and filterName must return True for the name.
175+-- Also it must have Docs -- without Docs, nothing can be done.
176+filterInclude :: NsItem -- ^ Accessibility to check
177+ -> Bool -- ^ Predicate result
178+filterInclude (name, Just _, Public) | filterName name = True
179+filterInclude (name, Just _, Frozen) | filterName name = True
180+filterInclude _ = False
163-- | Finds all namespaces indirectly referred by a set of namespaces.
183-- | Finds all namespaces indirectly referred by a set of namespaces.
164-- The NsItems of the namespaces are searched for references.
184-- The NsItems of the namespaces are searched for references.
165traceNss :: NsDict -- ^ Mappings of namespaces and their contents
185traceNss :: NsDict -- ^ Mappings of namespaces and their contents
@@ -215,7 +235,7 @@ getAccess ist n =
215 let res = lookupDefAcc n False (tt_ctxt ist)
235 let res = lookupDefAcc n False (tt_ctxt ist)
216 in case res of
236 in case res of
217 [(_, acc)] -> acc
237 [(_, acc)] -> acc
218− _ -> Public
238+ _ -> Hidden
220-- | Simple predicate for whether an NsItem has Docs
240-- | Simple predicate for whether an NsItem has Docs
221hasDoc :: NsItem -- ^ The NsItem to test
241hasDoc :: NsItem -- ^ The NsItem to test
@@ -403,19 +423,15 @@ createNsDoc ist ns content out =
403 do let tpath = out </> "docs" </> (genRelNsPath ns "html")
423 do let tpath = out </> "docs" </> (genRelNsPath ns "html")
404 dir = takeDirectory tpath
424 dir = takeDirectory tpath
405 file = takeFileName tpath
425 file = takeFileName tpath
406− visible (_, _, Hidden) = False
408 haveDocs (_, Just d, _) = [d]
426 haveDocs (_, Just d, _) = [d]
409 haveDocs _ = []
427 haveDocs _ = []
410− -- Do not document private members
411− content' = filter visible content
412 -- We cannot do anything without a Doc
428 -- We cannot do anything without a Doc
413− content'' = concatMap haveDocs content'
429+ content' = concatMap haveDocs content
414 createDirectoryIfMissing True dir
430 createDirectoryIfMissing True dir
415 (path, h) <- openTempFile dir file
431 (path, h) <- openTempFile dir file
416 BS2.hPut h $ renderHtml $ wrapper (Just ns) $ do
432 BS2.hPut h $ renderHtml $ wrapper (Just ns) $ do
417 H.h1 $ toHtml (nsName2Str ns)
433 H.h1 $ toHtml (nsName2Str ns)
418− H.dl ! class_ "decls" $ forM_ content'' (createOtherDoc ist)
434+ H.dl ! class_ "decls" $ forM_ content' (createOtherDoc ist)
420 renameFile path tpath
436 renameFile path tpath