aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Backends/Hyperlinker.hs
diff options
context:
space:
mode:
authorŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-06-22 17:20:37 +0200
committerŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-06-30 22:37:49 +0200
commit6f16398a26a12d58b3ba7f1924e2b6b00e68f5f7 (patch)
treed85ee833ededcfc3df42e381154655e01b6a8751 /haddock-api/src/Haddock/Backends/Hyperlinker.hs
parent62d44cd1d37d83fa93d169c2e5b5b758fcc231d6 (diff)
Add support for providing custom CSS files for hyperlinked source.
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Hyperlinker.hs')
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker.hs26
1 files changed, 20 insertions, 6 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker.hs b/haddock-api/src/Haddock/Backends/Hyperlinker.hs
index 88619474..66392a67 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker.hs
@@ -5,21 +5,35 @@ import Haddock.Backends.Hyperlinker.Renderer
import GHC
import Text.XHtml hiding ((</>))
+
+import Data.Maybe
import System.Directory
import System.FilePath
ppHyperlinkedSource :: FilePath -> FilePath -> Maybe FilePath -> [Interface]
-> IO ()
ppHyperlinkedSource outdir libdir mstyle ifaces = do
- createDirectoryIfMissing True (outdir </> "src")
- mapM_ (ppHyperlinkedModuleSource outdir mstyle) ifaces
+ createDirectoryIfMissing True $ srcPath outdir
+ let cssFile = fromMaybe (defaultCssFile libdir) mstyle
+ copyFile cssFile $ srcPath outdir </> srcCssFile
+ mapM_ (ppHyperlinkedModuleSource outdir) ifaces
-ppHyperlinkedModuleSource :: FilePath -> Maybe FilePath -> Interface -> IO ()
-ppHyperlinkedModuleSource outdir mstyle iface = case ifaceTokenizedSrc iface of
- Just tokens -> writeFile path $ showHtml . render mstyle $ tokens
+ppHyperlinkedModuleSource :: FilePath -> Interface -> IO ()
+ppHyperlinkedModuleSource outdir iface = case ifaceTokenizedSrc iface of
+ Just tokens -> writeFile path $ showHtml . render mSrcCssFile $ tokens
Nothing -> return ()
where
- path = outdir </> "src" </> moduleSourceFile (ifaceMod iface)
+ mSrcCssFile = Just $ srcCssFile
+ path = srcPath outdir </> moduleSourceFile (ifaceMod iface)
moduleSourceFile :: Module -> FilePath
moduleSourceFile = (++ ".html") . moduleNameString . moduleName
+
+srcPath :: FilePath -> FilePath
+srcPath outdir = outdir </> "src"
+
+srcCssFile :: FilePath
+srcCssFile = "style.css"
+
+defaultCssFile :: FilePath -> FilePath
+defaultCssFile libdir = libdir </> "html" </> "solarized.css"