-- | The logic to render Python auxiliary files is contained in this module
module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.PythonRenderer (
  PythonProject(..)
) where

import Prelude hiding (break,print,sin,cos,tan,floor,(<>))

import Drasil.GOOL (pyName, pyVersion)

import Language.Drasil.Code.Imperative.GOOL.ClassInterface (AuxiliarySym(..))
import Language.Drasil.Code.Imperative.README (ReadMeInfo(..))

import qualified
  Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as
  G (doxConfig, readMe, makefile, noRunIfLib, doxDocConfig,
  docIfEnabled)
import Language.Drasil.Code.Imperative.Build.AST (Runnable, interpMM)
import Language.Drasil.Code.Imperative.Doxygen.Import (yes)

-- | Holds a Python project.
newtype PythonProject a = PP {forall a. PythonProject a -> a
unPP :: a}

instance Functor PythonProject where
  fmap :: forall a b. (a -> b) -> PythonProject a -> PythonProject b
fmap a -> b
f (PP a
x) = b -> PythonProject b
forall a. a -> PythonProject a
PP (a -> b
f a
x)

instance Applicative PythonProject where
  pure :: forall a. a -> PythonProject a
pure = a -> PythonProject a
forall a. a -> PythonProject a
PP
  (PP a -> b
f) <*> :: forall a b.
PythonProject (a -> b) -> PythonProject a -> PythonProject b
<*> (PP a
x) = b -> PythonProject b
forall a. a -> PythonProject a
PP (a -> b
f a
x)

instance Monad PythonProject where
  PP a
x >>= :: forall a b.
PythonProject a -> (a -> PythonProject b) -> PythonProject b
>>= a -> PythonProject b
f = a -> PythonProject b
f a
x

instance AuxiliarySym PythonProject where
  doxConfig :: String
-> SoftwareDossierState
-> Verbosity
-> PythonProject FileAndContents
doxConfig = PythonProject Doc
-> String
-> SoftwareDossierState
-> Verbosity
-> PythonProject FileAndContents
forall (r :: * -> *).
(AuxiliarySym r, Applicative r) =>
r Doc
-> String -> SoftwareDossierState -> Verbosity -> r FileAndContents
G.doxConfig PythonProject Doc
forall (r :: * -> *). AuxiliarySym r => r Doc
optimizeDox
  readMe :: ReadMeInfo -> PythonProject FileAndContents
readMe ReadMeInfo
rmi =
    ReadMeInfo -> PythonProject FileAndContents
forall (r :: * -> *).
Applicative r =>
ReadMeInfo -> r FileAndContents
G.readMe ReadMeInfo
rmi {
        langName = pyName,
        langVersion = pyVersion}

  optimizeDox :: PythonProject Doc
optimizeDox = Doc -> PythonProject Doc
forall a. a -> PythonProject a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
yes

  makefile :: [String]
-> ImplementationType
-> [Comments]
-> SoftwareDossierState
-> ProgData
-> PythonProject FileAndContents
makefile [String]
_ ImplementationType
it [Comments]
cms = Maybe BuildConfig
-> Maybe Runnable
-> Maybe DocConfig
-> SoftwareDossierState
-> ProgData
-> PythonProject FileAndContents
forall (r :: * -> *).
Applicative r =>
Maybe BuildConfig
-> Maybe Runnable
-> Maybe DocConfig
-> SoftwareDossierState
-> ProgData
-> r FileAndContents
G.makefile Maybe BuildConfig
forall a. Maybe a
Nothing (ImplementationType -> Maybe Runnable -> Maybe Runnable
G.noRunIfLib ImplementationType
it Maybe Runnable
pyRunnable)
    ([Comments] -> DocConfig -> Maybe DocConfig
G.docIfEnabled [Comments]
cms DocConfig
G.doxDocConfig)

  auxHelperDoc :: PythonProject Doc -> Doc
auxHelperDoc = PythonProject Doc -> Doc
forall a. PythonProject a -> a
unPP

-- | Default runnable information for Python files.
pyRunnable :: Maybe Runnable
pyRunnable :: Maybe Runnable
pyRunnable = String -> Maybe Runnable
interpMM String
"python3"