[Mono-docs-list] Patch for overloads in monodoc

Ben Maurer bmaurer@users.sourceforge.net
Sun, 24 Aug 2003 16:21:51 -0400


--=-xvKHqX+oNoEirx9sfnnq
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello Miguel,

I got the patch for friendly looking overloads working, it is attached.
Can you please review it? To have it take affect, you need to:

     1. Apply the patch
     2. Rebuild all ECMA docs
     3. Rebuild your index

You should then get a display like
http://users.hawken.edu/05mauben/Screenshot-mdoc-overload.png.

Some (good) side effects of this:
     1. In the index, only one of each method is displayed
     2. we can do <see href="M:System.Array.Copy" />, and we get the
        overloads page.
     3. mod M:System.Array.Copy gives us the overloads page.

-- Ben

--=-xvKHqX+oNoEirx9sfnnq
Content-Disposition: attachment; filename=mdoc-friendly-overloads.patch
Content-Type: text/x-patch; name=mdoc-friendly-overloads.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: ecma-provider.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/ecma-provider.cs,v
retrieving revision 1.62
diff -u -r1.62 ecma-provider.cs
--- ecma-provider.cs	21 Aug 2003 03:14:13 -0000	1.62
+++ ecma-provider.cs	24 Aug 2003 20:26:49 -0000
@@ -380,46 +380,66 @@
 			nodes_node = node.CreateNode (text, key);
 		else
 			nodes_node = node.CreateNode (plural_text, key);
-
-		NodeIndex [] node_array = new NodeIndex [count];
+		
 		int i = 0;
-		foreach (XmlNode n in list)
-			node_array [i] = new NodeIndex (n, i++);
-			
-		Array.Sort (node_array, NodeComparer);
 
-		foreach (NodeIndex ni in node_array){
-			string signature;
-
-			switch (text){
+		
+		switch (text) {
 			case "Event":
 			case "Property":
 			case "Field":
-				signature = GetMemberName (ni.node);
+				foreach (XmlNode n in list)
+					nodes_node.CreateNode (GetMemberName (n), (i++).ToString ());
 				break;
 
 			case "Constructor":
-				signature = EcmaHelpSource.MakeSignature(ni.node, typename);
+				foreach (XmlNode n in list)
+					nodes_node.CreateNode (EcmaHelpSource.MakeSignature(n, typename), (i++).ToString ());
 				break;
 
 			case "Method":
-				signature = EcmaHelpSource.MakeSignature(ni.node, null);
+				foreach (XmlNode n in list) {
+					bool multiple = false;
+					foreach (XmlNode nn in list) {
+						if (n != nn && n.Attributes ["MemberName"].InnerText == nn.Attributes ["MemberName"].InnerText) {
+							multiple = true;
+							break;
+						}
+					}
+					
+					if (multiple) {
+						nodes_node.LookupNode (n.Attributes ["MemberName"].InnerText, n.Attributes ["MemberName"].InnerText)
+							.CreateNode (EcmaHelpSource.MakeSignature(n, null), (i++).ToString ());
+					} else {
+						nodes_node.CreateNode (n.Attributes ["MemberName"].InnerText, (i++).ToString ());
+					}
+				}
+				
+				foreach (Node n in nodes_node.Nodes) {
+					if (!n.IsLeaf)
+						n.Sort ();
+				}
+				
 				break;
 				
 			default:
-				XmlNode signode = ni.node.SelectSingleNode ("MemberSignature[@Language='C#']");
-			
-				if (signode == null)
-					signature = GetMemberName (ni.node);
-				else
-					signature = signode.Attributes ["Value"].InnerText;
+				foreach (XmlNode n in list)
+				{
+					string sig;
+					XmlNode signode = n.SelectSingleNode ("MemberSignature[@Language='C#']");
+				
+					if (signode == null)
+						sig = GetMemberName (n);
+					else
+						sig = signode.Attributes ["Value"].InnerText;
+					
+					nodes_node.CreateNode (sig, (i++).ToString ());
+					
+				}
 				break;
-			}
-			
-			//signature = CleanSignature (ni.node, signature);
-
-			nodes_node.CreateNode (signature, ni.index.ToString ());
 		}
+		
+		nodes_node.Sort ();
 	}
 
 }
