Author: mkestner
Date: 2005-05-23 13:35:54 -0400 (Mon, 23 May 2005)
New Revision: 44914

Modified:
   trunk/monodoc/ChangeLog
   trunk/monodoc/configure.in
   trunk/monodoc/tools/ChangeLog
   trunk/monodoc/tools/monodocer.cs
Log:

2005-05-23  Mike Kestner  <[EMAIL PROTECTED]>

        * configure.in : bump svn version.

2005-05-23  Mike Kestner <[EMAIL PROTECTED]>

        * monodocer.cs : add multiple assembly updating. 


Modified: trunk/monodoc/ChangeLog
===================================================================
--- trunk/monodoc/ChangeLog     2005-05-23 17:17:43 UTC (rev 44913)
+++ trunk/monodoc/ChangeLog     2005-05-23 17:35:54 UTC (rev 44914)
@@ -1,3 +1,7 @@
+2005-05-23  Mike Kestner  <[EMAIL PROTECTED]>
+
+       * configure.in : bump svn version.
+
 2005-04-23  Mike Kestner  <[EMAIL PROTECTED]>
 
        * configure.in : remove gtk-sharp tests. remove gettext.

Modified: trunk/monodoc/configure.in
===================================================================
--- trunk/monodoc/configure.in  2005-05-23 17:17:43 UTC (rev 44913)
+++ trunk/monodoc/configure.in  2005-05-23 17:35:54 UTC (rev 44914)
@@ -1,6 +1,6 @@
 AC_INIT(README)
 AC_CANONICAL_SYSTEM
-AM_INIT_AUTOMAKE(monodoc, 1.0.6)
+AM_INIT_AUTOMAKE(monodoc, 1.0.6.99)
 AM_MAINTAINER_MODE
 
 AC_PROG_INSTALL

Modified: trunk/monodoc/tools/ChangeLog
===================================================================
--- trunk/monodoc/tools/ChangeLog       2005-05-23 17:17:43 UTC (rev 44913)
+++ trunk/monodoc/tools/ChangeLog       2005-05-23 17:35:54 UTC (rev 44914)
@@ -1,3 +1,7 @@
+2005-05-23  Mike Kestner <[EMAIL PROTECTED]>
+
+       * monodocer.cs : add multiple assembly updating. 
+
 2005-05-09  Joshua Tauberer <[EMAIL PROTECTED]>
 
        * Thanks for pushing me to use a ChangeLog.

