aboutsummaryrefslogtreecommitdiff
path: root/haddock-api
diff options
context:
space:
mode:
Diffstat (limited to 'haddock-api')
-rw-r--r--haddock-api/haddock-api.cabal1
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker.hs1
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs27
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs40
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs4
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Types.hs59
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs1
-rw-r--r--haddock-api/src/Haddock/Interface/Create.hs1
-rw-r--r--haddock-api/src/Haddock/Types.hs3
9 files changed, 74 insertions, 63 deletions
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index 11567f99..3838c3d8 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -85,6 +85,7 @@ library
Haddock.Backends.Hyperlinker.Ast
Haddock.Backends.Hyperlinker.Parser
Haddock.Backends.Hyperlinker.Renderer
+ Haddock.Backends.Hyperlinker.Types
Haddock.Backends.Hyperlinker.Utils
Haddock.ModuleTree
Haddock.Types
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker.hs b/haddock-api/src/Haddock/Backends/Hyperlinker.hs
index f007f970..4b58190c 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker.hs
@@ -3,6 +3,7 @@ module Haddock.Backends.Hyperlinker
, module Haddock.Backends.Hyperlinker.Utils
) where
+
import Haddock.Types
import Haddock.Backends.Hyperlinker.Renderer
import Haddock.Backends.Hyperlinker.Utils
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
index 9d5c127d..28fdc3f5 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
@@ -3,12 +3,10 @@
{-# LANGUAGE RecordWildCards #-}
-module Haddock.Backends.Hyperlinker.Ast
- ( enrich
- , RichToken(..), TokenDetails(..), rtkName
- ) where
+module Haddock.Backends.Hyperlinker.Ast (enrich) where
-import Haddock.Backends.Hyperlinker.Parser
+
+import Haddock.Backends.Hyperlinker.Types
import qualified GHC
@@ -16,25 +14,6 @@ import Control.Applicative
import Data.Data
import Data.Maybe
-data RichToken = RichToken
- { rtkToken :: Token
- , rtkDetails :: Maybe TokenDetails
- }
-
-data TokenDetails
- = RtkVar GHC.Name
- | RtkType GHC.Name
- | RtkBind GHC.Name
- | RtkDecl GHC.Name
- | RtkModule GHC.ModuleName
- deriving (Eq)
-
-rtkName :: TokenDetails -> Either GHC.Name GHC.ModuleName
-rtkName (RtkVar name) = Left name
-rtkName (RtkType name) = Left name
-rtkName (RtkBind name) = Left name
-rtkName (RtkDecl name) = Left name
-rtkName (RtkModule name) = Right name
-- | Add more detailed information to token stream using GHC API.
enrich :: GHC.RenamedSource -> [Token] -> [RichToken]
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index d927aa08..e206413e 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -1,44 +1,12 @@
-module Haddock.Backends.Hyperlinker.Parser
- ( parse
- , Token(..), TokenType(..)
- , Position(..), Span(..)
- ) where
+module Haddock.Backends.Hyperlinker.Parser (parse) where
+
import Data.Char
import Data.List
import Data.Maybe
-data Token = Token
- { tkType :: TokenType
- , tkValue :: String
- , tkSpan :: Span
- }
-
-data Position = Position
- { posRow :: !Int
- , posCol :: !Int
- }
-
-data Span = Span
- { spStart :: Position
- , spEnd :: Position
- }
-
-data TokenType
- = TkIdentifier
- | TkKeyword
- | TkString
- | TkChar
- | TkNumber
- | TkOperator
- | TkGlyph
- | TkSpecial
- | TkSpace
- | TkComment
- | TkCpp
- | TkPragma
- | TkUnknown
- deriving (Show, Eq)
+import Haddock.Backends.Hyperlinker.Types
+
-- | Turn source code string into a stream of more descriptive tokens.
--
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
index a4d7bc2d..add1465b 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
@@ -1,8 +1,8 @@
module Haddock.Backends.Hyperlinker.Renderer (render) where
+
import Haddock.Types
-import Haddock.Backends.Hyperlinker.Parser
-import Haddock.Backends.Hyperlinker.Ast
+import Haddock.Backends.Hyperlinker.Types
import Haddock.Backends.Hyperlinker.Utils
import qualified GHC
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Types.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Types.hs
new file mode 100644
index 00000000..19cc5288
--- /dev/null
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Types.hs
@@ -0,0 +1,59 @@
+module Haddock.Backends.Hyperlinker.Types where
+
+
+import qualified GHC
+
+
+data Token = Token
+ { tkType :: TokenType
+ , tkValue :: String
+ , tkSpan :: Span
+ }
+
+data Position = Position
+ { posRow :: !Int
+ , posCol :: !Int
+ }
+
+data Span = Span
+ { spStart :: Position
+ , spEnd :: Position
+ }
+
+data TokenType
+ = TkIdentifier
+ | TkKeyword
+ | TkString
+ | TkChar
+ | TkNumber
+ | TkOperator
+ | TkGlyph
+ | TkSpecial
+ | TkSpace
+ | TkComment
+ | TkCpp
+ | TkPragma
+ | TkUnknown
+ deriving (Show, Eq)
+
+
+data RichToken = RichToken
+ { rtkToken :: Token
+ , rtkDetails :: Maybe TokenDetails
+ }
+
+data TokenDetails
+ = RtkVar GHC.Name
+ | RtkType GHC.Name
+ | RtkBind GHC.Name
+ | RtkDecl GHC.Name
+ | RtkModule GHC.ModuleName
+ deriving (Eq)
+
+
+rtkName :: TokenDetails -> Either GHC.Name GHC.ModuleName
+rtkName (RtkVar name) = Left name
+rtkName (RtkType name) = Left name
+rtkName (RtkBind name) = Left name
+rtkName (RtkDecl name) = Left name
+rtkName (RtkModule name) = Right name
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs
index 9ba8446d..db2bfc76 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs
@@ -4,6 +4,7 @@ module Haddock.Backends.Hyperlinker.Utils
, hypSrcModuleUrlFormat, hypSrcModuleNameUrlFormat,
) where
+
import Haddock.Backends.Xhtml.Utils
import GHC
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index 59f7076f..0599151e 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -21,6 +21,7 @@ import Haddock.GhcUtils
import Haddock.Utils
import Haddock.Convert
import Haddock.Interface.LexParseRn
+import Haddock.Backends.Hyperlinker.Types
import Haddock.Backends.Hyperlinker.Ast as Hyperlinker
import Haddock.Backends.Hyperlinker.Parser as Hyperlinker
diff --git a/haddock-api/src/Haddock/Types.hs b/haddock-api/src/Haddock/Types.hs
index da4b3eec..90dbb4d4 100644
--- a/haddock-api/src/Haddock/Types.hs
+++ b/haddock-api/src/Haddock/Types.hs
@@ -35,7 +35,8 @@ import DynFlags (ExtensionFlag, Language)
import OccName
import Outputable
import Control.Monad (ap)
-import Haddock.Backends.Hyperlinker.Ast
+
+import Haddock.Backends.Hyperlinker.Types
-----------------------------------------------------------------------------
-- * Convenient synonyms