aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/Module/Types.hs
blob: f16737f634884940f1ea86517c7f664cd97faa2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{-# LANGUAGE OverloadedStrings #-}
{- |
   Module      : Text.Pandoc.Lua.Module.Types
   Copyright   : © 2019-2021 Albert Krewinkel
   License     : GNU GPL, version 2 or above

   Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
   Stability   : alpha

Pandoc data type constructors.
-}
module Text.Pandoc.Lua.Module.Types
  ( documentedModule
  ) where

import HsLua ( Module (..), (###), (<#>), (=#>)
             , defun, functionResult, parameter)
import HsLua.Module.Version (peekVersionFuzzy, pushVersion)
import Text.Pandoc.Error (PandocError)
import Text.Pandoc.Lua.ErrorConversion ()

-- | Push the pandoc.types module on the Lua stack.
documentedModule :: Module PandocError
documentedModule = Module
  { moduleName = "pandoc.types"
  , moduleDescription =
      "Constructors for types that are not part of the pandoc AST."
  , moduleFields = []
  , moduleFunctions =
      [ defun "Version"
        ### return
        <#> parameter peekVersionFuzzy "string|integer|{integer,...}|Version"
              "version_specifier"
              (mconcat [ "either a version string like `'2.7.3'`, "
                       , "a single integer like `2`, "
                       , "list of integers like `{2,7,3}`, "
                       , "or a Version object"
                       ])
        =#> functionResult pushVersion "Version" "A new Version object."
      ]
  , moduleOperations = []
  }