From acd35b99bf112d4e23e7886da64f5a3b75e102cf Mon Sep 17 00:00:00 2001 From: Antoine Leblanc Date: Tue, 25 Oct 2022 14:41:21 +0100 Subject: [PATCH 1/4] Add 1531 test. --- hoogle-test/ref/Bug1531/test.txt | 14 ++++++++++++++ hoogle-test/src/Bug1531/Bug1531.hs | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 hoogle-test/ref/Bug1531/test.txt create mode 100644 hoogle-test/src/Bug1531/Bug1531.hs diff --git a/hoogle-test/ref/Bug1531/test.txt b/hoogle-test/ref/Bug1531/test.txt new file mode 100644 index 0000000000..1493e70f7c --- /dev/null +++ b/hoogle-test/ref/Bug1531/test.txt @@ -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 diff --git a/hoogle-test/src/Bug1531/Bug1531.hs b/hoogle-test/src/Bug1531/Bug1531.hs new file mode 100644 index 0000000000..4de5c828e9 --- /dev/null +++ b/hoogle-test/src/Bug1531/Bug1531.hs @@ -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 From 8391daed6eaa4d610bee06bc72445085dce83bd3 Mon Sep 17 00:00:00 2001 From: Antoine Leblanc Date: Tue, 25 Oct 2022 16:52:02 +0100 Subject: [PATCH 2/4] Fix ignore-exports not working. --- haddock-api/src/Haddock/Interface/Create.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs index e3c4a52952..8eec4f52be 100644 --- a/haddock-api/src/Haddock/Interface/Create.hs +++ b/haddock-api/src/Haddock/Interface/Create.hs @@ -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) @@ -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 @@ -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] From ab502fc1cb4af6ce3546ebd13ea8eeaa6a40517f Mon Sep 17 00:00:00 2001 From: Antoine Leblanc Date: Tue, 25 Oct 2022 17:52:32 +0100 Subject: [PATCH 3/4] Fix broken html test. --- html-test/ref/IgnoreExports.html | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/html-test/ref/IgnoreExports.html b/html-test/ref/IgnoreExports.html index 029565b8fb..7450a3abc0 100644 --- a/html-test/ref/IgnoreExports.html +++ b/html-test/ref/IgnoreExports.html @@ -58,6 +58,8 @@ >data Foo = Bar
  • :: Int
  • bar :: Int
  • documentation for Foo

    Constructors

    Bar

    Documentation for Bar

    documentation for foo

    bar :: Int #

    documentation for bar

    Date: Tue, 25 Oct 2022 18:55:20 +0100 Subject: [PATCH 4/4] Bump haddock-api version to the one in this branch. --- haddock.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haddock.cabal b/haddock.cabal index 64ec969965..924b712ec6 100644 --- a/haddock.cabal +++ b/haddock.cabal @@ -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