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
|
module CurryDoc.Files ( generateModuleDocMapping )
where
import System.Directory ( doesDirectoryExist, getDirectoryContents )
import System.FilePath ( (</>), takeExtension )
import System.CurryPath ( stripCurrySuffix )
generateModuleDocMapping :: [(String,String)] -> IO [(String,String)]
generateModuleDocMapping pkglocs =
mapM genPkgMapping pkglocs >>= return . concat
where
genPkgMapping (srcroot,docroot) = do
mods <- curryModulesInDir srcroot
return $ map (\m -> (m,docroot)) mods
curryModulesInDir :: String -> IO [String]
curryModulesInDir dir = getModules "" dir
where
getModules p d = do
exdir <- doesDirectoryExist d
entries <- if exdir then getDirectoryContents d else return []
let realentries = filter (\f -> length f >= 1 && head f /= '.') entries
newprogs = filter (\f -> takeExtension f == ".curry") realentries
subdirs <- mapM (\e -> doesDirectoryExist (d </> e) >>=
\b -> return $ if b then [e] else []) realentries
>>= return . concat
subdirentries <- mapM (\s -> getModules (p ++ s ++ ".") (d </> s)) subdirs
return $ map ((p ++) . stripCurrySuffix) newprogs ++ concat subdirentries
|