Skip to content

Commit

Permalink
Filter out haddock doc decls from export lists
Browse files Browse the repository at this point in the history
  • Loading branch information
alanz committed Apr 1, 2024
1 parent 24d96e2 commit 4bafb35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
16 changes: 11 additions & 5 deletions src/Language/Haskell/GHC/ExactPrint/ExactPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ instance ExactPrint (HsModule GhcPs) where
flushComments []
putUnallocatedComments []

decls' <- markTopLevelList (filter removeDocDecl decls)
decls' <- markTopLevelList (filter notDocDecl decls)

lo1 <- case lo0 of
EpExplicitBraces open close -> do
Expand All @@ -1715,9 +1715,15 @@ instance ExactPrint (HsModule GhcPs) where
return (HsModule (XModulePs anf lo1 mdeprec' mbDoc') mmn' mexports' imports' decls')


removeDocDecl :: LHsDecl GhcPs -> Bool
removeDocDecl (L _ DocD{}) = False
removeDocDecl _ = True
notDocDecl :: LHsDecl GhcPs -> Bool
notDocDecl (L _ DocD{}) = False
notDocDecl _ = True

notIEDoc :: LIE GhcPs -> Bool
notIEDoc (L _ IEGroup {}) = False
notIEDoc (L _ IEDoc {}) = False
notIEDoc (L _ IEDocNamed {}) = False
notIEDoc _ = True

-- ---------------------------------------------------------------------

Expand Down Expand Up @@ -4530,7 +4536,7 @@ instance ExactPrint (LocatedL [LocatedA (IE GhcPs)]) where
an0 <- markEpAnnL an lal_rest AnnHiding
p <- getPosP
debugM $ "LocatedL [LIE:p=" ++ showPprUnsafe p
(an1, ies') <- markAnnList an0 (markAnnotated ies)
(an1, ies') <- markAnnList an0 (markAnnotated (filter notIEDoc ies))
return (L an1 ies')

instance (ExactPrint (Match GhcPs (LocatedA body)))
Expand Down
19 changes: 7 additions & 12 deletions tests/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ mkTests = do
roundTripMakeDeltaTests <- findTestsMD libdir
-- prettyRoundTripTests <- findPrettyTests libdir
return $ TestList [
internalTests,
-- internalTests,
roundTripTests
,
(transformTests libdir)
, (failingTests libdir)
,
roundTripBalanceCommentsTests
-- ,
-- (transformTests libdir)
-- , (failingTests libdir)
-- ,
-- roundTripBalanceCommentsTests
-- ,
-- roundTripMakeDeltaTests
]
Expand Down Expand Up @@ -213,7 +213,7 @@ tt' = do
-- mkParserTest libdir "ghc94" "Haddock.hs"
-- mkParserTest libdir "ghc94" "Haddock1.hs"
-- mkParserTest libdir "ghc94" "Haddock2.hs"
-- mkParserTest libdir "ghc94" "Haddock3.hs"
mkParserTest libdir "ghc94" "Haddock3.hs"
-- mkParserTestBC libdir "ghc94" "Haddock1.hs"

-- mkParserTest libdir "ghc98" "ExportWarnings_aux.hs"
Expand All @@ -222,11 +222,6 @@ tt' = do
-- mkParserTest libdir "ghc92" "TopLevelSemis.hs"
-- mkParserTestBC libdir "ghc92" "TopLevelSemis.hs"

-- mkParserTest libdir "ghc92" "TH1.hs"
-- mkParserTestBC libdir "ghc92" "TH1.hs"

-- mkParserTest libdir "transform" "AddLocalDecl1.hs"
mkParserTestBC libdir "transform" "AddLocalDecl1.hs"

-- mkParserTest libdir "ghc710" "CExpected.hs"
-- Needs GHC changes
Expand Down

0 comments on commit 4bafb35

Please sign in to comment.