[monkeydoc] Let XHTML have its node sorted by .Element rather than .Caption
authorJérémie Laval <jeremie.laval@gmail.com>
Thu, 20 Dec 2012 14:14:45 +0000 (15:14 +0100)
committerJérémie Laval <jeremie.laval@gmail.com>
Thu, 20 Dec 2012 19:35:10 +0000 (20:35 +0100)
mcs/tools/monkeydoc/MonkeyDoc/HelpSource.cs
mcs/tools/monkeydoc/MonkeyDoc/Node.cs
mcs/tools/monkeydoc/MonkeyDoc/providers/xhtml-provider.cs

index 77da6f2e591b7af93e15f10fa4ec8bcbb7bd9c86..bd80b23882645befc429220811031530923c72c7 100644 (file)
@@ -10,6 +10,11 @@ using Lucene.Net.Index;
 
 namespace MonkeyDoc
 {
+       public enum SortType {
+               Caption,
+               Element
+       }
+
        //
        // The HelpSource class keeps track of the archived data, and its
        // tree
@@ -121,6 +126,12 @@ namespace MonkeyDoc
                                return "dummy:";
                        }
                }
+
+               public virtual SortType SortType {
+                       get {
+                               return SortType.Caption;
+                       }
+               }
        
                /// <summary>
                ///   Returns a stream from the packaged help source archive
index 1320c98b28369b975e02f55a7c7bd6ad47ee249a..61cf9a82f916d7467d20e84928e918ca417b8c9d 100644 (file)
@@ -16,6 +16,7 @@ namespace MonkeyDoc
                Node parent;
                List<Node> nodes;
                Dictionary<string, Node> childrenLookup;
+               bool elementSort;
                /* Address has three types of value, 
                 *   _ 0 is for no on-disk representation
                 *   _ >0 is a valid address that is loaded immediately
@@ -33,6 +34,7 @@ namespace MonkeyDoc
                        this.tree = tree;
                        this.caption = caption;
                        this.element = element;
+                       this.elementSort = tree.HelpSource != null && tree.HelpSource.SortType == SortType.Element;
                }
        
                /// <summary>
@@ -47,6 +49,7 @@ namespace MonkeyDoc
                {
                        this.address = address;
                        this.tree = tree;
+                       this.elementSort = tree.HelpSource != null && tree.HelpSource.SortType == SortType.Element;
                        if (address > 0)
                                LoadNode ();
                }
@@ -303,8 +306,8 @@ namespace MonkeyDoc
                        EnsureLoaded ();
                        other.EnsureLoaded ();
 
-                       var cap1 = caption;
-                       var cap2 = other.caption;
+                       var cap1 = elementSort ? element : caption;
+                       var cap2 = elementSort ? other.element : other.caption;
 
                        /* Some node (notably from ecmaspec) have number prepended to them
                         * which we need to sort better by padding them to the same number
index 9e7c0f22f7c07f06d605ff1743a17ea54ba7880f..279465ebbd6c4a02d103b07c46ca152a815ae5a9 100644 (file)
@@ -52,6 +52,12 @@ namespace MonkeyDoc.Providers
                                return XhtmlPrefix;
                        }
                }
+
+               public override SortType SortType {
+                       get {
+                               return SortType.Element;
+                       }
+               }
                
                public override DocumentType GetDocumentTypeForId (string id, out Dictionary<string, string> extraArgs)
                {