on master help sign in
Changed IdrisDoc interface, updated command descriptions.
77eca9cPhilip Rasmussen
main/Main.hs+1
@@ -95,6 +95,7 @@ usagemsg = usagemsghdr ++ "\n" ++
95 "\t --install IPKG Install package\n" ++
95 "\t --install IPKG Install package\n" ++
96 "\t --clean IPKG Clean package\n" ++
96 "\t --clean IPKG Clean package\n" ++
97 "\t --build IPKG Build package\n" ++
97 "\t --build IPKG Build package\n" ++
98+ "\t --mkdoc IPKG Generate IdrisDoc for package\n" ++
98 "\t --exec EXPR Execute as idris\n" ++
99 "\t --exec EXPR Execute as idris\n" ++
99 "\t --libdir Display library directory\n" ++
100 "\t --libdir Display library directory\n" ++
100 "\t --link Display link directory\n" ++
101 "\t --link Display link directory\n" ++
src/Idris/Help.hs+3−3
@@ -4,6 +4,7 @@ data CmdArg = ExprArg -- ^ The command takes an expression
4 | NameArg -- ^ The command takes a name
4 | NameArg -- ^ The command takes a name
5 | FileArg -- ^ The command takes a file
5 | FileArg -- ^ The command takes a file
6 | ModuleArg -- ^ The command takes a module name
6 | ModuleArg -- ^ The command takes a module name
7+ | NamespaceArg -- ^ The command takes a namespace name
7 | OptionArg -- ^ The command takes an option
8 | OptionArg -- ^ The command takes an option
8 | MetaVarArg -- ^ The command takes a metavariable
9 | MetaVarArg -- ^ The command takes a metavariable
9 | ColourArg -- ^ The command is the colour-setting command
10 | ColourArg -- ^ The command is the colour-setting command
@@ -16,6 +17,7 @@ instance Show CmdArg where
16 show NameArg = "<name>"
17 show NameArg = "<name>"
17 show FileArg = "<filename>"
18 show FileArg = "<filename>"
18 show ModuleArg = "<module>"
19 show ModuleArg = "<module>"
20+ show NamespaceArg = "<namespace>"
19 show OptionArg = "<option>"
21 show OptionArg = "<option>"
20 show MetaVarArg = "<metavar>"
22 show MetaVarArg = "<metavar>"
21 show ColourArg = "<option>"
23 show ColourArg = "<option>"
@@ -29,9 +31,7 @@ help =
29 ([":t"], ExprArg, "Check the type of an expression"),
31 ([":t"], ExprArg, "Check the type of an expression"),
30 ([":miss", ":missing"], NameArg, "Show missing clauses"),
32 ([":miss", ":missing"], NameArg, "Show missing clauses"),
31 ([":doc"], NameArg, "Show internal documentation"),
33 ([":doc"], NameArg, "Show internal documentation"),
32− ([":mkdoc"], NoArg, "Generate IdrisDoc for all .idr files in working directory and subdirectories"),
34+ ([":mkdoc"], NamespaceArg, "Generate IdrisDoc for namespace(s) and dependencies"),
33− ([":mkdoc"], NameArg, "Generate IdrisDoc for target namespace"),
34− ([":mkdoc"], OptionArg, "Generate IdrisDoc. Options: [notrace] [ns | dir] [TARGET]"),
35 ([":apropos"], NoArg, "Search names, types, and documentation"),
35 ([":apropos"], NoArg, "Search names, types, and documentation"),
36 ([":i", ":info"], NameArg, "Display information about a type class"),
36 ([":i", ":info"], NameArg, "Display information about a type class"),
37 ([":total"], NameArg, "Check the totality of a name"),
37 ([":total"], NameArg, "Check the totality of a name"),
src/Idris/IdrisDoc.hs+6−19
@@ -1,27 +1,14 @@
1−module Idris.IdrisDoc (generateDocs, DocTarget (..), idrisDocUsage) where
1+module Idris.IdrisDoc (generateDocs) where
2
2
3import Idris.AbsSyntax (IState)
3import Idris.AbsSyntax (IState)
4
4
5type Failable = Either String
5type Failable = Either String
6
6
7-- ist: IState
7-- ist: IState
8−-- t: What do generate documentation for
8+-- nss: List of namespaces to generate documentation for
9−-- ot: Where to output documentation
9+-- out: Where to place the directory of documentation
10−-- trm: Trace mode? (will generate documentation for referred modules)
11−generateDocs :: IState -> DocTarget -> FilePath -> Bool -> IO (Either String ())
10+generateDocs :: IState -> [String] -> FilePath -> IO (Either String ())
12−generateDocs ist t ot trm = err "IdrisDoc has not been implemented yet..."
11+generateDocs ist nss out = err "IdrisDoc is still in development..."
13
12
14err :: String -> IO (Failable ())
13err :: String -> IO (Failable ())
15−err s = return $ Left s
14+err s = return $ Left s
16−
17−-- Target to generate documentation for
18−-- Namespace ns: Generate documentation for the namespace identified by 'ns'
19−-- Dir d: Generate documentation for all namespaces in the directory 'd'
20−data DocTarget = Namespace String | Dir FilePath
21−
22−idrisDocUsage = "Usage: :mkdoc [notrace] [ns | dir] [TARGET]\n\n" ++
23− "notrace: Do not generate IdrisDoc for addtionally referred namespaces.\n" ++
24− "ns: TARGET is a loaded namespace. TARGET required.\n" ++
25− "dir: TARGET is a directory to search recursively for .idr files. TARGET required.\n" ++
26− "TARGET: What to generate IdrisDoc for. By default interpreted as a namespace.\n" ++
27− "<none>: Same as ':mkdoc dir .'"
src/Idris/REPL.hs+5−13
@@ -978,20 +978,12 @@ process h fn (Apropos a) =
978
978
979-- IdrisDoc
979-- IdrisDoc
980process h fn (MakeDoc s) =
980process h fn (MakeDoc s) =
981− do istate <- getIState
981+ do istate <- getIState
982+ let nss = words s
982− outputTarget <- runIO $ getCurrentDirectory
983+ outputDir <- runIO $ getCurrentDirectory
983− let trim = dropWhile isSpace
984− s' = trim s
985− (trace, s'') = case (stripPrefix "notrace" s') of Just x -> (False, trim x)
986− Nothing -> (True, s')
987− target = let (front, back) = span (not . isSpace) s''
988− in if front == "ns" then Namespace (trim back)
989− else if front == "dir" then Dir (trim back)
990− else if null s'' then Dir outputTarget
991− else Namespace (s'')
992− result <- runIO $ generateDocs istate target outputTarget trace
984+ result <- runIO $ generateDocs istate nss outputDir
993 case result of Right _ -> iputStrLn "IdrisDoc generated"
985 case result of Right _ -> iputStrLn "IdrisDoc generated"
994− Left err -> iPrintError (err ++ "\n" ++ idrisDocUsage)
986+ Left err -> iPrintError err
995
987
996classInfo :: ClassInfo -> Idris ()
988classInfo :: ClassInfo -> Idris ()
997classInfo ci = do iputStrLn "Methods:\n"
989classInfo ci = do iputStrLn "Methods:\n"