on master help sign in
Link to proper haddock docs on hackage
commita6cbaff357e2c8f832be8ef76d21ef526430be39 authorJasper Van der Jeugt <m@jaspervdj.be> dateSat 29 Dec 2012, 16:24 (14 years ago) parent5d4d964
2 files changed+46−4
src/Hakyll/Core/Compiler.hs+9−1 web/site.hs+37−3
src/Hakyll/Core/Compiler.hs+9−1
@@ -4,6 +4,7 @@
44module Hakyll.Core.Compiler
55 ( Compiler
66 , getUnderlying
7+ , getUnderlyingExtension
78 , makeItem
89 , getRoute
910 , getResourceBody
@@ -31,8 +32,8 @@ import Control.Applicative ((<$>))
3132import Data.Binary (Binary)
3233import Data.ByteString.Lazy (ByteString)
3334import Data.Typeable (Typeable)
34−import Prelude hiding (id, (.))
3535import System.Environment (getProgName)
36+import System.FilePath (takeExtension)
3637
3738
3839--------------------------------------------------------------------------------
@@ -52,6 +53,13 @@ getUnderlying :: Compiler Identifier
5253getUnderlying = compilerUnderlying <$> compilerAsk
5354
5455
56+--------------------------------------------------------------------------------
57+-- | Get the extension of the underlying identifier. Returns something like
58+-- @".html"@
59+getUnderlyingExtension :: Compiler String
60+getUnderlyingExtension = takeExtension . toFilePath <$> getUnderlying
61+
62+
5563--------------------------------------------------------------------------------
5664makeItem :: a -> Compiler (Item a)
5765makeItem x = do
web/site.hs+37−3
@@ -1,8 +1,12 @@
11--------------------------------------------------------------------------------
22{-# LANGUAGE OverloadedStrings #-}
3−import Control.Monad (forM_)
4−import Data.Monoid (mappend)
3+import Control.Applicative ((<$>))
4+import Control.Arrow (second)
5+import Control.Monad (forM_)
6+import Data.List (isPrefixOf)
7+import Data.Monoid (mappend)
58import Hakyll
9+import System.FilePath (dropTrailingPathSeparator, splitPath)
610import Text.Pandoc
711
812
@@ -14,7 +18,17 @@ main = hakyllWith config $ do
1418 compile compressCssCompiler
1519
1620 -- Static directories
17− forM_ ["images/*", "examples/*", "reference/**"] $ \f -> match f $ do
21+ forM_ ["images/*", "examples/*"] $ \f -> match f $ do
22+ route idRoute
23+ compile copyFileCompiler
24+
25+ -- Haddock stuff
26+ match "reference/**.html" $ do
27+ route idRoute
28+ compile $ fmap (withUrls hackage) <$> getResourceString
29+
30+ -- Haddock stuff
31+ match ("reference/**" `mappend` complement "**.html") $ do
1832 route idRoute
1933 compile copyFileCompiler
2034
@@ -69,3 +83,23 @@ config = defaultConfiguration
6983 , deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
7084 \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4"
7185 }
86+
87+
88+--------------------------------------------------------------------------------
89+-- | Turns
90+--
91+-- > /usr/share/doc/ghc/html/libraries/base-4.6.0.0/Data-String.html
92+--
93+-- into
94+--
95+-- > http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/Data-String.html
96+hackage :: String -> String
97+hackage url
98+ | "/usr" `isPrefixOf` url =
99+ "http://hackage.haskell.org/packages/archive/" ++
100+ packageName ++ "/" ++ version' ++ "/doc/html/" ++ baseName
101+ | otherwise = url
102+ where
103+ (packageName, version') = second (drop 1) $ break (== '-') package
104+ (baseName : package : _) = map dropTrailingPathSeparator $
105+ reverse $ splitPath url