Author: jonpryor
Date: 2007-05-17 16:27:11 -0400 (Thu, 17 May 2007)
New Revision: 77604

Modified:
   trunk/monodoc/tools/ChangeLog
   trunk/monodoc/tools/monodocer.cs
Log:
        * monodocer.cs: Add -importecmadoc flag, which will import
          documentation found within an ECMA documetation file (e.g. the
          CLILibraryTypes.xml from the ECMA-335 standard).
          WARNING: import is currently SLOW.


Modified: trunk/monodoc/tools/ChangeLog
===================================================================
--- trunk/monodoc/tools/ChangeLog       2007-05-17 19:59:30 UTC (rev 77603)
+++ trunk/monodoc/tools/ChangeLog       2007-05-17 20:27:11 UTC (rev 77604)
@@ -1,5 +1,12 @@
 2007-05-17  Jonathan Pryor  <[EMAIL PROTECTED]>
 
+       * monodocer.cs: Add -importecmadoc flag, which will import
+         documentation found within an ECMA documetation file (e.g. the
+         CLILibraryTypes.xml from the ECMA-335 standard).
+         WARNING: import is currently SLOW.
+
+2007-05-17  Jonathan Pryor  <[EMAIL PROTECTED]>
+
        * monodocer.cs: Refactor MakeDocNode() so that there's only one
          version, not three overloads, and use a (new) DocsNodeInfo type to
          pass information to the new MakeDocNode() method.  This doesn't

Modified: trunk/monodoc/tools/monodocer.cs
===================================================================
--- trunk/monodoc/tools/monodocer.cs    2007-05-17 19:59:30 UTC (rev 77603)
+++ trunk/monodoc/tools/monodocer.cs    2007-05-17 20:27:11 UTC (rev 77604)
@@ -33,6 +33,7 @@
 
        static string name;
        static XmlDocument slashdocs;
+       static XmlDocument ecmadocs;
 
        static string since;
 
