Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
55326fa0
by Alan Zimmerman at 2026-08-28T06:08:03-04:00
4 changed files:
- compiler/GHC/Parser/PostProcess/Haddock.hs
- + testsuite/tests/printer/Haddock1.hs
- testsuite/tests/printer/Makefile
- testsuite/tests/printer/all.T
Changes:
| ... | ... | @@ -265,12 +265,14 @@ instance HasHaddock (Located (HsModule GhcPs)) where |
| 265 | 265 | -- ) where
|
| 266 | 266 | --
|
| 267 | 267 | -- Only do this when the export list exists.
|
| 268 | - let (_, close_paren, _) = am_exports mod_anns
|
|
| 268 | + let
|
|
| 269 | + (open_paren, close_paren, _) = am_exports mod_anns
|
|
| 270 | + l_exports = combineSrcSpans (getEpTokenSrcSpan open_paren) (getEpTokenSrcSpan close_paren)
|
|
| 269 | 271 | hsmodExports' <- traverse @Maybe
|
| 270 | 272 | (\exports ->
|
| 271 | - extendHdkA (getEpTokenSrcSpan close_paren) $ do
|
|
| 273 | + extendHdkA l_exports $ do
|
|
| 272 | 274 | exports' <- addHaddockInterleaveItems EpNoLayout mkDocIE exports
|
| 273 | - registerEpTokenHdkA close_paren -- ) position, not end-of-last-item
|
|
| 275 | + registerEpTokenHdkA close_paren -- Do not consume comments after the closing parenthesis
|
|
| 274 | 276 | pure exports')
|
| 275 | 277 | (hsmodExports mod)
|
| 276 | 278 |
| 1 | +{-# OPTIONS_GHC -fno-warn-redundant-constraints -haddock #-}
|
|
| 2 | +-- | Haddock comment,
|
|
| 3 | +-- coming before the module
|
|
| 4 | +module Haddock1 (
|
|
| 5 | + |
|
| 6 | + -- | This is some inline documentation in the export list
|
|
| 7 | + --
|
|
| 8 | + -- > a code block using bird-tracks
|
|
| 9 | + -- > each line must begin with > (which isn't significant unless it
|
|
| 10 | + -- > is at the beginning of the line).
|
|
| 11 | + f
|
|
| 12 | + |
|
| 13 | + {-| nested-style doc comments -}
|
|
| 14 | + , g
|
|
| 15 | + |
|
| 16 | + -- * A section
|
|
| 17 | + -- and without an intervening comma:
|
|
| 18 | + -- ** A subsection
|
|
| 19 | + ) where
|
|
| 20 | + |
|
| 21 | +-- | Haddock before imports
|
|
| 22 | +import Data.List
|
|
| 23 | + |
|
| 24 | +-- | Haddock before decl
|
|
| 25 | +f = undefined
|
|
| 26 | +g = undefined
|
|
| 27 | + |
|
| 28 | +-- | This comment applies to the /following/ declaration
|
|
| 29 | +-- and it continues until the next non-comment line
|
|
| 30 | +data T a b
|
|
| 31 | + = A Int (Maybe Float) -- ^ This comment describes the 'A' constructor
|
|
| 32 | + | -- | This comment describes the 'B' constructor
|
|
| 33 | + B (T a b, T Int Float) -- ^ abcd
|
|
| 34 | + |
|
| 35 | +-- | An abstract data declaration
|
|
| 36 | +data T2 a b = T2 a b |
| ... | ... | @@ -932,3 +932,8 @@ PprModifiers: |
| 932 | 932 | PprQualifiedStrings:
|
| 933 | 933 | $(CHECK_PPR) $(LIBDIR) PprQualifiedStrings.hs
|
| 934 | 934 | $(CHECK_EXACT) $(LIBDIR) PprQualifiedStrings.hs
|
| 935 | + |
|
| 936 | +.PHONY: Haddock1
|
|
| 937 | +Haddock1:
|
|
| 938 | + # $(CHECK_PPR) $(LIBDIR) Haddock1.hs
|
|
| 939 | + $(CHECK_EXACT) $(LIBDIR) Haddock1.hs |
| ... | ... | @@ -223,3 +223,4 @@ test('TestLevelImports', [ignore_stderr, req_ppr_deps], makefile_test, ['TestLev |
| 223 | 223 | test('TestNamedDefaults', [ignore_stderr, req_ppr_deps], makefile_test, ['TestNamedDefaults'])
|
| 224 | 224 | test('PprModifiers', [ignore_stderr,req_ppr_deps], makefile_test, ['PprModifiers'])
|
| 225 | 225 | test('PprQualifiedStrings', [ignore_stderr,req_ppr_deps], makefile_test, ['PprQualifiedStrings'])
|
| 226 | +test('Haddock1', [ignore_stderr,req_ppr_deps], makefile_test, ['Haddock1']) |