-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Run a sequence of functions on in-memory representations of files
--   
--   See README at <a>https://github.com/icidasset/shikensu#readme</a>
@package shikensu
@version 0.3.11


-- | Types and path helpers. This is re-exported in the main
--   <tt>Shikensu</tt> module.
module Shikensu.Internal.Types

-- | A file definition, along with some additional properties.
data Definition
Definition :: String -> FilePath -> String -> String -> FilePath -> FilePath -> Maybe ByteString -> Metadata -> Maybe FilePath -> FilePath -> Definition
[$sel:basename:Definition] :: Definition -> String
[$sel:dirname:Definition] :: Definition -> FilePath
[$sel:extname:Definition] :: Definition -> String
[$sel:pattern:Definition] :: Definition -> String
[$sel:rootDirname:Definition] :: Definition -> FilePath
[$sel:workingDirname:Definition] :: Definition -> FilePath
[$sel:content:Definition] :: Definition -> Maybe ByteString
[$sel:metadata:Definition] :: Definition -> Metadata
[$sel:parentPath:Definition] :: Definition -> Maybe FilePath
[$sel:pathToRoot:Definition] :: Definition -> FilePath
type Dictionary = [Definition]
type Metadata = Object
absolutePath :: Definition -> String
localPath :: Definition -> String
workspacePath :: Definition -> String
instance GHC.Show.Show Shikensu.Internal.Types.Definition
instance GHC.Classes.Eq Shikensu.Internal.Types.Definition
instance Data.Aeson.Types.ToJSON.ToJSON Shikensu.Internal.Types.Definition


-- | Internal utility functions.
module Shikensu.Internal.Utilities

-- | Get the common directory from a pattern.
commonDirectory :: String -> FilePath

-- | Path to parent, when there is one.
--   
--   <pre>
--   Just "../" or Nothing
--   </pre>
compileParentPath :: FilePath -> Maybe FilePath

-- | Path to root.
--   
--   Example, if <tt>dirname</tt> is 'example/subdir', then this will be
--   <tt>../../</tt>.
--   
--   If the <tt>dirname</tt> is empty, then this will be empty as well.
compilePathToRoot :: FilePath -> FilePath

-- | If the path is a single dot, return an empty string. Otherwise return
--   the path.
replaceSingleDot :: String -> String

-- | Strip prefix.
stripPrefix :: String -> String -> String

-- | Take dirname and replace single dot.
takeDirName :: FilePath -> FilePath


-- | Shikensu.
--   
--   See the README and tests for examples.
module Shikensu

-- | Fork a Definition.
forkDefinition :: FilePath -> Definition -> Definition

-- | Make a single dictionary based on a path to a directory and multiple
--   glob patterns.
--   
--   <ol>
--   <li>Compile patterns so <tt>globDir</tt> can use them.</li>
--   <li>Run <tt>globDir</tt> function on the given (root) path.</li>
--   <li>We get a list back for each pattern (ie. a list of lists), here we
--   put each child list in a tuple along with its pattern.</li>
--   <li>We make a Dictionary out of each tuple (this also needs the
--   path).</li>
--   <li>Merge the dictionaries into one dictionary.</li>
--   </ol>
--   
--   <pre>
--   list ["*.md"] "/root/articles"
--   </pre>
list :: [String] -> FilePath -> IO Dictionary

-- | Flipped version of <a>list</a>.
listF :: FilePath -> [String] -> IO Dictionary

-- | Same as <a>list</a>, but given a relative directory.
--   
--   <pre>
--   listRelative ["*.md"] "./articles"
--   </pre>
listRelative :: [String] -> FilePath -> IO Dictionary

-- | Flipped version <a>listRelative</a>.
listRelativeF :: FilePath -> [String] -> IO Dictionary

-- | Make a Definition.
--   
--   Example definition, given:
--   
--   <ul>
--   <li>the root path `/Users/icidasset/Projects/shikensu`</li>
--   <li>the pattern `example/**/*.md`</li>
--   <li>the absolute path
--   `/Users/icidasset/Projects/shikensu/example/test/hello.md`</li>
--   </ul>
--   
--   <pre>
--   Definition
--       { basename = "hello"
--       , dirname = "test"
--       , extname = ".md"
--       , pattern = "example/**/*.md"
--       , rootDirname = "/Users/icidasset/Projects/shikensu"
--       , workingDirname = "example"
--   
--       , content = Nothing
--       , metadata = HashMap.empty
--       , parentPath = "../"
--       , pathToRoot = "../../"
--       }
--   </pre>
makeDefinition :: FilePath -> String -> FilePath -> Definition

-- | Make a Dictionary.
makeDictionary :: FilePath -> (String, [FilePath]) -> Dictionary


-- | Metadata functions.
module Shikensu.Metadata

-- | Transpose metadata.
--   
--   Transpose our metadata object to a given type which implements the
--   Aeson.FromJSON instance.
--   
--   <pre>
--   data Example =
--       Example { some :: Text }
--       deriving (Generic, FromJSON)
--   
--   hashMap     = HashMap.fromList [ ("some", "metadata") ]
--   defaultEx   = Example { some = "default" }
--   example     = transposeMetadata hashMap defaultEx :: Example
--   </pre>
transposeMetadata :: FromJSON a => Metadata -> a -> a

-- | Inverse of <a>transposeMetadata</a>.
transposeToMetadata :: ToJSON a => a -> Metadata


-- | Dictionary functions.
module Shikensu.Contrib