@@ -77,6 +78,9 @@
                [Option("An XML documemntation {file} made by the /doc option 
of mcs/csc the contents of which will be imported.")]
                public string importslashdoc;
                
+               [Option("An ECMA or monodoc-generated XML documemntation {file} 
to import.")]
+               public string importecmadoc;
+
                [Option("Indent the XML files nicely.")]
                public bool pretty = false;
                
@@ -136,6 +140,17 @@
                                }
                        }
                        
+                       if (opts.importecmadoc != null) {
+                               try {
+                                       ecmadocs = new XmlDocument();
+                                       ecmadocs.Load(opts.importecmadoc);
+                               } catch (Exception e) {
+                                       Console.Error.WriteLine("Could not load 
XML file: " + e.Message);
+                                       Environment.ExitCode = 1;
+                                       return;
+                               }
+                       }
+                       
                        // PERFORM THE UPDATES
                        
                        if (opts.type != null)
@@ -1072,6 +1087,37 @@
                if (addremarks)
                        WriteElementInitialText(e, "remarks", "To be added.");
                
+               if (info.EcmaDocs != null) {
+                       foreach (string child in new string[]{"summary", 
"remarks", retnodename}) {
+                               if (child != null && 
info.EcmaDocs.SelectSingleNode (child) != null)
+                                       ClearElement (e, child);
+                       }
+                       foreach (XmlNode child in info.EcmaDocs.ChildNodes) {
+                               if (child.Name != "param" && child.Name != 
"typeparam" && child.Name != "altmember")
+                                       CopyNode (child, e);
+                       }
+
+                       foreach (XmlElement sa in 
info.EcmaDocs.SelectNodes("altmember")) {
+                               XmlElement a = (XmlElement) 
e.SelectSingleNode("[EMAIL PROTECTED]'" + sa.GetAttribute("cref") + "']");
+                               if (a == null) {
+                                       a = e.OwnerDocument.CreateElement 
("altmember");
+                                       a.SetAttribute ("cref", 
sa.GetAttribute("cref"));
+                                       e.AppendChild(a);
+                               }
+                       }
+
+                       foreach (XmlElement p in info.EcmaDocs.SelectNodes 
("param")) {
+                               XmlElement p2 = (XmlElement) 
e.SelectSingleNode("[EMAIL PROTECTED]'" + p.GetAttribute("name") + "']");
+                               if (p2 != null)
+                                       p2.InnerXml = p.InnerXml;
+                       }
+
+                       foreach (XmlElement p in 
info.EcmaDocs.SelectNodes("typeparam")) {
+                               XmlElement p2 = (XmlElement) 
e.SelectSingleNode("[EMAIL PROTECTED]'" + p.GetAttribute("name") + "']");
+                               if (p2 != null)
+                                       p2.InnerXml = p.InnerXml;
+                       }
+               }
                if (info.SlashDocs != null) {
                        XmlNode elem = info.SlashDocs;
                        if (elem != null) {
@@ -1516,6 +1562,7 @@
                                ReturnType = 
type.GetMethod("Invoke").ReturnType;
                        }
                        SetSlashDocs (type);
+                       SetEcmaDocs (type);
                }
 
                public DocsNodeInfo (XmlElement node, MemberInfo member)
@@ -1548,6 +1595,7 @@
                        if (member.DeclaringType != null && 
member.DeclaringType.IsEnum)
                                AddRemarks = false;
                        SetSlashDocs (member);
+                       SetEcmaDocs (member);
                }
 
                private void SetSlashDocs (MemberInfo member)
@@ -1557,6 +1605,48 @@
                                SlashDocs = slashdocs.SelectSingleNode 
("doc/members/[EMAIL PROTECTED]'" + slashdocsig + "']");
                }
 
+               private void SetEcmaDocs (MemberInfo member)
+               {
+                       if (ecmadocs == null)
+                               return;
+
+                       string xpath;
+
+                       if (member is Type) {
+                               xpath = "//[EMAIL PROTECTED]"" + 
GetDocTypeFullName ((Type) member)+ "\"]/Docs";
+                       }
+                       else {
+                               // Create e.g.:
+                               // //Members/[EMAIL 
PROTECTED]"CopyTo"]/Parameters[count(Parameter) = 2 
+                               //   and Parameter[1]/@Type="System.Array" and 
+                               //   Parameter[2]/@Type="System.Int64"]/../Docs'
+                               StringBuilder sb = new StringBuilder ();
+                               sb.Append ("//[EMAIL PROTECTED]"")
+                                       .Append (GetDocTypeFullName 
(member.DeclaringType))
+                                       .Append ("\"]");
+                               sb.Append ("/Members/[EMAIL PROTECTED]"");
+                               if (member is ConstructorInfo)
+                                       sb.Append (".ctor");
+                               else
+                                       sb.Append (GetMemberName (member));
+                               sb.Append ("\"]");
+                               if (member is MethodBase) {
+                                       sb.Append ("/Parameters[");
+                                       ParameterInfo[] parameters = 
((MethodBase) member).GetParameters ();
+                                       sb.Append ("count(Parameter) = 
").Append (parameters.Length);
+                                       for (int i = 0; i < parameters.Length; 
++i) {
+                                               sb.Append (" and 
Parameter[").Append (i+1).Append ("]/@Type=\"")
+                                                       .Append 
(GetDocTypeFullName (parameters [i].ParameterType))
+                                                       .Append ("\"");
+                                       }
+                                       sb.Append ("]/..");
+                               }
+                               sb.Append ("/Docs");
+                               xpath = sb.ToString ();
+                       }
+                       EcmaDocs = ecmadocs.SelectSingleNode (xpath);
+               }
+
                public Type ReturnType;
                public Type[] GenericParameters;
                public ParameterInfo[] Parameters;
@@ -1564,6 +1654,7 @@
                public XmlElement Node;
                public bool AddRemarks = true;
                public XmlNode SlashDocs;
+               public XmlNode EcmaDocs;
        }
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to