Modified: trunk/monodoc/tools/monodocer.cs
===================================================================
--- trunk/monodoc/tools/monodocer.cs    2005-05-23 17:17:43 UTC (rev 44913)
+++ trunk/monodoc/tools/monodocer.cs    2005-05-23 17:35:54 UTC (rev 44914)
@@ -19,7 +19,7 @@
 public class Stub {
        
        static string srcPath;
-       static Assembly assembly;
+       static Assembly[] assemblies;
        
        static bool nooverrides = true, delete = false, ignoremembers = false;
        
@@ -32,8 +32,8 @@
                [Option("When updating documentation, write the updated files 
to this {path}.")]
                public string updateto = null;
 
-               [Option("The assembly to document.  Specify a {file} path or 
the name of a GAC'd assembly.")]
-               public string assembly = null;
+               [Option(-1, "The assembly to document.  Specify a {file} path 
or the name of a GAC'd assembly.")]
+               public string[] assembly = null;
 
                [Option("Document only the {type name}d by this argument.")]
                public string type = null;
@@ -82,19 +82,10 @@
                        if (opts.assembly == null)
                                throw new InvalidOperationException("The 
assembly option is required.");
                                
-                       try {
-                               assembly = Assembly.LoadFile(opts.assembly);
-                       } catch (System.IO.FileNotFoundException e) { }
-
-                       if (assembly == null) {
-                               try {
-                                       assembly = 
Assembly.LoadWithPartialName(opts.assembly);
-                               } catch (Exception e) { }
-                       }
+                       assemblies = new Assembly [opts.assembly.Length];
+                       for (int i = 0; i < opts.assembly.Length; i++)
+                               assemblies [i] = LoadAssembly (opts.assembly 
[i]);
                        
-                       if (assembly == null)
-                               throw new InvalidOperationException("Assembly 
not found.");
-                       
                        // PERFORM THE UPDATES
                        
                        if (opts.type != null)
@@ -102,7 +93,7 @@
                        else if ([EMAIL PROTECTED] != null)
                                DoUpdateNS([EMAIL PROTECTED], opts.path + "/" + 
[EMAIL PROTECTED], opts.updateto == null ? opts.path + "/" + [EMAIL PROTECTED] 
: opts.updateto + "/" + [EMAIL PROTECTED]);
                        else
-                               DoUpdateAssembly(opts.path, opts.updateto == 
null ? opts.path : opts.updateto);
+                               DoUpdateAssemblies(opts.path, opts.updateto == 
null ? opts.path : opts.updateto);
                
                } catch (InvalidOperationException error) {
                        Console.Error.WriteLine(error.Message);
@@ -119,6 +110,25 @@
                Console.Error.WriteLine("Members Added: {0}, Members Deleted: 
{1}", additions, deletions);
        }
        
+       private static Assembly LoadAssembly (string name)
+       {
+               Assembly assembly = null;
+               try {
+                       assembly = Assembly.LoadFile (name);
+               } catch (System.IO.FileNotFoundException e) { }
+
+               if (assembly == null) {
+                       try {
+                               assembly = Assembly.LoadWithPartialName (name);
+                       } catch (Exception e) { }
+               }
+                       
+               if (assembly == null)
+                       throw new InvalidOperationException("Assembly " + name 
+ " not found.");
+
+               return assembly;
+       }
+
        private static void WriteXml(XmlElement element, System.IO.TextWriter 
output) {
                XmlTextWriter writer = new XmlTextWriter(output);
                writer.Formatting = Formatting.Indented;
@@ -134,13 +144,12 @@
                XmlElement index_root = index.CreateElement("Overview");
                index.AppendChild(index_root);
 
-               XmlElement index_assembly = index.CreateElement("Assembly");
-               if (assembly == null)
+               if (assemblies.Length == 0)
                        throw new Exception ("No assembly");
-               index_assembly.InnerText = assembly.GetName().Name;
-               index_assembly.SetAttribute("Version", 
assembly.GetName().Version.ToString());
-               index_root.AppendChild(index_assembly);
 
+               XmlElement index_assemblies = index.CreateElement("Assemblies");
+               index_root.AppendChild(index_assemblies);
+
                XmlElement index_remarks = index.CreateElement("Remarks");
                index_remarks.InnerText = "To be added.";
                index_root.AppendChild(index_remarks);
@@ -152,8 +161,6 @@
                XmlElement index_types = index.CreateElement("Types");
                index_root.AppendChild(index_types);
                
-               MakeAttributes(index_root, assembly, true);
-               
                return index;
        }
        
@@ -183,7 +190,12 @@
        }
        
        public static void DoUpdateType(string basepath, string typename, 
string dest) {
-               Type type = assembly.GetType(typename, false);
+               Type type = null;
+               foreach (Assembly assembly in assemblies) {
+                       type = assembly.GetType(typename, false);
+                       if (type != null)
+                               break;
+               }
                if (type == null) throw new InvalidOperationException("Type not 
found: " + typename);
                if (type.Namespace == null) throw new 
InvalidOperationException("Types in the root namespace cannot be documented: " 
+ typename);
                string typename2 = type.FullName.Substring(type.Namespace == "" 
? 0 : type.Namespace.Length+1);
@@ -209,6 +221,7 @@
        
        public static void DoUpdateNS(string ns, string nspath, string outpath) 
{
                Hashtable seenTypes = new Hashtable();
+               Assembly assembly = assemblies [0];
                
                foreach (System.IO.FileInfo file in new 
System.IO.DirectoryInfo(nspath).GetFiles("*.xml")) {
                        XmlDocument basefile = new XmlDocument();
@@ -257,7 +270,17 @@
                return type.FullName.Substring(start);
        }
        
-       public static void DoUpdateAssembly(string source, string dest) {
+       private static void AddIndexAssembly (Assembly assembly, XmlElement 
parent)
+       {
+               XmlElement index_assembly = 
parent.OwnerDocument.CreateElement("Assembly");
+               index_assembly.SetAttribute("Name", assembly.GetName().Name);
+               index_assembly.SetAttribute("Version", 
assembly.GetName().Version.ToString());
+               MakeAttributes(index_assembly, assembly, true);
+               parent.AppendChild(index_assembly);
+       }
+
+       private static void DoUpdateAssemblies (string source, string dest) 
+       {
                string indexfile = dest + "/index.xml";
                XmlDocument index;
                if (new System.IO.FileInfo(indexfile).Exists) {
@@ -267,11 +290,27 @@
                        index = CreateIndexStub();
                }
                XmlElement index_types = 
(XmlElement)index.SelectSingleNode("Overview/Types");
+               XmlElement index_assemblies = 
(XmlElement)index.SelectSingleNode("Overview/Assemblies");
+               index_assemblies.RemoveAll ();
                
-               MakeAttributes(index.DocumentElement, assembly, true);
-               
                Hashtable goodfiles = new Hashtable();
+
+               foreach (Assembly assm in assemblies) {
+                       AddIndexAssembly (assm, index_assemblies);
+                       DoUpdateAssembly (assm, index_types, source, dest, 
goodfiles);
+               }
                
+               CleanupFiles (dest, goodfiles);
+               CleanupIndexTypes (index_types, goodfiles);
+
+               using (System.IO.TextWriter writer
+                       = new System.IO.StreamWriter(new 
System.IO.FileStream(indexfile, System.IO.FileMode.Create)))
+                       WriteXml(index.DocumentElement, writer);
+       
+       }
+               
+       private static void DoUpdateAssembly (Assembly assembly, XmlElement 
index_types, string source, string dest, Hashtable goodfiles) 
+       {
                foreach (Type type in assembly.GetTypes()) {
                        if (type.Namespace == null) continue;
                        
@@ -313,17 +352,17 @@
                        // Add namespace and type nodes into the index file as 
needed
                        XmlElement nsnode = 
(XmlElement)index_types.SelectSingleNode("[EMAIL PROTECTED]'" + type.Namespace 
+ "']");
                        if (nsnode == null) {
-                               nsnode = index.CreateElement("Namespace");
+                               nsnode = 
index_types.OwnerDocument.CreateElement("Namespace");
                                nsnode.SetAttribute("Name", type.Namespace);
                                index_types.AppendChild(nsnode);
                        }
                        XmlElement typenode = 
(XmlElement)nsnode.SelectSingleNode("[EMAIL PROTECTED]'" + typename + "']");
                        if (typenode == null) {
-                               typenode = index.CreateElement("Type");
+                               typenode = 
index_types.OwnerDocument.CreateElement("Type");
                                typenode.SetAttribute("Name", typename);
                                nsnode.AppendChild(typenode);
                        }
-                       
+                               
                        // Ensure the namespace index file exists
                        if (!new System.IO.FileInfo(dest + "/" + type.Namespace 
+ ".xml").Exists) {
                                Console.Error.WriteLine("New Namespace File: " 
+ type.Namespace);
@@ -333,7 +372,10 @@
                        // mark the file as corresponding to a type
                        goodfiles[type.Namespace + "/" + typename + ".xml"] = 
goodfiles;
                }
-               
+       }
+
+       private static void CleanupFiles (string dest, Hashtable goodfiles)
+       {
                // Look for files that no longer correspond to types
                foreach (System.IO.DirectoryInfo nsdir in new 
System.IO.DirectoryInfo(dest).GetDirectories("*")) {
                        foreach (System.IO.FileInfo typefile in 
nsdir.GetFiles("*.xml")) {
@@ -345,19 +387,18 @@
                                }
                        }
                }
+       }
                
+       private static void CleanupIndexTypes (XmlElement index_types, 
Hashtable goodfiles)
+       {
                // Look for type nodes that no longer correspond to types
                foreach (XmlElement typenode in 
index_types.SelectNodes("Namespace/Type")) {
                        string fulltypename = 
((XmlElement)typenode.ParentNode).GetAttribute("Name") + "/" + 
typenode.GetAttribute("Name") + ".xml";
                        if (!goodfiles.ContainsKey(fulltypename))
                                typenode.ParentNode.RemoveChild(typenode);
                }
+       }
                
-               using (System.IO.TextWriter writer
-                       = new System.IO.StreamWriter(new 
System.IO.FileStream(indexfile, System.IO.FileMode.Create)))
-                       WriteXml(index.DocumentElement, writer);
-       }
-       
        public static void DoUpdateType2(XmlDocument basefile, Type type, 
string output) {
                Console.Error.WriteLine("Updating: " + type.FullName);
                
@@ -538,10 +579,6 @@
        
        // CREATE A STUB DOCUMENTATION FILE     
 
-       public static XmlElement StubType(string type) {
-               return StubType(assembly.GetType(type, true));
-       }
-       
        public static XmlElement StubType(Type type) {
                string typesig = MakeTypeSignature(type);
                if (typesig == null) return null; // not publicly visible

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

Reply via email to