@@ -697,12 +717,30 @@
 		}
 		
 		string [] nodes = rest.Split (new char [] {'/'});
-		if (nodes.Length == 1) {
-			args.AddParam("show", "", "members");
-			args.AddParam("index", "", "all");
-		} else {
-			args.AddParam("show", "", "member");
-			args.AddParam("index", "", nodes [1]);
+		
+		switch (nodes.Length) {
+			case 1:
+				args.AddParam("show", "", "members");
+				args.AddParam("index", "", "all");
+				break;
+			case 2:
+				// Could either be a single member, or an overload thingy
+				try {
+					int dummy = int.Parse (nodes [1]); // is it an int
+					
+					args.AddParam("show", "", "member");
+					args.AddParam("index", "", nodes [1]);
+				} catch {
+					args.AddParam("show", "", "overloads");
+					args.AddParam("index", "", nodes [1]);
+				}
+				break;
+			case 3:
+				args.AddParam("show", "", "member");
+				args.AddParam("index", "", nodes [2]);
+				break;
+			default:
+				return "What the hell is this URL " + url;
 		}
 
 		switch (nodes [0]){
Index: mono-ecma.xsl
===================================================================
RCS file: /cvs/public/monodoc/browser/mono-ecma.xsl,v
retrieving revision 1.18
diff -u -r1.18 mono-ecma.xsl
--- mono-ecma.xsl	21 Aug 2003 03:14:13 -0000	1.18
+++ mono-ecma.xsl	24 Aug 2003 20:26:49 -0000
@@ -59,6 +59,10 @@
 					<xsl:when test="$show='namespace'">
 						<xsl:value-of select="$namespace"/> Namespace
 					</xsl:when>
+					
+					<xsl:when test="$show='overloads'">
+						<xsl:value-of select="$index"/> Overloads
+					</xsl:when>
 
 				</xsl:choose>
 			</h3>
@@ -425,7 +429,35 @@
 			</xsl:if>
 
 		</xsl:when>
+		
+		<xsl:when test="$show='overloads'">
+				<p>
+					The overloads of <xsl:value-of select="$index"/>
+					are listed below.  For a list of all members, see the <a>
+					<xsl:attribute name="href">T:<xsl:value-of select="@FullName"/>/*</xsl:attribute>
+					<xsl:value-of select="@Name"/> Members</a> list.
+				</p>
+				
+				<!-- TODO: can we make this actually test if there are any overloads
+				<xsl:if test="Base/BaseTypeName">
+					<p>
+						See Also: <a>
+					<xsl:attribute name="href">T:<xsl:value-of select="Base/BaseTypeName"/>/*</xsl:attribute>
+					Inherited members</a> from <xsl:value-of select="Base/BaseTypeName"/>
+					</p>
+				</xsl:if>
+				 -->
+				 
+				<xsl:call-template name="ListMembers">
+					<xsl:with-param name="listmembertype" select="'Method'"/>
+					<xsl:with-param name="showprotected" select="false()"/>
+				</xsl:call-template>
 
+				<xsl:call-template name="ListMembers">
+					<xsl:with-param name="listmembertype" select="'Method'"/>
+					<xsl:with-param name="showprotected" select="true()"/>
+				</xsl:call-template>
+		</xsl:when>
 		<!-- MEMBER DETAILS -->
 		<xsl:when test="$show='member'">
 			<xsl:variable name="Type" select="."/>
@@ -1119,7 +1151,7 @@
 
 		<!-- Get all members in this type that are of listmembertype and are either
 			protected or not protected according to showprotected. -->
-		<xsl:variable name="MEMBERS" select="Members/Member[MemberType=$listmembertype][$showprotected=contains(MemberSignature[@Language='C#']/@Value,'protected')]"/>
+		<xsl:variable name="MEMBERS" select="Members/Member[MemberType=$listmembertype and (not($show='overloads') or @MemberName=$index) ][$showprotected=contains(MemberSignature[@Language='C#']/@Value,'protected')]"/>
 
 		<!-- if there aren't any, skip this -->
 		<xsl:if test="count($MEMBERS)">

--=-xvKHqX+oNoEirx9sfnnq--