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
	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;
		root.Populate (root, nodes);

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

		//
		// Load the sources
		//
		foreach (var sourceFile in sourceFiles){
			root.AddSourceFile (sourceFile);
		}
		
		foreach (string path in UncompiledHelpSources) {
			EcmaUncompiledHelpSource hs = new EcmaUncompiledHelpSource(path);
			hs.RootTree = root;
			root.help_sources.Add (hs);
			string epath = "extra-help-source-" + hs.Name;
			Node hsn = root.CreateNode (hs.Name, "root:/" + epath);
			root.name_to_hs [epath] = hs;
			hsn.EnsureNodes ();
			foreach (Node n in hs.Tree.Nodes){
				hsn.AddNode (n);
			}
		}
		
		// Clean the tree
		PurgeNode(root);

		root.Sort ();

		return root;
	}
Esempio n. 3
0
	//
	// Loads the tree layout
	//
	public static RootTree LoadTree (string basedir)
	{
		XmlDocument doc = new XmlDocument ();

		RootTree root = new RootTree ();
		root.basedir = basedir;
		
		//
		// Load the layout
		//
		string layout = Path.Combine (basedir, "monodoc.xml");
		doc.Load (layout);
		XmlNodeList nodes = doc.SelectNodes ("/node/node");

		root.name_to_node ["root"] = root;
		root.Populate (root, nodes);

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

		//
		// Load the sources
		//
		string sources_dir = Path.Combine (basedir, "sources");
		
		string [] files = Directory.GetFiles (sources_dir);
		foreach (string file in files){
			if (!file.EndsWith (".source"))
				continue;

			doc = new XmlDocument ();
			try {
				doc.Load (file);
			} catch {
				Console.Error.WriteLine ("Error: Could not load source file {0}", file);
				continue;
			}

			XmlNodeList extra_nodes = doc.SelectNodes ("/monodoc/node");
			if (extra_nodes.Count > 0)
				root.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);
				continue;
			}
			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 = root;
				root.help_sources.Add (hs);
				root.name_to_hs [path] = hs;

				Node parent = root.LookupEntryPoint (path);
				if (parent == null){
					Console.Error.WriteLine ("node `{0}' is not defined on the documentation map", path);
					continue;
				}

				foreach (Node n in hs.Tree.Nodes){
					parent.AddNode (n);
				}
			}
		}
		
		foreach (string path in UncompiledHelpSources) {
			EcmaUncompiledHelpSource hs = new EcmaUncompiledHelpSource(path);
			root.help_sources.Add (hs);
			string epath = "extra-help-source-" + hs.Name;
			Node hsn = root.CreateNode (hs.Name, "root:/" + epath);
			root.name_to_hs [epath] = hs;
			hsn.EnsureNodes ();
			foreach (Node n in hs.Tree.Nodes){
				hsn.AddNode (n);
			}
		}
		
		// Clean the tree
		PurgeNode(root);

		return root;
	}