From a6cbaff357e2c8f832be8ef76d21ef526430be39 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 29 Dec 2012 16:24:27 +0100 Subject: Link to proper haddock docs on hackage --- web/site.hs | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'web/site.hs') 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 -- cgit v1.2.3