Add index creation operations to mdoc
authorJeremie Laval <jeremie.laval@gmail.com>
Mon, 31 Oct 2011 14:43:32 +0000 (15:43 +0100)
committerJeremie Laval <jeremie.laval@gmail.com>
Mon, 31 Oct 2011 14:44:28 +0000 (15:44 +0100)
mcs/tools/mdoc/Mono.Documentation/index.cs [new file with mode: 0644]
mcs/tools/mdoc/Mono.Documentation/mdoc.cs
mcs/tools/mdoc/mdoc.exe.sources

diff --git a/mcs/tools/mdoc/Mono.Documentation/index.cs b/mcs/tools/mdoc/Mono.Documentation/index.cs
new file mode 100644 (file)
index 0000000..b9205ba
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// index.cs
+// Index maker (both normal and Lucene-based)
+//
+// Authors:
+//    Jérémie Laval <jeremie dot laval at xamarin dot com>
+//
+// Copyright 2011 Xamarin Inc (http://www.xamarin.com).
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+using System;
+using System.Collections.Generic;
+
+using Mono.Options;
+using Monodoc;
+
+namespace Mono.Documentation {
+
+       class MDocIndex : MDocCommand {
+               public override void Run (IEnumerable<string> args)
+               {
+                       string rootPath = null;
+
+                       var options = new OptionSet () {
+                               { "r=|root=", "Specify which documentation root to use. Default is $libdir/monodoc", v => rootPath = v },
+                       };
+
+                       var extra = Parse (options, args, "index", 
+                                          "[OPTIONS]+ ACTION",
+                                          "Create tree indexes depending on ACTION. Possible values are \"index\" or \"search\"");
+                       if (extra == null)
+                               return;
+
+                       var root = string.IsNullOrEmpty (rootPath) ? RootTree.LoadTree () : RootTree.LoadTree (rootPath);
+
+                       foreach (var action in extra) {
+                               switch (action) {
+                               case "index":
+                                       RootTree.MakeIndex (root);
+                                       break;
+                               case "search":
+                                       RootTree.MakeSearchIndex (root);
+                                       break;
+                               }
+                       }
+               }
+       }
+}
\ No newline at end of file
index c610da8d00da63bd2ee747ca917ef9e25c645213..7ce10c852514471738055763dd48567fa613de6d 100644 (file)
@@ -47,6 +47,7 @@ namespace Mono.Documentation {
                                { "update",           new MDocUpdater () },
                                { "update-ecma-xml",  new MDocUpdateEcmaXml () },
                                { "validate",         new MDocValidator () },
+                               { "index",            new MDocIndex () },
                        };
 
                        bool showVersion = false;
index d39aea29d6934cade3e5115f945f69be6a5957fb..1a9bfb0ed5efbefbdaf4558a36e39184402e0fd9 100644 (file)
@@ -4,6 +4,7 @@ Mono.Documentation/assembler.cs
 Mono.Documentation/dump.cs
 Mono.Documentation/ecmadoc.cs
 Mono.Documentation/exceptions.cs
+Mono.Documentation/index.cs
 Mono.Documentation/mdoc.cs
 Mono.Documentation/MdocFile.cs
 Mono.Documentation/monodocer.cs