@@ -1,39 +1,47 @@
1+--------------------------------------------------------------------------------
12-- | Module providing the main hakyll function and command-line argument parsing
2−--
33{-# LANGUAGE CPP #-}
44module Hakyll.Main
55 ( hakyll
66 , hakyllWith
77 ) where
88
9−import Control.Monad (when)
10−import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
11−import System.Environment (getProgName, getArgs)
12−import System.Process (system)
139
14−import Hakyll.Core.Configuration
15−import Hakyll.Core.Identifier
16−import Hakyll.Core.Runtime
17−import Hakyll.Core.Rules
10+--------------------------------------------------------------------------------
11+import Control.Monad (when)
12+import System.Directory (doesDirectoryExist,
13+ removeDirectoryRecursive)
14+import System.Environment (getArgs, getProgName)
15+import System.Process (system)
1816
19−#ifdef PREVIEW_SERVER
20−import Control.Applicative ((<$>))
21−import Control.Concurrent (forkIO)
22−import qualified Data.Set as S
2317
24−import Hakyll.Core.Rules.Internal
25−import Hakyll.Web.Preview.Poll
26−import Hakyll.Web.Preview.Server
18+--------------------------------------------------------------------------------
19+import Hakyll.Core.Configuration
20+import Hakyll.Core.Rules
21+import Hakyll.Core.Runtime
22+
23+
24+--------------------------------------------------------------------------------
25+#ifdef PREVIEW_SERVER
26+import Control.Applicative ((<$>))
27+import Control.Concurrent (forkIO)
28+import qualified Data.Set as S
29+import Hakyll.Core.Identifier
30+import Hakyll.Core.Rules.Internal
31+import Hakyll.Web.Preview.Poll
32+import Hakyll.Web.Preview.Server
2733#endif
2834
35+
36+--------------------------------------------------------------------------------
2937-- | This usualy is the function with which the user runs the hakyll compiler
30−--
3138hakyll :: Rules a -> IO ()
3239hakyll = hakyllWith defaultConfiguration
3340
41+
42+--------------------------------------------------------------------------------
3443-- | A variant of 'hakyll' which allows the user to specify a custom
3544-- configuration
36−--
3745hakyllWith :: Configuration -> Rules a -> IO ()
3846hakyllWith conf rules = do
3947 args <- getArgs
@@ -49,15 +57,17 @@ hakyllWith conf rules = do
4957 ["deploy"] -> deploy conf
5058 _ -> help
5159
60+
61+--------------------------------------------------------------------------------
5262-- | Build the site
53−--
5463build :: Configuration -> Rules a -> IO ()
5564build conf rules = do
5665 _ <- run conf rules
5766 return ()
5867
68+
69+--------------------------------------------------------------------------------
5970-- | Remove the output directories
60−--
6171clean :: Configuration -> IO ()
6272clean conf = do
6373 remove $ destinationDirectory conf
@@ -68,8 +78,9 @@ clean conf = do
6878 exists <- doesDirectoryExist dir
6979 when exists $ removeDirectoryRecursive dir
7080
81+
82+--------------------------------------------------------------------------------
7183-- | Show usage information.
72−--
7384help :: IO ()
7485help = do
7586 name <- getProgName
@@ -95,8 +106,9 @@ help = do
95106 previewServerDisabled
96107#endif
97108
109+
110+--------------------------------------------------------------------------------
98111-- | Preview the site
99−--
100112preview :: Configuration -> Rules a -> Int -> IO ()
101113#ifdef PREVIEW_SERVER
102114preview conf rules port = do
@@ -111,15 +123,17 @@ preview conf rules port = do
111123preview _ _ _ = previewServerDisabled
112124#endif
113125
126+
127+--------------------------------------------------------------------------------
114128-- | Rebuild the site
115−--
116129rebuild :: Configuration -> Rules a -> IO ()
117130rebuild conf rules = do
118131 clean conf
119132 build conf rules
120133
134+
135+--------------------------------------------------------------------------------
121136-- | Start a server
122−--
123137server :: Configuration -> Int -> IO ()
124138#ifdef PREVIEW_SERVER
125139server conf port = do
@@ -131,15 +145,17 @@ server conf port = do
131145server _ _ = previewServerDisabled
132146#endif
133147
148+
149+--------------------------------------------------------------------------------
134150-- | Upload the site
135−--
136151deploy :: Configuration -> IO ()
137152deploy conf = do
138153 _ <- system $ deployCommand conf
139154 return ()
140155
156+
157+--------------------------------------------------------------------------------
141158-- | Print a warning message about the preview serving not being enabled
142−--
143159#ifndef PREVIEW_SERVER
144160previewServerDisabled :: IO ()
145161previewServerDisabled =