on master help sign in
Some more documentation.
commitaaa777180948074f2d65a23aedc4f7fc7e3d4761 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateThu 21 Jan 2010, 09:19 (17 years ago) parentcf789c7
3 files changed+14−3
src/Text/Hakyll/Internal/Cache.hs+6 src/Text/Hakyll/Page.hs+2−1 src/Text/Hakyll/Renderables.hs+6−2
src/Text/Hakyll/Internal/Cache.hs+6
@@ -8,12 +8,18 @@ import Text.Hakyll.Hakyll (Hakyll)
88import Text.Hakyll.File
99import Data.Binary
1010
11+-- | We can store all datatypes instantiating @Binary@ to the cache. The cache
12+-- directory is specified by the @HakyllConfiguration@, usually @_cache@.
1113storeInCache :: (Binary a) => a -> FilePath -> Hakyll ()
1214storeInCache value path = do
1315 cachePath <- toCache path
1416 makeDirectories cachePath
1517 liftIO $ encodeFile cachePath value
1618
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.
1723getFromCache :: (Binary a) => FilePath -> Hakyll (Maybe a)
1824getFromCache path = do
1925 cachePath <- toCache path
src/Text/Hakyll/Page.hs+2−1
@@ -136,7 +136,8 @@ readPageFromFile path = do
136136 where
137137 url = toURL path
138138
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.
140141readPage :: FilePath -> Hakyll Page
141142readPage path = do
142143 cacheResult <- getFromCache path
src/Text/Hakyll/Renderables.hs+6−2
@@ -64,10 +64,14 @@ data CombinedRenderable a b = CombinedRenderable a b
6464-- | Combine two renderables. The url will always be taken from the first
6565-- "Renderable". Also, if a `$key` is present in both renderables, the
6666-- 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.
6770combine :: (Renderable a, Renderable b) => a -> b -> CombinedRenderable a b
6871combine = CombinedRenderable
6972
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.
7175combineWithURL :: (Renderable a, Renderable b)
7276 => FilePath
7377 -> a
@@ -75,7 +79,7 @@ combineWithURL :: (Renderable a, Renderable b)
7579 -> CombinedRenderable a b
7680combineWithURL = CombinedRenderableWithURL
7781
78−-- | Render combinations.
82+-- Render combinations.
7983instance (Renderable a, Renderable b)
8084 => Renderable (CombinedRenderable a b) where
8185