packages feed

haddock 2.2.0 → 2.2.1

raw patch · 9 files changed

+109/−44 lines, 9 files

Files

CHANGES view
@@ -1,15 +1,17 @@-Changes in version 2.2.0:+Changes in version 2.2.1:    * Support for GHC 6.8.3    * The Hoogle backend is back, thanks to Neil Mitchell. The plan is to be     compatible with the upcoming Hoogle 4 pre-release -  * Shows associated types in the documentation for class declarations+  * Show associated types in the documentation for class declarations -  * Shows type family declarations+  * Show type family declarations -  * Major bug fixes (#44 and #crash)+  * Show type equality predicates++  * Major bug fixes (#1 and #44)    * It is no longer required to specify the path to GHC's lib dir 
doc/haddock.xml view
@@ -16,7 +16,7 @@       <holder>Simon Marlow</holder>     </copyright>     <abstract>-      <para>This document describes Haddock version 2.2.0, a Haskell+      <para>This document describes Haddock version 2.2.1, a Haskell       documentation tool.</para>     </abstract>   </bookinfo>
haddock.cabal view
@@ -1,5 +1,5 @@ name:                 haddock-version:              2.2.0+version:              2.2.1 cabal-version:        >= 1.2 license:              BSD3 build-type:           Simple
haddock.spec view
@@ -17,7 +17,7 @@ # version label of your release tarball.  %define name    haddock-%define version 2.2.0+%define version 2.2.1 %define release 1  Name:           %{name}
src/Haddock/Backends/Hoogle.hs view
@@ -60,9 +60,6 @@ --------------------------------------------------------------------- -- Utility functions -unL (L _ x) = x-reL = L undefined-  dropComment (' ':'-':'-':' ':_) = [] dropComment (x:xs) = x : dropComment xs
src/Haddock/GHC/Utils.hs view
@@ -24,6 +24,14 @@ import Packages  +unL :: Located a -> a+unL (L _ x) = x+++reL :: a -> Located a+reL = L undefined++ moduleString :: Module -> String moduleString = moduleNameString . moduleName  @@ -65,6 +73,27 @@ getMainDeclBinder (ForD (ForeignImport name _ _)) = Just (unLoc name) getMainDeclBinder (ForD (ForeignExport _ _ _)) = Nothing getMainDeclBinder _ = Nothing+++isTyClD (TyClD _) = True+isTyClD _ = False+++isClassD (TyClD d) = isClassDecl d+isClassD _ = False+++isDocD (DocD _) = True+isDocD _ = False+++isInstD (InstD _) = True+isInstD (TyClD d) = isFamInstDecl d+isInstD _ = False+++declATs (TyClD d) | isClassDecl d = map (tcdName . unL) $ tcdATs d+declATs _ = []   pretty :: Outputable a => a -> String
src/Haddock/Interface/AttachInstances.hs view
@@ -125,6 +125,7 @@ toHsPred :: PredType -> HsPred Name toHsPred (ClassP cls ts) = HsClassP (className cls) (map toLHsType ts) toHsPred (IParam n t) = HsIParam n (toLHsType t)+toHsPred (EqPred t1 t2) = HsEqualP (toLHsType t1) (toLHsType t2)   toLHsType = noLoc . toHsType
src/Haddock/Interface/Create.hs view
@@ -146,7 +146,7 @@ mkDeclMap :: [DeclWithDoc] -> Map Name DeclWithDoc mkDeclMap decls = Map.fromList [ (n, (L loc d, doc)) | (L loc d, doc) <- decls                                 , (n, doc) <- (declName d, doc) : subordinates d-                               , not (isDoc d), not (isInstance d) ]+                               , not (isDocD d), not (isInstD d) ]   -- | Group type family instances together. Include the family declaration@@ -161,19 +161,8 @@     ex ((L _ (TyClD d)), _) = d -} -isTyClD (TyClD _) = True-isTyClD _ = False  -isDoc (DocD _) = True-isDoc _ = False---isInstance (InstD _) = True-isInstance (TyClD d) = isFamInstDecl d-isInstance _ = False-- subordinates (TyClD d) = classDataSubs d subordinates _ = [] @@ -191,12 +180,9 @@     fields       = concat [ fields | RecCon fields <- map con_details cons]  --- All the sub declarations of a class (except default methods), ordered by+-- All the sub declarations of a class (that we handle), ordered by -- source location, with documentation attached if it exists. -classDecls = filter notDef . collectDocs . sortByLoc . declsFromClass-  where-    notDef (L _ (ValD _), _) = False-    notDef _                 = True  +classDecls = filterDecls . collectDocs . sortByLoc . declsFromClass   declsFromClass class_ = docs ++ defs ++ sigs ++ ats@@ -213,17 +199,19 @@ declName (SigD sig) = fromJust $ sigNameNoLoc sig  --- All the top-level declarations of a module, ordered by source location,--- with documentation attached if it exists.+-- | The top-level declarations of a module that we care about, +-- ordered by source location, with documentation attached if it exists. topDecls :: HsGroup Name -> [DeclWithDoc] -topDecls = collectDocs . sortByLoc . declsFromGroup    +topDecls = filterClasses . filterDecls . collectDocs . sortByLoc . declsFromGroup  -filterOutInstances = filter (\(L _ d, _) -> not (isInstance d))+filterOutInstances = filter (\(L _ d, _) -> not (isInstD d))  --- | Pick out the declarations that we want from a group+-- | Take all declarations in an 'HsGroup' and convert them into a list of+-- 'LHsDecl's declsFromGroup :: HsGroup Name -> [LHsDecl Name]+-- TODO: actually take all declarations declsFromGroup group =    decls hs_tyclds TyClD group ++   decls hs_fords  ForD  group ++@@ -267,6 +255,35 @@   --------------------------------------------------------------------------------+-- Filtering of declarations+--+-- We filter out declarations that we don't intend to handle later.+--------------------------------------------------------------------------------+++-- | Filter out declarations that we don't handle in Haddock+filterDecls :: [DeclWithDoc] -> [DeclWithDoc]+filterDecls decls = filter (isHandled . unL . fst) decls+  where+    isHandled (ForD (ForeignImport {})) = True+    isHandled (TyClD {}) = True+    isHandled (InstD {}) = True+    isHandled (SigD d) = isVanillaLSig (reL d)+    -- we keep doc declarations to be able to get at named docs+    isHandled (DocD _) = True+    isHandled _ = False+++-- | Go through all class declarations and filter their sub-declarations+filterClasses :: [DeclWithDoc] -> [DeclWithDoc]+filterClasses decls = [ if isClassD d then (L loc (filterClass d), doc) else x +                      | x@(L loc d, doc) <- decls ]+  where+    filterClass (TyClD c) =+      TyClD $ c { tcdSigs = filter isVanillaLSig $ tcdSigs c }  +++-------------------------------------------------------------------------------- -- Instances -------------------------------------------------------------------------------- @@ -332,6 +349,14 @@  let name:subs = map unLoc (tyClDeclNames tycld) ]  +{-+attachATs :: [IE Name] -> ([IE Name], [Name])+attachATs exports = +  where+    ats =   <- export ]+-}++ -- | Build the list of items that will become the documentation, from the -- export list.  At this point, the list of ExportItems is in terms of -- original names.@@ -355,7 +380,7 @@     = everything_local_exported   | Just specs <- maybe_exps = liftM concat $ mapM lookupExport specs   where-    instances = [ d  | d@(L _ decl, _) <- decls, isInstance decl ]+    instances = [ d  | d@(L _ decl, _) <- decls, isInstD decl ]      everything_local_exported =  -- everything exported       return (fullContentsOfThisModule this_mod decls)@@ -380,18 +405,21 @@       case r of         Nothing -> return []         Just found -> return [ ExportDoc found ]- +     declWith :: Name -> ErrMsgM [ ExportItem Name ]     declWith t-	| Just (decl, maybeDoc) <- findDecl t-        = return [ ExportDecl (restrictTo subs (extractDecl t mdl decl)) maybeDoc [] ]-	| otherwise-	= return []-	where -              mdl = nameModule t-	      subs = filter (`elem` exported_names) all_subs-              all_subs | mdl == this_mod = Map.findWithDefault [] t sub_map-		       | otherwise       = allSubsOfName modMap t+      -- temp hack: we filter out separately declared ATs, since we haven't decided how+      -- to handle them yet. We should really give an warning message also, and filter the+      -- name out in mkVisibleNames...+      | Just (decl, maybeDoc) <- findDecl t, t `notElem` declATs (unL decl) =+          return [ ExportDecl (restrictTo subs (extractDecl t mdl decl)) maybeDoc [] ]+      | otherwise = return []+     where +       mdl = nameModule t+       subs = filter (`elem` exported_names) all_subs+       all_subs+         | mdl == this_mod = Map.findWithDefault [] t sub_map+         | otherwise       = allSubsOfName modMap t      fullContentsOf m   	| m == this_mod = return (fullContentsOfThisModule this_mod decls)@@ -433,6 +461,7 @@       TyClD d | isClassDecl d ->          let matches = [ sig | sig <- tcdSigs d, sigName sig == Just name,                         isVanillaLSig sig ] -- TODO: document fixity+--        let assocMathes = [ tyDecl | at <- tcdATs d,  ]          in case matches of            [s0] -> let (n, tyvar_names) = name_and_tyvars d                       L pos sig = extractClassDecl n mdl tyvar_names s0
src/Haddock/Utils.hs view
@@ -40,6 +40,7 @@  ) where  import Haddock.Types+import Haddock.GHC.Utils  import GHC import SrcLoc@@ -89,7 +90,8 @@       []    -> TyClD (d { tcdND = DataType, tcdCons = [] })        [con] -> TyClD (d { tcdCons = [con] })   TyClD d | isClassDecl d -> -    TyClD (d { tcdSigs = restrictDecls names (tcdSigs d) })+    TyClD (d { tcdSigs = restrictDecls names (tcdSigs d),+               tcdATs = restrictATs names (tcdATs d) })   _ -> decl     restrictCons :: [Name] -> [LConDecl Name] -> [LConDecl Name]@@ -116,6 +118,11 @@ restrictDecls names decls = filter keep decls   where keep d = fromJust (sigName d) `elem` names         -- has to have a name, since it's a class method type signature+++restrictATs :: [Name] -> [LTyClDecl Name] -> [LTyClDecl Name]+restrictATs names ats = [ at | at <- ats , tcdName (unL at) `elem` names ]+  -- ----------------------------------------------------------------------------- -- Filename mangling functions stolen from s main/DriverUtil.lhs.