summaryrefslogtreecommitdiff
path: root/web/site.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-12-29 16:24:27 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-12-29 16:24:27 +0100
commita6cbaff357e2c8f832be8ef76d21ef526430be39 (patch)
tree1ed630264399643c31b2bd0a4969dd1515161718 /web/site.hs
parent5d4d964fccc53167f25683ff7a0f11cde951ca88 (diff)
downloadhakyll-a6cbaff357e2c8f832be8ef76d21ef526430be39.tar.gz
Link to proper haddock docs on hackage
Diffstat (limited to 'web/site.hs')
-rw-r--r--web/site.hs40
1 files changed, 37 insertions, 3 deletions
diff --git a/web/site.hs b/web/site.hs
index 6130bea..aac6368 100644
--- a/web/site.hs
+++ b/web/site.hs
@@ -1,8 +1,12 @@
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
-import Control.Monad (forM_)
-import Data.Monoid (mappend)
+import Control.Applicative ((<$>))
+import Control.Arrow (second)
+import Control.Monad (forM_)
+import Data.List (isPrefixOf)
+import Data.Monoid (mappend)
import Hakyll
+import System.FilePath (dropTrailingPathSeparator, splitPath)
import Text.Pandoc
@@ -14,7 +18,17 @@ main = hakyllWith config $ do
compile compressCssCompiler
-- Static directories
- forM_ ["images/*", "examples/*", "reference/**"] $ \f -> match f $ do
+ forM_ ["images/*", "examples/*"] $ \f -> match f $ do
+ route idRoute
+ compile copyFileCompiler
+
+ -- Haddock stuff
+ match "reference/**.html" $ do
+ route idRoute
+ compile $ fmap (withUrls hackage) <$> getResourceString
+
+ -- Haddock stuff
+ match ("reference/**" `mappend` complement "**.html") $ do
route idRoute
compile copyFileCompiler
@@ -69,3 +83,23 @@ config = defaultConfiguration
, deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
\_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4"
}
+
+
+--------------------------------------------------------------------------------
+-- | Turns
+--
+-- > /usr/share/doc/ghc/html/libraries/base-4.6.0.0/Data-String.html
+--
+-- into
+--
+-- > http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/Data-String.html
+hackage :: String -> String
+hackage url
+ | "/usr" `isPrefixOf` url =
+ "http://hackage.haskell.org/packages/archive/" ++
+ packageName ++ "/" ++ version' ++ "/doc/html/" ++ baseName
+ | otherwise = url
+ where
+ (packageName, version') = second (drop 1) $ break (== '-') package
+ (baseName : package : _) = map dropTrailingPathSeparator $
+ reverse $ splitPath url