[Git][ghc/ghc][master] Have haddock --incremental look for the module in -this-unit-id
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 Have haddock --incremental look for the module in -this-unit-id - - - - - 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: ===================================== testsuite/tests/haddock/haddock_testsuite/IncrementalUnitId.hs ===================================== @@ -0,0 +1,7 @@ +-- | A module to test that @haddock --incremental@ finds the module +-- in the unit given by @-this-unit-id@. +module IncrementalUnitId where + +-- | A value with some documentation. +theAnswer :: Int +theAnswer = 42 ===================================== testsuite/tests/haddock/haddock_testsuite/Makefile ===================================== @@ -84,3 +84,12 @@ haddockForeignTest: .PHONY: T26114 T26114: '$(HADDOCK)' T26114.hs + +# Check that `haddock --incremental` looks for the module in the +# unit given by `-this-unit-id`. +.PHONY: haddockIncrementalUnitId +haddockIncrementalUnitId: + rm -f IncrementalUnitId.hi IncrementalUnitId.o IncrementalUnitId.haddock IncrementalUnitId2.haddock + '$(TEST_HC)' -c -haddock -fwrite-interface -this-unit-id mypkg-1.0 IncrementalUnitId.hs + @echo "== haddock finds the module in the unit given by -this-unit-id ==" + '$(HADDOCK)' --incremental=IncrementalUnitId --optghc=-this-unit-id=mypkg-1.0 --dump-interface=IncrementalUnitId.haddock ===================================== testsuite/tests/haddock/haddock_testsuite/all.T ===================================== @@ -30,3 +30,8 @@ test('T26114', [ignore_stderr, req_haddock, extra_files(['T26114.hs'])], makefile_test, ['T26114']) + +test('haddockIncrementalUnitId', + [ignore_stderr, req_haddock, extra_files(['IncrementalUnitId.hs'])], + makefile_test, + ['haddockIncrementalUnitId']) ===================================== testsuite/tests/haddock/haddock_testsuite/haddockIncrementalUnitId.stdout ===================================== @@ -0,0 +1,3 @@ +== haddock finds the module in the unit given by -this-unit-id == +Warning: IncrementalUnitId: could not find link destinations for: + - GHC.Internal.Types.Int ===================================== utils/haddock/CHANGES.md ===================================== @@ -1,3 +1,10 @@ +## Changes in next + + * Allow the `--incremental` flag for modules in other units than main. + In the initial implementation, the argument to incremental could only + be the name of a module in the main unit. Now this can be changed by + specifying `--optghc=-this-unit-id=my-unit-id` when invoking haddock. + ## Changes in 2.32.0 * Add highlighting for inline-code-blocks (sections enclosed in @'s) ===================================== utils/haddock/haddock-api/src/Haddock/Interface.hs ===================================== @@ -47,7 +47,6 @@ import Debug.Trace (traceMarkerIO) import System.Exit (exitFailure ) -- TODO use Haddock's die import Text.Printf import GHC hiding (verbosity, SuccessFlag(..)) -import GHC.Builtin.Modules (mkMainModule_) import qualified GHC.Data.EnumSet as EnumSet import GHC.Data.FastString (unpackFS) import GHC.Data.Graph.Directed @@ -76,6 +75,7 @@ import GHC.Unit.Module.Graph (ModuleGraphNode (..), ModuleNodeInfo(..)) import GHC.Unit.Module.ModDetails import GHC.Unit.Module.ModIface (mi_semantic_module, mi_boot) import GHC.Unit.Module.ModSummary (isBootSummary) +import GHC.Unit.Types (stringToUnit, unitIdString) import GHC.Utils.Outputable (Outputable, (<+>), pprModuleName, text) import GHC.Utils.Error (withTiming) import GHC.Utils.Monad (mapMaybeM) @@ -369,12 +369,14 @@ createOneShotIface verbosity flags instIfaceMap moduleNameStr = do out verbosity verbose $ "Checking interface " ++ moduleNameStr ++ "..." - -- Turn on GHC's one-shot mode + -- Turn on GHC's one-shot mode. dflags <- (\df -> df{ ghcMode = OneShot }) <$> getDynFlags modifySession $ hscSetFlags dflags hsc_env <- getSession - (iface, insts) <- liftIO $ loadHiFile hsc_env doc $ mkMainModule_ moduleNm + let oneShotUnit = stringToUnit (unitIdString (homeUnitId_ dflags)) + + (iface, insts) <- liftIO $ loadHiFile hsc_env doc $ mkModule oneShotUnit moduleNm -- Update the DynFlags with the extensions from the source file (as stored in the interface file) -- This is instead of ms_hspp_opts from ModSummary, which is not available in one-shot mode. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e4610f2d80ece6d72bd2d79a88b3d990... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e4610f2d80ece6d72bd2d79a88b3d990... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Marge Bot (@marge-bot)