-- | Clear metadata.
--   
--   Replace the current hash map with an empty one.
clearMetadata :: Dictionary -> Dictionary
clearMetadataDef :: Definition -> Definition

-- | Clone.
--   
--   For each definition that has the given <a>localPath</a> (1st
--   argument), make a clone with a new <a>localPath</a> (2nd argument),
--   and add that into dictionary just after the matching definition.
--   
--   <pre>
--   clone "index.html" "200.html" dictionary
--   </pre>
clone :: FilePath -> FilePath -> Dictionary -> Dictionary

-- | Copy definition properties into the metadata.
--   
--   See the <tt>toJSON</tt> implementation for <a>Definition</a> in
--   <a>Types</a> to see what properties get put in here.
copyPropsToMetadata :: Dictionary -> Dictionary
copyPropsToMetadataDef :: Definition -> Definition

-- | Exclude.
--   
--   Filter out the definitions that have the given <a>localPath</a>.
exclude :: FilePath -> Dictionary -> Dictionary

-- | Insert metadata.
--   
--   Merge the current hash map with another one.
insertMetadata :: Metadata -> Dictionary -> Dictionary
insertMetadataDef :: Metadata -> Definition -> Definition

-- | Permalink.
--   
--   Append the basename to the dirname, and change the basename to the
--   given string. It will NOT change definitions that already have the new
--   basename.
--   
--   <pre>
--   permalink "index" dictionary
--   </pre>
permalink :: String -> Dictionary -> Dictionary
permalinkDef :: String -> Definition -> Definition

-- | Prefix dirname.
--   
--   Prefix the dirname of each definition with a given string.
prefixDirname :: String -> Dictionary -> Dictionary
prefixDirnameDef :: String -> Definition -> Definition

-- | Rename.
--   
--   Change the <a>localPath</a> of the definitions that match a given
--   <a>localPath</a>. For example, if you have a definition with the local
--   path `a/b/example.html`:
--   
--   <pre>
--   rename "a/b/example.html" "example/index.html" dictionary
--   </pre>
--   
--   See <a>localPath</a> for more info.
rename :: FilePath -> FilePath -> Dictionary -> Dictionary
renameDef :: FilePath -> FilePath -> Definition -> Definition

-- | Rename extension.
--   
--   Example:
--   
--   <pre>
--   renameExt ".markdown" ".html" dictionary
--   -- The definitions that had the extname ".markdown"
--   -- now have the extname ".html"
--   </pre>
renameExt :: String -> String -> Dictionary -> Dictionary
renameExtDef :: String -> String -> Definition -> Definition

-- | Render content.
--   
--   Replace the content property by providing a renderer. A renderer is a
--   function with the signature `Definition -&gt; Maybe ByteString`.
--   
--   You can use this to render templates, markdown, etc.
renderContent :: (Definition -> Maybe ByteString) -> Dictionary -> Dictionary
renderContentDef :: (Definition -> Maybe ByteString) -> Definition -> Definition

-- | Replace metadata.
--   
--   Replace the current hash map with another one.
replaceMetadata :: Metadata -> Dictionary -> Dictionary
replaceMetadataDef :: Metadata -> Definition -> Definition

-- | Set content.
--   
--   Set content directly.
setContent :: ByteString -> Dictionary -> Dictionary
setContentDef :: ByteString -> Definition -> Definition

-- | Transform content.
--   
--   Alias for <a>renderContent</a>.
transformContent :: (Definition -> Maybe ByteString) -> Dictionary -> Dictionary
transformContentDef :: (Definition -> Maybe ByteString) -> Definition -> Definition


-- | Sorting functions.
module Shikensu.Sorting

-- | Sort by absolutePath.
--   
--   <pre>
--   Data.List.sortBy Shikensu.sortByAbsolutePath dictionary
--   </pre>
sortByAbsolutePath :: Definition -> Definition -> Ordering

module Shikensu.Utilities

-- | Get stuff out of the metadata. Does NOT return a <a>Maybe</a>, but
--   gives an error if it isn't found.
(!~>) :: (FromJSON a, ToJSON a) => Metadata -> Text -> a

-- | Get stuff out of the metadata. Returns a <a>Maybe</a>.
(~>) :: (FromJSON a, ToJSON a) => Metadata -> Text -> Maybe a

-- | IO Sequence helpers
io :: ([Definition] -> [IO Definition]) -> Dictionary -> IO Dictionary

-- | One way to deal with multiple dictionaries.
--   
--   <pre>
--   lsequence
--       [ ( "pages", Shikensu.list ["src/pages/**/*.html"] rootDir    )
--       , ( "js",    Shikensu.list ["src/javascript/**/*.js"] rootDir )
--       ]
--   </pre>
--   
--   From multiple IO monads to a single IO monad.
lsequence :: Monad m => [(id, m a)] -> m [(id, a)]
mapIO :: (Definition -> IO Definition) -> Dictionary -> IO Dictionary


-- | Dictionary IO functions.
module Shikensu.Contrib.IO

-- | Read.
--   
--   Read the contents of each file, and for each file (ie. definition) put
--   that content in the <a>$sel:content:Definition</a> property.
read :: Dictionary -> IO Dictionary
readDef :: Definition -> IO Definition

-- | Write.
--   
--   Write the contents of each definition to a file. The path of the new
--   file is `joinPath [rootDirname, givenDirectoryName, localPath]`.
write :: FilePath -> Dictionary -> IO Dictionary
writeDef :: FilePath -> Definition -> IO Definition
