Hi,

I made a tiny monodocer patch that updates "name" attribute in paramref
descendants in Docs element, in sync with the corresponding
"name" attribute of the param element when it is being updated.

I could not find where (well, whether) monodocer updates parameter
names when there are two or more parameters. Does the updating happen
in such cases?

If it looks good, I'll commit this patch later.

Atsushi Eno

Index: monodocer.cs
===================================================================
--- monodocer.cs	(revision 47922)
+++ monodocer.cs	(working copy)
@@ -848,13 +848,13 @@
 			if (parameters.Length == 1) {
 				int c = e.SelectNodes("param").Count;
 				if (c == 1) {
-					((XmlElement)e.SelectSingleNode("param")).SetAttribute("name", parameters[0].Name);
+					UpdateParameterName (e, (XmlElement) e.SelectSingleNode("param"), parameters[0].Name);
 				} else if (c > 1) {
 					foreach (XmlElement paramnode in e.SelectNodes("param")) {
 						if (paramnode.InnerText.StartsWith("To be added"))
 							paramnode.ParentNode.RemoveChild(paramnode);
 						else
-							paramnode.SetAttribute("name", parameters[0].Name);
+							UpdateParameterName (e, paramnode, parameters[0].Name);
 					}
 				}
 			}
@@ -966,7 +966,18 @@
 		
 		NormalizeWhitespace(e);
 	}
-	
+
+	private static void UpdateParameterName (XmlElement docs, XmlElement pe, string newName)
+	{
+		string existingName = pe.GetAttribute ("name");
+		pe.SetAttribute ("name", newName);
+		if (existingName == newName)
+			return;
+		foreach (XmlElement paramref in docs.SelectNodes (".//paramref"))
+			if (paramref.GetAttribute ("name").Trim () == existingName)
+				paramref.SetAttribute ("name", newName);
+	}
+
 	private static void NormalizeWhitespace(XmlElement e) {
 		// Remove all text and whitespace nodes from the element so it
 		// is outputted with nice indentation and no blank lines.
_______________________________________________
Mono-docs-list maillist  -  Mono-docs-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-docs-list

Reply via email to