예제 #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);
        }
예제 #2
0
        public bool AddSourceFile(string sourceFile)
        {
            if (this.loadedSourceFiles.Contains(sourceFile))
            {
                return(false);
            }

            Node        node        = this.LookupEntryPoint("various") ?? base.RootNode;
            XmlDocument xmlDocument = new XmlDocument();

            try {
                xmlDocument.Load(sourceFile);
            } catch {
                bool result = false;
                return(result);
            }

            XmlNodeList extra_nodes = xmlDocument.SelectNodes("/monodoc/node");

            if (extra_nodes.Count > 0)
            {
                this.Populate(node, extra_nodes);
            }

            XmlNodeList sources = xmlDocument.SelectNodes("/monodoc/source");

            if (sources == null)
            {
                Console.Error.WriteLine("Error: No <source> section found in the {0} file", sourceFile);
                return(false);
            }

            loadedSourceFiles.Add(sourceFile);
            foreach (XmlNode xmlNode in sources)
            {
                XmlAttribute a = xmlNode.Attributes["provider"];
                if (a == null)
                {
                    Console.Error.WriteLine("Error: no provider in <source>");
                    continue;
                }
                string provider = a.InnerText;
                a = xmlNode.Attributes["basefile"];
                if (a == null)
                {
                    Console.Error.WriteLine("Error: no basefile in <source>");
                    continue;
                }
                string basefile = a.InnerText;
                a = xmlNode.Attributes["path"];
                if (a == null)
                {
                    Console.Error.WriteLine("Error: no path in <source>");
                    continue;
                }
                string     path         = a.InnerText;
                string     basefilepath = Path.Combine(Path.GetDirectoryName(sourceFile), basefile);
                HelpSource helpSource   = RootTree.GetHelpSource(provider, basefilepath);
                if (helpSource != null)
                {
                    helpSource.RootTree = this;
                    this.helpSources.Add(helpSource);
                    this.nameToHelpSource[path] = helpSource;
                    Node node2 = this.LookupEntryPoint(path);
                    if (node2 == null)
                    {
                        Console.Error.WriteLine("node `{0}' is not defined on the documentation map", path);
                        node2 = node;
                    }
                    foreach (Node current in helpSource.Tree.RootNode.ChildNodes)
                    {
                        node2.AddNode(current);
                    }
                    node2.Sort();
                }
            }
            return(true);
        }