Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty haddocks and remove empty comments. #1459

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add isCommentHaddock
  • Loading branch information
philderbeast committed Aug 3, 2024
commit e0eb3458acb2f3adad3ade79f63d09045667410e
8 changes: 8 additions & 0 deletions src/GHC/Util/ApiAnnotation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module GHC.Util.ApiAnnotation (
, GHC.Util.ApiAnnotation.comments
, isCommentMultiline
, isCommentPragma
, isCommentHaddock
, pragmas
, flags
, languagePragmas
Expand Down Expand Up @@ -67,6 +68,13 @@ isCommentPragma (L _ (EpaComment (EpaBlockComment comm) _)) =
"{-#" `isPrefixOf` comm && "#-}" `isSuffixOf` comm
isCommentPragma _ = False

isCommentHaddock :: LEpaComment -> Bool
isCommentHaddock (L _ (EpaComment (EpaBlockComment comm) _)) =
"{- |" `isPrefixOf` comm && "-}" `isSuffixOf` comm
isCommentHaddock (L _ (EpaComment (EpaLineComment comm) _)) =
"-- |" `isPrefixOf` comm || "-- ^" `isPrefixOf` comm
isCommentHaddock _ = False

-- Pragmas have the form @{-# ...#-}@.
pragmas :: EpAnnComments -> [(LEpaComment, String)]
pragmas x =
Expand Down