{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications    #-}
{- |
   Module      : Text.Pandoc.Lua.Module.Path
   Copyright   : © 2019-2026 Albert Krewinkel
   License     : GNU GPL, version 2 or above

   Maintainer  : Albert Krewinkel <albert+pandoc@tarleb.com>
   Stability   : alpha

Pandoc's system Lua module.
-}
module Text.Pandoc.Lua.Module.Path
  ( documentedModule
  ) where

import Data.Version (makeVersion)
import HsLua
import qualified HsLua.Module.Path   as MPath
import qualified HsLua.Module.System as MSystem

-- | Push the pandoc.system module on the Lua stack.
documentedModule :: forall e. LuaError e => Module e
documentedModule :: forall e. LuaError e => Module e
documentedModule = Name -> Module e
forall e. Name -> Module e
defmodule Name
"pandoc.path"
  Module e -> Text -> Module e
forall a. HasDescription a => a -> Text -> a
`withDescription` forall e. Module e -> Text
moduleDescription @e Module e
forall e. LuaError e => Module e
MPath.documentedModule
  Module e -> [Field e] -> Module e
forall e. Module e -> [Field e] -> Module e
`withFields`
      [ Field e
forall e. Field e
MPath.separator
      , Field e
forall e. Field e
MPath.search_path_separator
      ]
  Module e -> [DocumentedFunction e] -> Module e
forall e. Module e -> [DocumentedFunction e] -> Module e
`withFunctions`
      [ DocumentedFunction e
forall e. DocumentedFunction e
MPath.directory              DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. LuaError e => DocumentedFunction e
MSystem.exists               DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
3,Int
7,Int
1]
      , DocumentedFunction e
forall e. DocumentedFunction e
MPath.filename               DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. DocumentedFunction e
MPath.is_absolute            DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. DocumentedFunction e
MPath.is_relative            DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. LuaError e => DocumentedFunction e
MPath.join                   DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. DocumentedFunction e
MPath.make_relative          DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. DocumentedFunction e
MPath.normalize              DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. LuaError e => DocumentedFunction e
MPath.split                  DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. DocumentedFunction e
MPath.split_extension        DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. LuaError e => DocumentedFunction e
MPath.split_search_path      DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      , DocumentedFunction e
forall e. LuaError e => DocumentedFunction e
MPath.treat_strings_as_paths DocumentedFunction e -> Version -> DocumentedFunction e
forall e. DocumentedFunction e -> Version -> DocumentedFunction e
`since` [Int] -> Version
v[Int
2,Int
12]
      ]
 where
  v :: [Int] -> Version
v = [Int] -> Version
makeVersion