on master help sign in
Link to proper haddock docs on hackage
a6cbaffJasper Van der Jeugt
src/Hakyll/Core/Compiler.hs+9−1
@@ -4,6 +4,7 @@
4module Hakyll.Core.Compiler
4module Hakyll.Core.Compiler
5 ( Compiler
5 ( Compiler
6 , getUnderlying
6 , getUnderlying
7+ , getUnderlyingExtension
7 , makeItem
8 , makeItem
8 , getRoute
9 , getRoute
9 , getResourceBody
10 , getResourceBody
@@ -31,8 +32,8 @@ import Control.Applicative ((<$>))
31import Data.Binary (Binary)
32import Data.Binary (Binary)
32import Data.ByteString.Lazy (ByteString)
33import Data.ByteString.Lazy (ByteString)
33import Data.Typeable (Typeable)
34import Data.Typeable (Typeable)
34−import Prelude hiding (id, (.))
35import System.Environment (getProgName)
35import System.Environment (getProgName)
36+import System.FilePath (takeExtension)
36
37
37
38
38--------------------------------------------------------------------------------
39--------------------------------------------------------------------------------
@@ -52,6 +53,13 @@ getUnderlying :: Compiler Identifier
52getUnderlying = compilerUnderlying <$> compilerAsk
53getUnderlying = compilerUnderlying <$> compilerAsk
53
54
54
55
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+
55--------------------------------------------------------------------------------
63--------------------------------------------------------------------------------
56makeItem :: a -> Compiler (Item a)
64makeItem :: a -> Compiler (Item a)
57makeItem x = do
65makeItem x = do
web/site.hs+37−3
@@ -1,8 +1,12 @@
1--------------------------------------------------------------------------------
1--------------------------------------------------------------------------------
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3−import Control.Monad (forM_)
3+import Control.Applicative ((<$>))
4+import Control.Arrow (second)
5+import Control.Monad (forM_)
6+import Data.List (isPrefixOf)
4−import Data.Monoid (mappend)
7+import Data.Monoid (mappend)
5import Hakyll
8import Hakyll
9+import System.FilePath (dropTrailingPathSeparator, splitPath)
6import Text.Pandoc
10import Text.Pandoc
7
11
8
12
@@ -14,7 +18,17 @@ main = hakyllWith config $ do
14 compile compressCssCompiler
18 compile compressCssCompiler
15
19
16 -- Static directories
20 -- 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
18 route idRoute
32 route idRoute
19 compile copyFileCompiler
33 compile copyFileCompiler
20
34
@@ -69,3 +83,23 @@ config = defaultConfiguration
69 , deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
83 , deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
70 \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4"
84 \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4"
71 }
85 }
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