aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--haddock-ghc.cabal103
-rw-r--r--haddock.cabal102
-rw-r--r--src/Haddock/Utils.hs41
3 files changed, 172 insertions, 74 deletions
diff --git a/haddock-ghc.cabal b/haddock-ghc.cabal
new file mode 100644
index 00000000..5e907b6f
--- /dev/null
+++ b/haddock-ghc.cabal
@@ -0,0 +1,103 @@
+build-type: Simple
+name: haddock
+version: 2.0
+license: BSD3
+license-file: LICENSE
+copyright: (c) Simon Marlow, David Waern
+author: Simon Marlow, David Waern
+maintainer: David Waern <davve@dtek.chalmers.se>
+stability: stable
+homepage: http://www.haskell.org/haddock/
+synopsis: Haddock is a documentation-generation tool for Haskell
+ libraries
+build-depends:
+ base,
+ haskell98,
+ mtl,
+ ghc>=6.8,
+ Cabal,
+ filepath,
+ network,
+ process,
+ directory,
+ pretty,
+ containers,
+ array
+extensions: CPP, PatternGuards
+ghc-options: -fglasgow-exts
+hs-source-dirs: src
+exposed-modules: Distribution.Haddock
+other-modules:
+ Haddock.Types
+ Haddock.InterfaceFile
+ Haddock.Exception
+data-files:
+ html/haddock-DEBUG.css
+ html/haddock.css
+ html/haddock.js
+ html/haskell_icon.gif
+ html/minus.gif
+ html/plus.gif
+extra-source-files:
+ CHANGES
+ README
+ TODO
+ doc/Makefile
+ doc/README
+ doc/aclocal.m4
+ doc/config.mk.in
+ doc/configure.ac
+ doc/docbook-xml.mk
+ doc/fptools.css
+ doc/haddock.xml
+ examples/A.hs
+ examples/B.hs
+ examples/Bug1.hs
+ examples/Bug2.hs
+ examples/Bug3.hs
+ examples/Bug4.hs
+ examples/Bug6.hs
+ examples/Bug7.hs
+ examples/Bug8.hs
+ examples/Bug9.hs
+ examples/Hash.hs
+ examples/Hidden.hs
+ examples/Makefile
+ examples/NoLayout.hs
+ examples/Test.hs
+ examples/Visible.hs
+ examples/hide-bug/A.hs
+ examples/hide-bug/B.hs
+ examples/hide-bug/C.hs
+ examples/hide-bug/D.hs
+ haddock.spec
+ haskell.vim
+ src/haddock.sh
+
+executable: haddock
+hs-source-dirs: src
+main-is: Main.hs
+extensions: CPP, PatternGuards
+ghc-options: -fglasgow-exts -funbox-strict-fields -O2 -fasm
+other-modules:
+ Haddock.Interface.Rename
+ Haddock.Interface.Create
+ Haddock.Interface.AttachInstances
+ Haddock.Utils.FastMutInt2
+ Haddock.Utils.BlockTable
+ Haddock.Utils.Html
+ Haddock.Utils
+ Haddock.Backends.HaddockDB
+ Haddock.Backends.DevHelp
+ Haddock.Backends.HH
+ Haddock.Backends.HH2
+ Haddock.Backends.Hoogle
+ Haddock.ModuleTree
+ Haddock.Types
+ Haddock.Version
+ Haddock.InterfaceFile
+ Haddock.Exception
+ Haddock.Options
+ Haddock.GHC.Typecheck
+ Haddock.GHC.Utils
+ Haddock.GHC
diff --git a/haddock.cabal b/haddock.cabal
index 5e907b6f..c4202436 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -1,42 +1,21 @@
-build-type: Simple
-name: haddock
-version: 2.0
-license: BSD3
-license-file: LICENSE
-copyright: (c) Simon Marlow, David Waern
-author: Simon Marlow, David Waern
-maintainer: David Waern <davve@dtek.chalmers.se>
-stability: stable
-homepage: http://www.haskell.org/haddock/
-synopsis: Haddock is a documentation-generation tool for Haskell
- libraries
-build-depends:
- base,
- haskell98,
- mtl,
- ghc>=6.8,
- Cabal,
- filepath,
- network,
- process,
- directory,
- pretty,
- containers,
- array
-extensions: CPP, PatternGuards
-ghc-options: -fglasgow-exts
-hs-source-dirs: src
-exposed-modules: Distribution.Haddock
-other-modules:
- Haddock.Types
- Haddock.InterfaceFile
- Haddock.Exception
+name: haddock
+cabal-version: >=1.1.4
+version: 2.0
+license: BSD3
+license-file: LICENSE
+copyright: (c) Simon Marlow
+author: Simon Marlow
+maintainer: Simon Marlow <simonmar@microsoft.com>
+stability: stable
+homepage: http://www.haskell.org/haddock/
+synopsis: Haddock is a documentation-generation tool for Haskell libraries
+build-depends: base>=1.0, haskell98>=1.0, mtl>=1.0, network>=1.0
data-files:
- html/haddock-DEBUG.css
- html/haddock.css
- html/haddock.js
- html/haskell_icon.gif
- html/minus.gif
+ html/haddock-DEBUG.css
+ html/haddock.css
+ html/haddock.js
+ html/haskell_icon.gif
+ html/minus.gif
html/plus.gif
extra-source-files:
CHANGES
@@ -74,30 +53,25 @@ extra-source-files:
haskell.vim
src/haddock.sh
-executable: haddock
-hs-source-dirs: src
-main-is: Main.hs
-extensions: CPP, PatternGuards
-ghc-options: -fglasgow-exts -funbox-strict-fields -O2 -fasm
+executable: haddock-ghc
+hs-source-dirs: src
+main-is: Main.hs
+extensions: CPP, PatternGuards
other-modules:
- Haddock.Interface.Rename
- Haddock.Interface.Create
- Haddock.Interface.AttachInstances
- Haddock.Utils.FastMutInt2
- Haddock.Utils.BlockTable
- Haddock.Utils.Html
- Haddock.Utils
- Haddock.Backends.HaddockDB
- Haddock.Backends.DevHelp
- Haddock.Backends.HH
- Haddock.Backends.HH2
- Haddock.Backends.Hoogle
- Haddock.ModuleTree
- Haddock.Types
- Haddock.Version
- Haddock.InterfaceFile
- Haddock.Exception
- Haddock.Options
- Haddock.GHC.Typecheck
- Haddock.GHC.Utils
- Haddock.GHC
+ FastMutInt2
+ BlockTable
+ HaddockDB
+ HaddockDevHelp
+ HaddockHH
+ HaddockHH2
+ HaddockHoogle
+ HaddockHtml
+ HaddockModuleTree
+ HaddockRename
+ HaddockTypes
+ HaddockUtil
+ HaddockVersion
+ Html
+ GHCUtils
+ Main
+
diff --git a/src/Haddock/Utils.hs b/src/Haddock/Utils.hs
index 6f2c32fc..81834cd8 100644
--- a/src/Haddock/Utils.hs
+++ b/src/Haddock/Utils.hs
@@ -46,14 +46,10 @@ import Module
import PackageConfig ( stringToPackageId )
import Control.Monad ( liftM, MonadPlus(..) )
-import Data.Map ( Map )
-import qualified Data.Map as Map hiding ( Map )
-import Data.Char
+import Data.Char ( isAlpha, isSpace, toUpper, ord )
import Data.IORef ( IORef, newIORef, readIORef )
import Data.List ( intersect, isSuffixOf, intersperse )
-import Data.Maybe ( maybeToList, fromMaybe, isJust, fromJust )
-import Data.Word ( Word8 )
-import Data.Bits ( testBit )
+import Data.Maybe ( maybeToList, fromMaybe )
import Network.URI
import System.Environment ( getProgName )
import System.Exit ( exitWith, ExitCode(..) )
@@ -233,11 +229,36 @@ mapMaybeM _ Nothing = return Nothing
mapMaybeM f (Just a) = f a >>= return . Just
escapeStr :: String -> String
-#if __GLASGOW_HASKELL__ < 603
-escapeStr = flip escapeString unreserved
-#else
escapeStr = escapeURIString isUnreserved
-#endif
+
+-- Following few functions are copy'n'pasted from Network.URI module
+-- to avoid depending on the network lib, since doing so gives a
+-- circular build dependency between haddock and network
+-- (at least if you want to build network with haddock docs)
+
+escapeURIChar :: (Char -> Bool) -> Char -> String
+escapeURIChar p c
+ | p c = [c]
+ | otherwise = '%' : myShowHex (ord c) ""
+ where
+ myShowHex :: Int -> ShowS
+ myShowHex n r = case showIntAtBase 16 (toChrHex) n r of
+ [] -> "00"
+ [c] -> ['0',c]
+ cs -> cs
+ toChrHex d
+ | d < 10 = chr (ord '0' + fromIntegral d)
+ | otherwise = chr (ord 'A' + fromIntegral (d - 10))
+
+escapeURIString :: (Char -> Bool) -> String -> String
+escapeURIString p s = concatMap (escapeURIChar p) s
+
+isUnreserved :: Char -> Bool
+isUnreserved c = isAlphaNumChar c || (c `elem` "-_.~")
+
+isAlphaChar c = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
+isDigitChar c = (c >= '0' && c <= '9')
+isAlphaNumChar c = isAlphaChar c || isDigitChar c
-----------------------------------------------------------------------------