[commit: haddock] master: Add support for top-level function declaration anchors. (c678689)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:41:00 UTC 2015


Repository : ssh://git@git.haskell.org/haddock

On branch  : master
Link       : http://git.haskell.org/haddock.git/commitdiff/c6786894f71809ecfa377a44beab0771a3bc7985

>---------------------------------------------------------------

commit c6786894f71809ecfa377a44beab0771a3bc7985
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Fri Jun 12 01:36:49 2015 +0200

    Add support for top-level function declaration anchors.


>---------------------------------------------------------------

c6786894f71809ecfa377a44beab0771a3bc7985
 haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
index 39bbacf..cb9508e 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
@@ -40,9 +40,9 @@ enrich src =
     detailsMap = concatMap ($ src)
         [ variables
         , types
+        , decls
         , binds
         , imports
-        , decls
         ]
 
 type DetailsMap = [(GHC.SrcSpan, TokenDetails)]
@@ -96,11 +96,16 @@ binds =
 decls :: GHC.RenamedSource -> DetailsMap
 decls (group, _, _, _) = concatMap ($ group)
     [ map typ . concat . map GHC.group_tyclds . GHC.hs_tyclds
+    , everything (<|>) fun
     ]
   where
     typ (GHC.L _ t) =
         let (GHC.L sspan name) = GHC.tcdLName t
         in (sspan, TokenDetails RtkDecl name)
+    fun term = case cast term of
+        (Just (GHC.FunBind (GHC.L sspan name) _ _ _ _ _ :: GHC.HsBind GHC.Name))
+            | GHC.isExternalName name -> pure (sspan, TokenDetails RtkDecl name)
+        _ -> empty
 
 imports :: GHC.RenamedSource -> DetailsMap
 imports =



More information about the ghc-commits mailing list