on master help sign in
Changed IdrisDoc interface, updated command descriptions.
commit77eca9c3a19f1b16012f279ef8d084a76a7e8723 authorPhilip Rasmussen <pjor@itu.dk> dateWed 26 Mar 2014, 11:36 (13 years ago) parent155e306
4 files changed+15−35
main/Main.hs+1 src/Idris/Help.hs+3−3 src/Idris/IdrisDoc.hs+6−19 src/Idris/REPL.hs+5−13
main/Main.hs+1
@@ -95,6 +95,7 @@ usagemsg = usagemsghdr ++ "\n" ++
9595 "\t --install IPKG Install package\n" ++
9696 "\t --clean IPKG Clean package\n" ++
9797 "\t --build IPKG Build package\n" ++
98+ "\t --mkdoc IPKG Generate IdrisDoc for package\n" ++
9899 "\t --exec EXPR Execute as idris\n" ++
99100 "\t --libdir Display library directory\n" ++
100101 "\t --link Display link directory\n" ++
src/Idris/Help.hs+3−3
@@ -4,6 +4,7 @@ data CmdArg = ExprArg -- ^ The command takes an expression
44 | NameArg -- ^ The command takes a name
55 | FileArg -- ^ The command takes a file
66 | ModuleArg -- ^ The command takes a module name
7+ | NamespaceArg -- ^ The command takes a namespace name
78 | OptionArg -- ^ The command takes an option
89 | MetaVarArg -- ^ The command takes a metavariable
910 | ColourArg -- ^ The command is the colour-setting command
@@ -16,6 +17,7 @@ instance Show CmdArg where
1617 show NameArg = "<name>"
1718 show FileArg = "<filename>"
1819 show ModuleArg = "<module>"
20+ show NamespaceArg = "<namespace>"
1921 show OptionArg = "<option>"
2022 show MetaVarArg = "<metavar>"
2123 show ColourArg = "<option>"
@@ -29,9 +31,7 @@ help =
2931 ([":t"], ExprArg, "Check the type of an expression"),
3032 ([":miss", ":missing"], NameArg, "Show missing clauses"),
3133 ([":doc"], NameArg, "Show internal documentation"),
32− ([":mkdoc"], NoArg, "Generate IdrisDoc for all .idr files in working directory and subdirectories"),
33− ([":mkdoc"], NameArg, "Generate IdrisDoc for target namespace"),
34− ([":mkdoc"], OptionArg, "Generate IdrisDoc. Options: [notrace] [ns | dir] [TARGET]"),
34+ ([":mkdoc"], NamespaceArg, "Generate IdrisDoc for namespace(s) and dependencies"),
3535 ([":apropos"], NoArg, "Search names, types, and documentation"),
3636 ([":i", ":info"], NameArg, "Display information about a type class"),
3737 ([":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
22
33import Idris.AbsSyntax (IState)
44
55type Failable = Either String
66
77-- ist: IState
8−-- t: What do generate documentation for
9−-- ot: Where to output documentation
10−-- trm: Trace mode? (will generate documentation for referred modules)
11−generateDocs :: IState -> DocTarget -> FilePath -> Bool -> IO (Either String ())
12−generateDocs ist t ot trm = err "IdrisDoc has not been implemented yet..."
8+-- nss: List of namespaces to generate documentation for
9+-- out: Where to place the directory of documentation
10+generateDocs :: IState -> [String] -> FilePath -> IO (Either String ())
11+generateDocs ist nss out = err "IdrisDoc is still in development..."
1312
1413err :: String -> IO (Failable ())
15−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 .'"
14+err s = return $ Left s
src/Idris/REPL.hs+5−13
@@ -978,20 +978,12 @@ process h fn (Apropos a) =
978978
979979-- IdrisDoc
980980process h fn (MakeDoc s) =
981− do istate <- getIState
982− outputTarget <- 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
981+ do istate <- getIState
982+ let nss = words s
983+ outputDir <- runIO $ getCurrentDirectory
984+ result <- runIO $ generateDocs istate nss outputDir
993985 case result of Right _ -> iputStrLn "IdrisDoc generated"
994− Left err -> iPrintError (err ++ "\n" ++ idrisDocUsage)
986+ Left err -> iPrintError err
995987
996988classInfo :: ClassInfo -> Idris ()
997989classInfo ci = do iputStrLn "Methods:\n"