* Makefile: Add a System.Core.dll reference; embed monodoc.xml as a
authorJonathan Pryor <jpryor@novell.com>
Fri, 26 Feb 2010 22:26:46 +0000 (22:26 -0000)
committerJonathan Pryor <jpryor@novell.com>
Fri, 26 Feb 2010 22:26:46 +0000 (22:26 -0000)
  resource.
* Monodoc/provider.cs: Add a
  RootTree.LoadTree(string,XmlDocument,IEnumerable<string>) method.
  This is so 'mdoc export-html-webdoc' doesn't need to rely on the
  system-wide .source files (allowing execution w/o changing/replacing
  the system-wide .source files) and so MonoDevelop can support
  multiple .source files spread throughout the system sanely.
* Monodoc/ecma-provider.cs: Always add the extension methods contained
  in the current EcmaHelpSource, instead of implicitly requiring that
  the current EcmaHelpSource also be contained within
  RootTree.HelpSources.  This simplifies logic in 'mdoc'.

svn path=/trunk/mcs/; revision=152587

mcs/tools/monodoc/ChangeLog
mcs/tools/monodoc/Makefile
mcs/tools/monodoc/Monodoc/ecma-provider.cs
mcs/tools/monodoc/Monodoc/provider.cs

index dd184fd88ed6c07a24a8127238baa9253a6e1166..8e613ac7d473ff63b04b0f8c97a1754320396054 100644 (file)
@@ -1,3 +1,18 @@
+2010-02-26  Jonathan Pryor  <jpryor@novell.com>
+
+       * Makefile: Add a System.Core.dll reference; embed monodoc.xml as a
+         resource.
+       * Monodoc/provider.cs: Add a
+         RootTree.LoadTree(string,XmlDocument,IEnumerable<string>) method.
+         This is so 'mdoc export-html-webdoc' doesn't need to rely on the
+         system-wide .source files (allowing execution w/o changing/replacing
+         the system-wide .source files) and so MonoDevelop can support
+         multiple .source files spread throughout the system sanely.
+       * Monodoc/ecma-provider.cs: Always add the extension methods contained
+         in the current EcmaHelpSource, instead of implicitly requiring that
+         the current EcmaHelpSource also be contained within
+         RootTree.HelpSources.  This simplifies logic in 'mdoc'.
+
 2010-01-13  Jonathan Pryor  <jpryor@novell.com>
 
        * Monodoc/provider.cs, Monodoc/ecma-provider.cs: Improve cache support
index 56a09ea44b9d34a7ce5fd9689da046e9f2198477..f605e3310b50afcb7fb30b2175c219ae9d21f5c7 100644 (file)
@@ -6,6 +6,7 @@ LIBRARY = monodoc.dll
 LIBRARY_PACKAGE = monodoc
 
 RESOURCE_FILES = \
+       ../../docs/monodoc.xml            \
        Resources/base.css                \
        Resources/ecmaspec-html-css.xsl   \
        Resources/ecmaspec-html.xsl       \
@@ -43,6 +44,7 @@ LIB_MCS_FLAGS = \
        /codepage:utf8                                                    \
        /nowarn:169,164,162,168,219                                       \
        /r:Commons.Xml.Relaxng                                            \
+       /resource:../../docs/monodoc.xml,monodoc.xml                      \
        /resource:Resources/base.css,base.css                             \
        /resource:Resources/ecmaspec-html-css.xsl,ecmaspec-html-css.xsl   \
        /resource:Resources/ecmaspec-html.xsl,ecmaspec-html.xsl           \
@@ -62,6 +64,7 @@ LIB_MCS_FLAGS = \
        /r:ICSharpCode.SharpZipLib                                        \
        /r:$(corlib)                                                      \
        /r:System.dll                                                     \
+       /r:System.Core.dll                                                \
        /r:System.Web                                                     \
        /r:System.Web.Services                                            \
        /r:System.Xml.dll
index c8eed7293b9400b0558513993bc562bace11d017..4c79062229eb022f6e3ee9b1a4c4b51d89c589ae 100644 (file)
@@ -1223,18 +1223,14 @@ public class EcmaHelpSource : HelpSource {
                        basetype = basetypedoc.SelectSingleNode("Type/Base/BaseTypeName");
                }
                ArrayList extensions = new ArrayList ();
