* Mono.Documentation/monodocer.cs, Mono.Documentation/monodocs2html.cs:
authorJonathan Pryor <jpryor@novell.com>
Fri, 5 Dec 2008 15:34:32 +0000 (15:34 -0000)
committerJonathan Pryor <jpryor@novell.com>
Fri, 5 Dec 2008 15:34:32 +0000 (15:34 -0000)
  Reorder parameters to be in sorted order, so `mdoc help COMMAND`
  parameters are sorted.
* Mono.Documentation/monodocer.cs: Remove try/catch in
  MDocUpdater.Run(MDocUpdaterOptions), so that any generated exceptions
  will be handled within mdoc itself (thus allowing the normal
  "See `mdoc help' for more information." message).  Improve some
  error messages so they're more useful.

svn path=/trunk/mcs/; revision=120842

mcs/tools/mdoc/ChangeLog
mcs/tools/mdoc/Mono.Documentation/monodocer.cs
mcs/tools/mdoc/Mono.Documentation/monodocs2html.cs

index 30687c33d710f698d27711b874dccd860db09fe4..b3881c3e946d1def64609ec5858151f4a403d0c5 100644 (file)
@@ -1,3 +1,14 @@
+2008-12-05  Jonathan Pryor <jpryor@novell.com>
+
+       * Mono.Documentation/monodocer.cs, Mono.Documentation/monodocs2html.cs: 
+         Reorder parameters to be in sorted order, so `mdoc help COMMAND` 
+         parameters are sorted.
+       * Mono.Documentation/monodocer.cs: Remove try/catch in
+         MDocUpdater.Run(MDocUpdaterOptions), so that any generated exceptions
+         will be handled within mdoc itself (thus allowing the normal 
+         "See `mdoc help' for more information." message).  Improve some
+         error messages so they're more useful.
+
 2008-12-04  Jonathan Pryor <jpryor@novell.com>
 
        * Makefile: Specify --exceptions=all in mdoc-update invocations.
