Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
e4610f2d
by Facundo Domínguez at 2026-10-31T09:21:24-04:00
6 changed files:
- + testsuite/tests/haddock/haddock_testsuite/IncrementalUnitId.hs
- testsuite/tests/haddock/haddock_testsuite/Makefile
- testsuite/tests/haddock/haddock_testsuite/all.T
- + testsuite/tests/haddock/haddock_testsuite/haddockIncrementalUnitId.stdout
- utils/haddock/CHANGES.md
- utils/haddock/haddock-api/src/Haddock/Interface.hs
Changes:
| 1 | +-- | A module to test that @haddock --incremental@ finds the module
|
|
| 2 | +-- in the unit given by @-this-unit-id@.
|
|
| 3 | +module IncrementalUnitId where
|
|
| 4 | + |
|
| 5 | +-- | A value with some documentation.
|
|
| 6 | +theAnswer :: Int
|
|
| 7 | +theAnswer = 42 |
| ... | ... | @@ -84,3 +84,12 @@ haddockForeignTest: |
| 84 | 84 | .PHONY: T26114
|
| 85 | 85 | T26114:
|
| 86 | 86 | '$(HADDOCK)' T26114.hs
|
| 87 | + |
|
| 88 | +# Check that `haddock --incremental` looks for the module in the
|
|
| 89 | +# unit given by `-this-unit-id`.
|
|
| 90 | +.PHONY: haddockIncrementalUnitId
|
|
| 91 | +haddockIncrementalUnitId:
|
|
| 92 | + rm -f IncrementalUnitId.hi IncrementalUnitId.o IncrementalUnitId.haddock IncrementalUnitId2.haddock
|
|
| 93 | + '$(TEST_HC)' -c -haddock -fwrite-interface -this-unit-id mypkg-1.0 IncrementalUnitId.hs
|
|
| 94 | + @echo "== haddock finds the module in the unit given by -this-unit-id =="
|
|
| 95 | + '$(HADDOCK)' --incremental=IncrementalUnitId --optghc=-this-unit-id=mypkg-1.0 --dump-interface=IncrementalUnitId.haddock |
| ... | ... | @@ -30,3 +30,8 @@ test('T26114', |
| 30 | 30 | [ignore_stderr, req_haddock, extra_files(['T26114.hs'])],
|
| 31 | 31 | makefile_test,
|
| 32 | 32 | ['T26114'])
|
| 33 | + |
|
| 34 | +test('haddockIncrementalUnitId',
|
|
| 35 | + [ignore_stderr, req_haddock, extra_files(['IncrementalUnitId.hs'])],
|
|
| 36 | + makefile_test,
|
|
| 37 | + ['haddockIncrementalUnitId']) |
| 1 | +== haddock finds the module in the unit given by -this-unit-id ==
|
|
| 2 | +Warning: IncrementalUnitId: could not find link destinations for:
|
|
| 3 | + - GHC.Internal.Types.Int |
| 1 | +## Changes in next
|
|
| 2 | + |
|
| 3 | + * Allow the `--incremental` flag for modules in other units than main.
|
|
| 4 | + In the initial implementation, the argument to incremental could only
|
|
| 5 | + be the name of a module in the main unit. Now this can be changed by
|
|
| 6 | + specifying `--optghc=-this-unit-id=my-unit-id` when invoking haddock.
|
|
| 7 | + |
|
| 1 | 8 | ## Changes in 2.32.0
|
| 2 | 9 | * Add highlighting for inline-code-blocks (sections enclosed in @'s)
|
| 3 | 10 |
| ... | ... | @@ -47,7 +47,6 @@ import Debug.Trace (traceMarkerIO) |
| 47 | 47 | import System.Exit (exitFailure ) -- TODO use Haddock's die
|
| 48 | 48 | import Text.Printf
|
| 49 | 49 | import GHC hiding (verbosity, SuccessFlag(..))
|
| 50 | -import GHC.Builtin.Modules (mkMainModule_)
|
|
| 51 | 50 | import qualified GHC.Data.EnumSet as EnumSet
|
| 52 | 51 | import GHC.Data.FastString (unpackFS)
|
| 53 | 52 | import GHC.Data.Graph.Directed
|
| ... | ... | @@ -76,6 +75,7 @@ import GHC.Unit.Module.Graph (ModuleGraphNode (..), ModuleNodeInfo(..)) |
| 76 | 75 | import GHC.Unit.Module.ModDetails
|
| 77 | 76 | import GHC.Unit.Module.ModIface (mi_semantic_module, mi_boot)
|
| 78 | 77 | import GHC.Unit.Module.ModSummary (isBootSummary)
|
| 78 | +import GHC.Unit.Types (stringToUnit, unitIdString)
|
|
| 79 | 79 | import GHC.Utils.Outputable (Outputable, (<+>), pprModuleName, text)
|
| 80 | 80 | import GHC.Utils.Error (withTiming)
|
| 81 | 81 | import GHC.Utils.Monad (mapMaybeM)
|
| ... | ... | @@ -369,12 +369,14 @@ createOneShotIface verbosity flags instIfaceMap moduleNameStr = do |
| 369 | 369 | |
| 370 | 370 | out verbosity verbose $ "Checking interface " ++ moduleNameStr ++ "..."
|
| 371 | 371 | |
| 372 | - -- Turn on GHC's one-shot mode
|
|
| 372 | + -- Turn on GHC's one-shot mode.
|
|
| 373 | 373 | dflags <- (\df -> df{ ghcMode = OneShot }) <$> getDynFlags
|
| 374 | 374 | modifySession $ hscSetFlags dflags
|
| 375 | 375 | hsc_env <- getSession
|
| 376 | 376 | |
| 377 | - (iface, insts) <- liftIO $ loadHiFile hsc_env doc $ mkMainModule_ moduleNm
|
|
| 377 | + let oneShotUnit = stringToUnit (unitIdString (homeUnitId_ dflags))
|
|
| 378 | + |
|
| 379 | + (iface, insts) <- liftIO $ loadHiFile hsc_env doc $ mkModule oneShotUnit moduleNm
|
|
| 378 | 380 | |
| 379 | 381 | -- Update the DynFlags with the extensions from the source file (as stored in the interface file)
|
| 380 | 382 | -- This is instead of ms_hspp_opts from ModSummary, which is not available in one-shot mode.
|