@@ -110,8 +110,7 @@ createInterface mod_iface flags modMap instIfaceMap = do
110
110
++ map getName fam_instances
111
111
instanceMap = M. fromList (map (getSrcSpan &&& id ) localInsts)
112
112
113
- let maps = (docMap, argMap, instanceMap)
114
- allWarnings = M. unions (warningMap : map ifaceWarningMap (M. elems modMap))
113
+ let allWarnings = M. unions (warningMap : map ifaceWarningMap (M. elems modMap))
115
114
116
115
-- Locations of all TH splices
117
116
-- TODO: We use the splice info in 'Haddock.Backends.Xhtml.Layout.links' to
@@ -122,12 +121,12 @@ createInterface mod_iface flags modMap instIfaceMap = do
122
121
123
122
-- The MAIN functionality: compute the export items which will
124
123
-- each be the actual documentation of this module.
125
- exportItems <- mkExportItems is_sig modMap pkgName mdl sem_mdl allWarnings renamer
126
- exportedNames maps fixMap splices
124
+ exportItems <- mkExportItems modMap pkgName mdl allWarnings renamer
125
+ docMap argMap fixMap splices
127
126
(docs_named_chunks mod_iface_docs)
128
127
(docs_structure mod_iface_docs) instIfaceMap
129
128
130
- let ! visibleNames = mkVisibleNames maps exportItems opts
129
+ let ! visibleNames = mkVisibleNames instanceMap exportItems opts
131
130
132
131
-- Measure haddock documentation coverage.
133
132
let prunedExportItems0 = pruneExportItems exportItems
@@ -157,7 +156,6 @@ createInterface mod_iface flags modMap instIfaceMap = do
157
156
, ifaceRnExportItems = []
158
157
, ifaceExports = exportedNames
159
158
, ifaceVisibleExports = visibleNames
160
- , ifaceDeclMap = M. empty -- TODO: get rid of this
161
159
, ifaceFixMap = fixMap
162
160
, ifaceInstances = instances
163
161
, ifaceFamInstances = fam_instances
@@ -270,8 +268,6 @@ parseOption "not-home" = return (Just OptNotHome)
270
268
parseOption " show-extensions" = return (Just OptShowExtensions )
271
269
parseOption other = tell [" Unrecognised option: " ++ other] >> return Nothing
272
270
273
- type Maps = (DocMap Name , ArgMap Name , InstMap )
274
-
275
271
-- | Extract a map of fixity declarations only
276
272
mkFixMap :: [Name ] -> [(OccName , Fixity )] -> FixMap
277
273
mkFixMap exps occFixs =
@@ -281,24 +277,22 @@ mkFixMap exps occFixs =
281
277
expsOccEnv = mkOccEnv (map (nameOccName &&& id ) exps)
282
278
283
279
mkExportItems
284
- :: Bool -- is it a signature
285
- -> IfaceMap
280
+ :: IfaceMap
286
281
-> Maybe Package -- this package
287
282
-> Module -- this module
288
- -> Module -- semantic module
289
283
-> WarningMap
290
284
-> Renamer
291
- -> [ Name ] -- exported names (orig )
292
- -> Maps
285
+ -> DocMap Name -- docs (keyed by 'Name's )
286
+ -> ArgMap Name -- docs for arguments (keyed by 'Name's)
293
287
-> FixMap
294
288
-> [SrcSpan ] -- splice locations
295
289
-> Map String HsDoc' -- named chunks
296
290
-> DocStructure
297
291
-> InstIfaceMap
298
292
-> ErrMsgGhc [ExportItem GhcRn ]
299
293
mkExportItems
300
- is_sig modMap mbPkgName thisMod semMod warnings renamer exportedNames
301
- maps fixMap splices namedChunks dsItems instIfaceMap =
294
+ modMap mbPkgName thisMod warnings renamer
295
+ docMap argMap fixMap splices namedChunks dsItems instIfaceMap =
302
296
concat <$> traverse lookupExport dsItems
303
297
where
304
298
lookupExport :: DocStructureItem -> ErrMsgGhc [ExportItem GhcRn ]
@@ -329,23 +323,21 @@ mkExportItems
329
323
pure (map ExportModule unrestricted_mods ++ avail_exps)
330
324
331
325
availExport avail =
332
- availExportItem is_sig modMap thisMod semMod warnings exportedNames
333
- maps fixMap splices instIfaceMap avail
326
+ availExportItem modMap thisMod warnings
327
+ docMap argMap fixMap splices instIfaceMap avail
334
328
335
- availExportItem :: Bool -- is it a signature
336
- -> IfaceMap
329
+ availExportItem :: IfaceMap
337
330
-> Module -- this module
338
- -> Module -- semantic module
339
331
-> WarningMap
340
- -> [ Name ] -- exported names (orig )
341
- -> Maps
332
+ -> DocMap Name -- docs (keyed by 'Name's )
333
+ -> ArgMap Name -- docs for arguments (keyed by 'Name's)
342
334
-> FixMap
343
335
-> [SrcSpan ] -- splice locations
344
336
-> InstIfaceMap
345
337
-> AvailInfo
346
338
-> ErrMsgGhc [ExportItem GhcRn ]
347
- availExportItem is_sig modMap thisMod semMod warnings exportedNames
348
- ( docMap, argMap, _) fixMap splices instIfaceMap
339
+ availExportItem modMap thisMod warnings
340
+ docMap argMap fixMap splices instIfaceMap
349
341
availInfo = declWith availInfo
350
342
where
351
343
declWith :: AvailInfo -> ErrMsgGhc [ ExportItem GhcRn ]
@@ -482,32 +474,14 @@ hiDecl t = do
482
474
lookupDocs :: AvailInfo -> WarningMap -> DocMap Name -> ArgMap Name
483
475
-> (DocForDecl Name , [(Name , DocForDecl Name )])
484
476
lookupDocs avail warnings docMap argMap =
485
- let n = availName avail in
486
- let lookupArgDoc x = M. findWithDefault M. empty x argMap in
487
- let doc = (lookupDoc n, lookupArgDoc n) in
488
- let subDocs = [ (s, (lookupDoc s, lookupArgDoc s))
489
- | s <- availSubordinates avail
490
- ] in
491
- (doc, subDocs)
477
+ ( lookupDocForDecl (availName avail)
478
+ , [ (s, lookupDocForDecl s) | s <- availSubordinates avail ]
479
+ )
492
480
where
493
- lookupDoc name = Documentation (M. lookup name docMap) (M. lookup name warnings)
494
-
481
+ lookupDoc x = Documentation (M. lookup x docMap) (M. lookup x warnings)
482
+ lookupArgDoc x = M. findWithDefault M. empty x argMap
483
+ lookupDocForDecl x = (lookupDoc x, lookupArgDoc x)
495
484
496
- -- Note [1]:
497
- ------------
498
- -- It is unnecessary to document a subordinate by itself at the top level if
499
- -- any of its parents is also documented. Furthermore, if the subordinate is a
500
- -- record field or a class method, documenting it under its parent
501
- -- indicates its special status.
502
- --
503
- -- A user might expect that it should show up separately, so we issue a
504
- -- warning. It's a fine opportunity to also tell the user she might want to
505
- -- export the subordinate through the parent export item for clarity.
506
- --
507
- -- The code removes top-level subordinates also when the parent is exported
508
- -- through a 'module' export. I think that is fine.
509
- --
510
- -- (For more information, see Trac #69)
511
485
512
486
-- | Sometimes the declaration we want to export is not the "main" declaration:
513
487
-- it might be an individual record selector or a class method. In these
@@ -651,8 +625,8 @@ pruneExportItems = filter hasDoc
651
625
hasDoc _ = True
652
626
653
627
654
- mkVisibleNames :: Maps -> [ExportItem GhcRn ] -> [DocOption ] -> [Name ]
655
- mkVisibleNames (_, _, instMap) exports opts
628
+ mkVisibleNames :: InstMap -> [ExportItem GhcRn ] -> [DocOption ] -> [Name ]
629
+ mkVisibleNames instMap exports opts
656
630
| OptHide `elem` opts = []
657
631
| otherwise = let ns = concatMap exportName exports
658
632
in seqList ns `seq` ns
0 commit comments