on master help sign in
Some more documentation.
aaa7771Jasper Van der Jeugt
src/Text/Hakyll/Internal/Cache.hs+6
@@ -8,12 +8,18 @@ import Text.Hakyll.Hakyll (Hakyll)
8import Text.Hakyll.File
8import Text.Hakyll.File
9import Data.Binary
9import Data.Binary
10
10
11+-- | We can store all datatypes instantiating @Binary@ to the cache. The cache
12+-- directory is specified by the @HakyllConfiguration@, usually @_cache@.
11storeInCache :: (Binary a) => a -> FilePath -> Hakyll ()
13storeInCache :: (Binary a) => a -> FilePath -> Hakyll ()
12storeInCache value path = do
14storeInCache value path = do
13 cachePath <- toCache path
15 cachePath <- toCache path
14 makeDirectories cachePath
16 makeDirectories cachePath
15 liftIO $ encodeFile cachePath value
17 liftIO $ encodeFile cachePath value
16
18
19+-- | Get a value from the cache. The filepath given should not be located in the
20+-- cache. This function performs a timestamp check on the filepath and the
21+-- filepath in the cache, and only returns the cached value when it is still
22+-- up-to-date.
17getFromCache :: (Binary a) => FilePath -> Hakyll (Maybe a)
23getFromCache :: (Binary a) => FilePath -> Hakyll (Maybe a)
18getFromCache path = do
24getFromCache path = do
19 cachePath <- toCache path
25 cachePath <- toCache path
src/Text/Hakyll/Page.hs+2−1
@@ -136,7 +136,8 @@ readPageFromFile path = do
136 where
136 where
137 url = toURL path
137 url = toURL path
138
138
139−-- | Read a page. Might fetch it from the cache if available.
139+-- | Read a page. Might fetch it from the cache if available. Otherwise, it will
140+-- read it from the file given and store it in the cache.
140readPage :: FilePath -> Hakyll Page
141readPage :: FilePath -> Hakyll Page
141readPage path = do
142readPage path = do
142 cacheResult <- getFromCache path
143 cacheResult <- getFromCache path
src/Text/Hakyll/Renderables.hs+6−2
@@ -64,10 +64,14 @@ data CombinedRenderable a b = CombinedRenderable a b
64-- | Combine two renderables. The url will always be taken from the first
64-- | Combine two renderables. The url will always be taken from the first
65-- "Renderable". Also, if a `$key` is present in both renderables, the
65-- "Renderable". Also, if a `$key` is present in both renderables, the
66-- value from the first "Renderable" will be taken as well.
66-- value from the first "Renderable" will be taken as well.
67+--
68+-- Since renderables are always more or less key-value maps, you can see
69+-- this as a @union@ between two maps.
67combine :: (Renderable a, Renderable b) => a -> b -> CombinedRenderable a b
70combine :: (Renderable a, Renderable b) => a -> b -> CombinedRenderable a b
68combine = CombinedRenderable
71combine = CombinedRenderable
69
72
70−-- | Combine two renderables and set a custom URL.
73+-- | Combine two renderables and set a custom URL. This behaves like "combine",
74+-- except that for the @url@ field, the given URL is always chosen.
71combineWithURL :: (Renderable a, Renderable b)
75combineWithURL :: (Renderable a, Renderable b)
72 => FilePath
76 => FilePath
73 -> a
77 -> a
@@ -75,7 +79,7 @@ combineWithURL :: (Renderable a, Renderable b)
75 -> CombinedRenderable a b
79 -> CombinedRenderable a b
76combineWithURL = CombinedRenderableWithURL
80combineWithURL = CombinedRenderableWithURL
77
81
78−-- | Render combinations.
82+-- Render combinations.
79instance (Renderable a, Renderable b)
83instance (Renderable a, Renderable b)
80 => Renderable (CombinedRenderable a b) where
84 => Renderable (CombinedRenderable a b) where
81
85