+               AddExtensionMethodsFromHelpSource (extensions, this);
                foreach (HelpSource hs in RootTree.HelpSources) {
                        EcmaHelpSource es = hs as EcmaHelpSource;
                        if (es == null)
                                continue;
-                       Stream s = es.GetHelpStream ("ExtensionMethods.xml");
-                       if (s != null) {
-                               XmlDocument d = new XmlDocument ();
-                               d.Load (s);
-                               foreach (XmlNode n in d.SelectNodes ("/ExtensionMethods/*")) {
-                                       extensions.Add (n);
-                               }
-                       }
+                       if (es == this)
+                               continue;
+                       AddExtensionMethodsFromHelpSource (extensions, es);
                }
                XmlDocUtils.AddExtensionMethods (doc, extensions, delegate (string s) {
                                s = s.StartsWith ("T:") ? s : "T:" + s;
@@ -1311,6 +1307,18 @@ public class EcmaHelpSource : HelpSource {
                return BuildHtml (css_ecma_code, js_code, html); 
        }
 
+       void AddExtensionMethodsFromHelpSource (ArrayList extensions, EcmaHelpSource es)
+       {
+               Stream s = es.GetHelpStream ("ExtensionMethods.xml");
+               if (s != null) {
+                       XmlDocument d = new XmlDocument ();
+                       d.Load (s);
+                       foreach (XmlNode n in d.SelectNodes ("/ExtensionMethods/*")) {
+                               extensions.Add (n);
+                       }
+               }
+       }
+
        
        public override void RenderPreviewDocs (XmlNode newNode, XmlWriter writer)
        {
index b5cc05b3464eb4c194e61cb9ce8be5a63eded158..eb528c95a0492e9a3a1681c6a8820874f91c7979 100644 (file)
 //
 namespace Monodoc {
 using System;
+using System.Collections.Generic;
 using System.IO;
+using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
 using System.Collections;
 using System.Diagnostics;
 using System.Configuration;
+using System.Reflection;
 using System.Text.RegularExpressions;
 using System.Xml;
 using System.Xml.XPath;
@@ -869,17 +872,37 @@ public class RootTree : Tree {
                                basedir = d.SelectSingleNode ("config/path").Attributes ["docsPath"].Value;
                        }
                }
-               XmlDocument doc = new XmlDocument ();
 
-               RootTree root = new RootTree ();
-               root.basedir = basedir;
-               
                //
                // Load the layout
                //
+               XmlDocument doc = new XmlDocument ();
                string layout = Path.Combine (basedir, "monodoc.xml");
                doc.Load (layout);
-               XmlNodeList nodes = doc.SelectNodes ("/node/node");
+
+               return LoadTree (basedir, doc, 
+                               Directory.GetFiles (Path.Combine (basedir, "sources"))
+                               .Where (file => file.EndsWith (".source")));
+       }
+
+       public static RootTree LoadTree (string indexDir, XmlDocument docTree, IEnumerable<string> sourceFiles)
+       {
+               if (docTree == null) {
+                       docTree = new XmlDocument ();
+                       using (var defTree = typeof(RootTree).Assembly.GetManifestResourceStream ("monodoc.xml"))
+                               docTree.Load (defTree);
+               }
+
+               sourceFiles = sourceFiles ?? new string [0];
+
+               //
+               // Load the layout
+               //
+
+               RootTree root = new RootTree ();
+               root.basedir = indexDir;
+
+               XmlNodeList nodes = docTree.SelectNodes ("/node/node");
 
                root.name_to_node ["root"] = root;
                root.name_to_node ["libraries"] = root;
@@ -894,7 +917,8 @@ public class RootTree : Tree {
                //
                // Load the sources
                //
-               root.AddSource (Path.Combine (basedir, "sources"));
+               foreach (var sourceFile in sourceFiles)
+                       root.AddSourceFile (sourceFile);
                
                foreach (string path in UncompiledHelpSources) {
                        EcmaUncompiledHelpSource hs = new EcmaUncompiledHelpSource(path);
@@ -919,70 +943,75 @@ public class RootTree : Tree {
 
        public void AddSource (string sources_dir)
        {
-               Node third_party = LookupEntryPoint ("various") ?? this;
-
                string [] files = Directory.GetFiles (sources_dir);
 
                foreach (string file in files){
                        if (!file.EndsWith (".source"))
                                continue;
+                       AddSourceFile (file);
+               }
+       }
 
-                       XmlDocument doc = new XmlDocument ();
-                       try {
-                               doc.Load (file);
-                       } catch {
-                               Console.Error.WriteLine ("Error: Could not load source file {0}", file);
+       public void AddSourceFile (string sourceFile)
+       {
+               Node third_party = LookupEntryPoint ("various") ?? this;
+
+               XmlDocument doc = new XmlDocument ();
+               try {
+                       doc.Load (sourceFile);
+               }
+               catch {
+                       Console.Error.WriteLine ("Error: Could not load source file {0}", sourceFile);
+                       return;
+               }
+
+               XmlNodeList extra_nodes = doc.SelectNodes ("/monodoc/node");
+               if (extra_nodes.Count > 0)
+                       Populate (third_party, extra_nodes);
+
+               XmlNodeList sources = doc.SelectNodes ("/monodoc/source");
+               if (sources == null){
+                       Console.Error.WriteLine ("Error: No <source> section found in the {0} file", sourceFile);
+                       return;
+               }
+               foreach (XmlNode source in sources){
+                       XmlAttribute a = source.Attributes ["provider"];
+                       if (a == null){
+                               Console.Error.WriteLine ("Error: no provider in <source>");
                                continue;
                        }
+                       string provider = a.InnerText;
+                       a = source.Attributes ["basefile"];
+                       if (a == null){
+                               Console.Error.WriteLine ("Error: no basefile in <source>");
+                               continue;
+                       }
+                       string basefile = a.InnerText;
+                       a = source.Attributes ["path"];
+                       if (a == null){
+                               Console.Error.WriteLine ("Error: no path in <source>");
+                               continue;
+                       }
+                       string path = a.InnerText;
 
-                       XmlNodeList extra_nodes = doc.SelectNodes ("/monodoc/node");
-                       if (extra_nodes.Count > 0)
-                               Populate (third_party, extra_nodes);
-
-                       XmlNodeList sources = doc.SelectNodes ("/monodoc/source");
-                       if (sources == null){
-                               Console.Error.WriteLine ("Error: No <source> section found in the {0} file", file);
+                       string basefilepath = Path.Combine (Path.GetDirectoryName (sourceFile), basefile);
+                       HelpSource hs = GetHelpSource (provider, basefilepath);
+                       if (hs == null)
                                continue;
+                       hs.RootTree = this;
+                       help_sources.Add (hs);
+                       name_to_hs [path] = hs;
+
+                       Node parent = LookupEntryPoint (path);
+                       if (parent == null){
+                               Console.Error.WriteLine ("node `{0}' is not defined on the documentation map", path);
+                               parent = third_party;
                        }
-                       foreach (XmlNode source in sources){
-                               XmlAttribute a = source.Attributes ["provider"];
-                               if (a == null){
-                                       Console.Error.WriteLine ("Error: no provider in <source>");
-                                       continue;
-                               }
-                               string provider = a.InnerText;
-                               a = source.Attributes ["basefile"];
-                               if (a == null){
-                                       Console.Error.WriteLine ("Error: no basefile in <source>");
-                                       continue;
-                               }
-                               string basefile = a.InnerText;
-                               a = source.Attributes ["path"];
-                               if (a == null){
-                                       Console.Error.WriteLine ("Error: no path in <source>");
-                                       continue;
-                               }
-                               string path = a.InnerText;
-
-                               string basefilepath = Path.Combine (sources_dir, basefile);
-                               HelpSource hs = GetHelpSource (provider, basefilepath);
-                               if (hs == null)
-                                       continue;
-                               hs.RootTree = this;
-                               help_sources.Add (hs);
-                               name_to_hs [path] = hs;
-
-                               Node parent = LookupEntryPoint (path);
-                               if (parent == null){
-                                       Console.Error.WriteLine ("node `{0}' is not defined on the documentation map", path);
-                                       parent = third_party;
-                               }
 
-                               foreach (Node n in hs.Tree.Nodes){
-                                       parent.AddNode (n);
-                               }
-                               parent.Sort ();
+                       foreach (Node n in hs.Tree.Nodes){
+                               parent.AddNode (n);
                        }
+                       parent.Sort ();
                }
        }