From f1f94f2f634fb065f69ca2cc87a4a54f4e3a39ed Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Fri, 30 Aug 2013 06:05:51 +0100 Subject: Per-module extension flags and language listing. Any extensions that are not enabled by a used language (Haskell2010 &c) will be shown. Furthermore, any implicitly enabled are also going to be shown. While we could eliminate this either by using the GHC API or a dirty hack, I opted not to: if a user doesn't want the implied flags to show, they are recommended to use enable extensions more carefully or individually. Perhaps this will encourage users to not enable the most powerful flags needlessly. Enabled with show-extensions. Conflicts: src/Haddock/InterfaceFile.hs --- src/Haddock/Interface/LexParseRn.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/Haddock/Interface/LexParseRn.hs') diff --git a/src/Haddock/Interface/LexParseRn.hs b/src/Haddock/Interface/LexParseRn.hs index 73f2c165..c302e4f0 100644 --- a/src/Haddock/Interface/LexParseRn.hs +++ b/src/Haddock/Interface/LexParseRn.hs @@ -4,6 +4,7 @@ -- | -- Module : Haddock.Interface.LexParseRn -- Copyright : (c) Isaac Dupree 2009, +-- Mateusz Kowalczyk 2013 -- License : BSD-like -- -- Maintainer : haddock@projects.haskell.org @@ -17,7 +18,7 @@ module Haddock.Interface.LexParseRn , processModuleHeader ) where - +import qualified Data.IntSet as IS import Haddock.Types import Haddock.Parser import Haddock.Interface.ParseModuleHeader @@ -28,11 +29,11 @@ import Data.List import Data.Maybe import FastString import GHC +import DynFlags (ExtensionFlag(..), languageExtensions) import Name import Outputable import RdrName - processDocStrings :: DynFlags -> GlobalRdrEnv -> [HsDocString] -> ErrMsgM (Maybe (Doc Name)) processDocStrings dflags gre strs = do docs <- catMaybes <$> mapM (processDocStringParas dflags gre) strs @@ -82,7 +83,14 @@ processModuleHeader dflags gre safety mayStr = do hmi' = hmi { hmi_description = descr } doc' = rename dflags gre doc return (hmi', Just doc') - return (hmi { hmi_safety = Just $ showPpr dflags safety }, doc) + + let flags :: [ExtensionFlag] + -- We remove the flags implied by the language setting and we display the language instead + flags = map toEnum (IS.toList $ extensionFlags dflags) \\ languageExtensions (language dflags) + return (hmi { hmi_safety = Just $ showPpr dflags safety + , hmi_language = language dflags + , hmi_extensions = flags + } , doc) where failure = (emptyHaddockModInfo, Nothing) -- cgit v1.2.3