diff options
author | Mark Lentczner <markl@glyphic.com> | 2010-07-27 20:04:03 +0000 |
---|---|---|
committer | Mark Lentczner <markl@glyphic.com> | 2010-07-27 20:04:03 +0000 |
commit | ccb3be7d8d24eda2b5d871b96966049f2f1a7fc3 (patch) | |
tree | 3fb58e3666bd3f27ace12dcac066023c9da10d55 /src/Haddock | |
parent | fef839b8f0ccec340f92018c382f424c9266767a (diff) |
move themes into html dir with .theme and .std-theme extensions
Diffstat (limited to 'src/Haddock')
-rw-r--r-- | src/Haddock/Backends/Xhtml/Themes.hs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Haddock/Backends/Xhtml/Themes.hs b/src/Haddock/Backends/Xhtml/Themes.hs index 39f698fc..414feec0 100644 --- a/src/Haddock/Backends/Xhtml/Themes.hs +++ b/src/Haddock/Backends/Xhtml/Themes.hs @@ -22,7 +22,7 @@ import Haddock.Options import Control.Monad (liftM) import Data.Char (toLower) import Data.Either (lefts, rights) -import Data.List (nub, partition) +import Data.List (nub) import Data.Maybe (isJust, listToMaybe) import System.Directory @@ -60,16 +60,19 @@ standardTheme libDir = liftM (liftEither (take 1)) (defaultThemes libDir) -- | Default themes that are part of Haddock; added with --default-themes --- First default theme is the standard theme. At present, hard coded to "Ocean" --- if present. +-- The first theme in this list is considered the standard theme. +-- Themes are "discovered" by scanning the html sub-dir of the libDir, +-- and looking for directories with the extension .theme or .std-theme. +-- The later is, obviously, the standard theme. defaultThemes :: FilePath -> IO PossibleThemes defaultThemes libDir = do - themeDirs <- getDirectoryItems (libDir </> "html" </> "themes") - themes <- mapM directoryTheme themeDirs - return $ liftEither shuffle $ sequenceEither themes + themeDirs <- getDirectoryItems (libDir </> "html") + themes <- mapM directoryTheme $ discoverThemes themeDirs + return $ sequenceEither themes where - shuffle ts = let (a,b) = partition isStd ts in a ++ b - isStd c = themeName c == "Ocean" + discoverThemes paths = + filterExt ".std-theme" paths ++ filterExt ".theme" paths + filterExt ext = filter ((== ext).takeExtension) -- | Build a theme from a single .css file |