Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Fix ignore-exports again on ghc-9.4 #1533

Merged
merged 4 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 10 additions & 3 deletions haddock-api/src/Haddock/Interface/Create.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import qualified GHC.Types.Avail as Avail
import GHC.Types.Basic (PromotionFlag (..))
import GHC.Types.Name (getOccString, getSrcSpan, isDataConName, isValName, nameIsLocalOrFrom, nameOccName, emptyOccEnv)
import GHC.Types.Name.Env (lookupNameEnv)
import GHC.Types.Name.Reader (GlobalRdrEnv, greMangledName, lookupGlobalRdrEnv)
import GHC.Types.Name.Reader (GlobalRdrEnv, globalRdrEnvElts, greMangledName, gresToAvailInfo, isLocalGRE, lookupGlobalRdrEnv)
import GHC.Types.Name.Set (elemNameSet, mkNameSet)
import GHC.Types.SourceFile (HscSource (..))
import GHC.Types.SourceText (SourceText (..), sl_fs)
Expand Down Expand Up @@ -224,9 +224,16 @@ createInterface1 flags unit_state mod_sum tc_gbl_env ifaces inst_ifaces = do
Nothing

-- All the exported Names of this module.
actual_exports :: [AvailInfo]
actual_exports
| OptIgnoreExports `elem` doc_opts =
gresToAvailInfo $ filter isLocalGRE $ globalRdrEnvElts tcg_rdr_env
| otherwise =
tcg_exports

exported_names :: [Name]
exported_names =
concatMap availNamesWithSelectors tcg_exports
concatMap availNamesWithSelectors actual_exports

-- Module imports of the form `import X`. Note that there is
-- a) no qualification and
Expand Down Expand Up @@ -273,7 +280,7 @@ createInterface1 flags unit_state mod_sum tc_gbl_env ifaces inst_ifaces = do

export_items <- mkExportItems is_sig ifaces pkg_name tcg_mod tcg_semantic_mod
warnings tcg_rdr_env exported_names (map fst decls) maps fixities
imported_modules loc_splices export_list tcg_exports inst_ifaces dflags
imported_modules loc_splices export_list actual_exports inst_ifaces dflags

let
visible_names :: [Name]
Expand Down
2 changes: 1 addition & 1 deletion haddock.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ executable haddock
else
-- in order for haddock's advertised version number to have proper meaning,
-- we pin down to a single haddock-api version.
build-depends: haddock-api == 2.27.0
build-depends: haddock-api == 2.27.1

test-suite html-test
type: exitcode-stdio-1.0
Expand Down
14 changes: 14 additions & 0 deletions hoogle-test/ref/Bug1531/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

@package test
@version 0.0.0

module Bug1531

-- | This function is exported.
exportedFunction :: a

-- | This function isn't, but should still be included due to the presence
-- of the ignore-exports pragma.
internalFunction :: a
12 changes: 12 additions & 0 deletions hoogle-test/src/Bug1531/Bug1531.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{-# OPTIONS_HADDOCK ignore-exports #-}

module Bug1531 (exportedFunction) where

-- | This function is exported.
exportedFunction :: a
exportedFunction = undefined

-- | This function isn't, but should still be included due to the presence
-- of the ignore-exports pragma.
internalFunction :: a
internalFunction = undefined
38 changes: 38 additions & 0 deletions html-test/ref/IgnoreExports.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@
>data</span
> <a href="#"
>Foo</a
> = <a href="#"
>Bar</a
></li
><li class="src short"
><a href="#"
>foo</a
> :: <a href="#" title="Data.Int"
>Int</a
></li
><li class="src short"
><a href="#"
>bar</a
> :: <a href="#" title="Data.Int"
>Int</a
></li
></ul
></details
></div
Expand All @@ -84,6 +92,22 @@
><p
>documentation for Foo</p
></div
><div class="subs constructors"
><p class="caption"
>Constructors</p
><table
><tr
><td class="src"
><a id="v:Bar" class="def"
>Bar</a
></td
><td class="doc"
><p
>Documentation for Bar</p
></td
></tr
></table
></div
></div
><div class="top"
><p class="src"
Expand All @@ -99,6 +123,20 @@
>documentation for foo</p
></div
></div
><div class="top"
><p class="src"
><a id="v:bar" class="def"
>bar</a
> :: <a href="#" title="Data.Int"
>Int</a
> <a href="#" class="selflink"
>#</a
></p
><div class="doc"
><p
>documentation for bar</p
></div
></div
></div
></div
></body
Expand Down