@@ -11,12 +11,18 @@ import System.Directory (createDirectoryIfMissing, copyFile)
11import Util.System
11import Util.System
13import Control.Monad
13import Control.Monad
14+import Control.Monad.Trans.State.Strict (execStateT)
15+import Control.Monad.Error (runErrorT)
14import Data.List
17import Data.List
15import Data.List.Split(splitOn)
18import Data.List.Split(splitOn)
17import Idris.Core.TT
20import Idris.Core.TT
18import Idris.REPL
21import Idris.REPL
22+import Idris.Parser (loadModule)
23+import Idris.Delaborate (pshow)
19import Idris.AbsSyntax
24import Idris.AbsSyntax
21import IRTS.System
27import IRTS.System
@@ -73,7 +79,7 @@ checkPkg :: Bool -- ^ Show Warnings
73 -> FilePath -- ^ Path to ipkg file.
79 -> FilePath -- ^ Path to ipkg file.
75checkPkg warnonly quit fpath
81checkPkg warnonly quit fpath
76− = do pkgdesc <-parseDesc fpath
82+ = do pkgdesc <- parseDesc fpath
77 ok <- mapM (testLib warnonly (pkgname pkgdesc)) (libdeps pkgdesc)
83 ok <- mapM (testLib warnonly (pkgname pkgdesc)) (libdeps pkgdesc)
78 when (and ok) $
84 when (and ok) $
79 do dir <- getCurrentDirectory
85 do dir <- getCurrentDirectory
@@ -121,6 +127,33 @@ cleanPkg fp
121 Nothing -> return ()
127 Nothing -> return ()
122 Just s -> rmFile $ dir </> s
128 Just s -> rmFile $ dir </> s
130+-- | Generate IdrisDoc for package
131+documentPkg :: FilePath -- ^ Path to .ipkg file.
134+ do pkgdesc <- parseDesc fp
135+ cd <- getCurrentDirectory
136+ let outputDir = cd </> (pkgname pkgdesc) ++ "_doc"
137+ mods = modules pkgdesc
138+ fs = map (foldl1' (</>) . splitOn "." . showCG) mods
139+ opts = NoREPL : Verbose : idris_opts pkgdesc
140+ setCurrentDirectory $ cd </> sourcedir pkgdesc
141+ make (makefile pkgdesc)
142+ let run l = runErrorT . (execStateT l)
144+ load (f:fs) = do loadModule stdout f; load fs
145+ loader = do idrisMain opts; load fs
146+ idrisInstance <- run loader idrisInit
147+ case idrisInstance of
148+ Left err -> do putStrLn $ pshow idrisInit err; exitWith (ExitFailure 1)
150+ do docRes <- generateDocs ist mods outputDir
152+ Right _ -> putStrLn "IdrisDoc generated"
153+ Left msg -> do putStrLn msg
154+ exitWith (ExitFailure 1)
124-- | Install package
157-- | Install package
125installPkg :: PkgDesc -> IO ()
158installPkg :: PkgDesc -> IO ()
126installPkg pkgdesc
159installPkg pkgdesc
@@ -131,7 +164,6 @@ installPkg pkgdesc
131 Just o -> return () -- do nothing, keep executable locally, for noe
164 Just o -> return () -- do nothing, keep executable locally, for noe
132 mapM_ (installObj (pkgname pkgdesc)) (objs pkgdesc)
165 mapM_ (installObj (pkgname pkgdesc)) (objs pkgdesc)
135-- ---------------------------------------------------------- [ Helper Methods ]
167-- ---------------------------------------------------------- [ Helper Methods ]
136-- Methods for building, testing, installing, and removal of idris
168-- Methods for building, testing, installing, and removal of idris
137-- packages.
169-- packages.