index f254408c20e3c0208e27b831c0d0af52afa82542..5eef2cb2a5b5aa0718a2babdc7d766baaf3f2d10 100644 (file)
@@ -78,21 +78,9 @@ class MDocUpdater : MDocCommand
 
                opts.type = new List<string> ();
                var p = new OptionSet () {
-                       { "o|out=",
-                               "Root {DIRECTORY} to generate/update documentation.",
-                               v => opts.path = v },
-                       { "i|import=", 
-                               "Import documentation from {FILE}.",
-                               v => opts.import = v },
                        { "delete",
                                "Delete removed members from the XML files.",
                                v => opts.delete = v != null },
-                       { "since=",
-                               "Manually specify the assembly {VERSION} that new members were added in.",
-                               v => opts.since = v },
-                       { "type=",
-                         "Only update documentation for {TYPE}.",
-                               v => opts.type.Add (v) },
                        { "exceptions:",
                          "Document potential exceptions that members can generate.  {SOURCES} " +
                                "is a comma-separated list of:\n" +
@@ -102,6 +90,18 @@ class MDocUpdater : MDocCommand
                                "If nothing is specified, then only exceptions from the member will " +
                                "be listed.",
                                v => opts.exceptions = ParseExceptionLocations (v) },
+                       { "i|import=", 
+                               "Import documentation from {FILE}.",
+                               v => opts.import = v },
+                       { "o|out=",
+                               "Root {DIRECTORY} to generate/update documentation.",
+                               v => opts.path = v },
+                       { "since=",
+                               "Manually specify the assembly {VERSION} that new members were added in.",
+                               v => opts.since = v },
+                       { "type=",
+                         "Only update documentation for {TYPE}.",
+                               v => opts.type.Add (v) },
                };
                opts.assembly = Parse (p, args, "update", 
                                "[OPTIONS]+ ASSEMBLIES",
@@ -109,7 +109,7 @@ class MDocUpdater : MDocCommand
                if (opts.assembly == null)
                        return;
                if (opts.assembly.Count == 0)
-                       Error ("No assemblies specified.");
+                       base.Error ("No assemblies specified.");
 
                Run (opts);
                opts.name = ""; // remove warning about unused member
@@ -142,74 +142,58 @@ class MDocUpdater : MDocCommand
                show_exceptions = opts.show_exceptions;
                exceptions = opts.exceptions;
 
-               try {
-                       // PARSE BASIC OPTIONS AND LOAD THE ASSEMBLY TO DOCUMENT
-                       
-                       if (opts.path == null)
-                               throw new InvalidOperationException("The path option is required.");
-                       
-                       srcPath = opts.path;
+               // PARSE BASIC OPTIONS AND LOAD THE ASSEMBLY TO DOCUMENT
+               
+               if (opts.path == null)
+                       throw new InvalidOperationException("The --out option is required.");
+               
+               srcPath = opts.path;
 
-                       if (opts.type != null && opts.type.Count > 0 && opts.@namespace != null)
-                               throw new InvalidOperationException("You cannot specify both 'type' and 'namespace'.");
+               if (opts.type != null && opts.type.Count > 0 && opts.@namespace != null)
+                       throw new InvalidOperationException("You cannot specify both 'type' and 'namespace'.");
+               
+               if (opts.assembly == null)
+                       throw new InvalidOperationException("The assembly option is required.");
                        
-                       if (opts.assembly == null)
-                               throw new InvalidOperationException("The assembly option is required.");
-                               
-                       assemblies = opts.assembly.Select (a => LoadAssembly (a)).ToList ();
-
-                       if (opts.import != null && ecmadocs == null && slashdocs == null) {
-                               try {
-                                       XmlReader r = new XmlTextReader (opts.import);
-                                       if (r.Read ()) {
-                                               while (r.NodeType != XmlNodeType.Element) {
-                                                       if (!r.Read ())
-                                                               throw new Exception ("Unable to read XML file: " + 
-                                                                               opts.import);
-                                               }
-                                               if (r.LocalName == "doc") {
-                                                       slashdocs = new XmlDocument();
-                                                       slashdocs.Load (opts.import);
-                                               }
-                                               else if (r.LocalName == "Libraries") {
-                                                       ecmadocs = new XmlTextReader (opts.import);
-                                               }
-                                               else
-                                                       throw new Exception ("Unsupported XML format within " + opts.import);
+               assemblies = opts.assembly.Select (a => LoadAssembly (a)).ToList ();
+
+               if (opts.import != null && ecmadocs == null && slashdocs == null) {
+                       try {
+                               XmlReader r = new XmlTextReader (opts.import);
+                               if (r.Read ()) {
+                                       while (r.NodeType != XmlNodeType.Element) {
+                                               if (!r.Read ())
+                                                       throw new Exception ("Unable to read XML file: " + 
+                                                                       opts.import);
                                        }
-                                       r.Close ();
-                               } catch (Exception e) {
-                                       Error ("Could not load XML file: {0}", e.Message);
-                                       Environment.ExitCode = 1;
-                                       return;
+                                       if (r.LocalName == "doc") {
+                                               slashdocs = new XmlDocument();
+                                               slashdocs.Load (opts.import);
+                                       }
+                                       else if (r.LocalName == "Libraries") {
+                                               ecmadocs = new XmlTextReader (opts.import);
+                                       }
+                                       else
+                                               throw new Exception ("Unsupported XML format within " + opts.import);
                                }
+                               r.Close ();
+                       } catch (Exception e) {
+                               Error ("Could not load XML file: {0}", e.Message);
+                               Environment.ExitCode = 1;
+                               return;
                        }
-                       
-                       // PERFORM THE UPDATES
-                       
-                       string dest_dir = opts.updateto != null ? opts.updateto : opts.path;
-                       if (opts.type != null && opts.type.Count > 0)
-                               DoUpdateTypes(opts.path, opts.type, dest_dir);
-                       else if (opts.@namespace != null)
-                               DoUpdateNS (opts.@namespace, Path.Combine (opts.path, opts.@namespace),
-                                               Path.Combine (dest_dir, opts.@namespace));
-                       else
-                               DoUpdateAssemblies(opts.path, dest_dir);
-               
-               } catch (InvalidOperationException error) {
-                       Error (opts.show_exceptions ? error.ToString () : error.Message);
-                       Environment.ExitCode = 1;
-                       return;
-                       
-               } catch (System.IO.IOException error) {
-                       Error (opts.show_exceptions ? error.ToString () : error.Message);
-                       Environment.ExitCode = 1;
-                       return;
-
-               } catch (Exception error) {
-                       Error (opts.show_exceptions ? error.ToString () : error.Message);
-                       Environment.ExitCode = 1;
                }
+               
+               // PERFORM THE UPDATES
+               
+               string dest_dir = opts.updateto != null ? opts.updateto : opts.path;
+               if (opts.type != null && opts.type.Count > 0)
+                       DoUpdateTypes(opts.path, opts.type, dest_dir);
+               else if (opts.@namespace != null)
+                       DoUpdateNS (opts.@namespace, Path.Combine (opts.path, opts.@namespace),
+                                       Path.Combine (dest_dir, opts.@namespace));
+               else
+                       DoUpdateAssemblies(opts.path, dest_dir);
 
                Console.WriteLine("Members Added: {0}, Members Deleted: {1}", additions, deletions);
        }
index 8b1976630dc3b29d8406ff05475bd449012bc088..b428430d06ce038f26f04873cbc2953e94bfbdf8 100644 (file)
@@ -31,20 +31,21 @@ class MDocToHtmlConverter : MDocCommand {
        {
                opts = new MDocToHtmlConverterOptions ();
                var p = new OptionSet () {
+                       { "default-template",
+                               "Writes the default XSLT to stdout.",
+                               v => opts.dumptemplate = v != null },
                        { "ext=",
                                "The file {EXTENSION} to use for created files.  "+
                                        "This defaults to \"html\".",
                                v => opts.ext = v },
-                       { "template=",
-                               "An XSLT {FILE} to use to generate the created " + 
-                                       "files.  If not specified, uses the template generated by --dump-template.",
-                               v => opts.template = v },
-                       { "default-template",
-                               "Writes the default XSLT to stdout.",
-                               v => opts.dumptemplate = v != null },
                        { "o|out=",
                                "The {DIRECTORY} to place the generated files and directories.",
                                v => opts.dest = v },
+                       { "template=",
+                               "An XSLT {FILE} to use to generate the created " + 
+                                       "files.  If not specified, uses the template generated by " + 
+                                       "--default-template.",
+                               v => opts.template = v },
                };
                List<string> extra = Parse (p, args, "export-html", 
                                "[OPTIONS]+ DIRECTORIES",