Esempio n. 1
0
        public static RootTree LoadTree(string indexDir, XmlDocument docTree, IEnumerable <string> sourceFiles)
        {
            if (docTree == null)
            {
                docTree = new XmlDocument();
                using  (Stream manifestResourceStream = typeof(RootTree).Assembly.GetManifestResourceStream("monodoc.xml")) {
                    docTree.Load(manifestResourceStream);
                }
            }

            sourceFiles = (sourceFiles ?? new string[0]);
            RootTree rootTree = new RootTree();

            rootTree.basedir = indexDir;
            XmlNodeList xml_node_list = docTree.SelectNodes("/node/node");

            rootTree.nameToNode["root"]      = rootTree.RootNode;
            rootTree.nameToNode["libraries"] = rootTree.RootNode;
            rootTree.Populate(rootTree.RootNode, xml_node_list);

            if (rootTree.LookupEntryPoint("various") == null)
            {
                Console.Error.WriteLine("No 'various' doc node! Check monodoc.xml!");
                Node rootNode = rootTree.RootNode;
            }

            foreach (string current in sourceFiles)
            {
                rootTree.AddSourceFile(current);
            }

            foreach (string path in uncompiledHelpSourcePaths)
            {
                var hs = new Providers.EcmaUncompiledHelpSource(path);
                hs.RootTree = rootTree;
                rootTree.helpSources.Add(hs);
                string epath = "extra-help-source-" + hs.Name;
                Node   hsn   = rootTree.RootNode.CreateNode(hs.Name, RootNamespace + epath);
                rootTree.nameToHelpSource [epath] = hs;
                hsn.EnsureNodes();
                foreach (Node n in hs.Tree.RootNode.ChildNodes)
                {
                    hsn.AddNode(n);
                }
            }

            RootTree.PurgeNode(rootTree.RootNode);
            rootTree.RootNode.Sort();
            return(rootTree);
        }
Esempio n. 2
0
 void Populate(Node parent, XmlNodeList xml_node_list)
 {
     foreach (XmlNode xmlNode in xml_node_list)
     {
         XmlAttribute e       = xmlNode.Attributes["parent"];
         Node         parent2 = null;
         if (e != null && this.nameToNode.TryGetValue(e.InnerText, out parent2))
         {
             xmlNode.Attributes.Remove(e);
             Populate(parent2, xmlNode.SelectNodes("."));
             continue;
         }
         e = xmlNode.Attributes["label"];
         if (e == null)
         {
             Console.Error.WriteLine("`label' attribute missing in <node>");
             continue;
         }
         string label = e.InnerText;
         e = xmlNode.Attributes["name"];
         if (e == null)
         {
             Console.Error.WriteLine("`name' attribute missing in <node>");
             continue;
         }
         string name         = e.InnerText;
         Node   orCreateNode = parent.GetOrCreateNode(label, RootNamespace + name);
         orCreateNode.EnsureNodes();
         this.nameToNode[name] = orCreateNode;
         XmlNodeList xmlNodeList = xmlNode.SelectNodes("./node");
         if (xmlNodeList != null)
         {
             this.Populate(orCreateNode, xmlNodeList);
         }
     }
 }