Esempio n. 1
0
        public override void PopulateTree(Tree tree)
        {
            string      fileId = tree.tree.HelpSource.PackFile(file);
            XmlDocument doc    = new XmlDocument();

            doc.Load(file);

            foreach (XmlElement addin in doc.SelectNodes("Addins/Addin"))
            {
                string addinId = addin.GetAttribute("fullId");
                Node   newNode = tree.CreateNode(addin.GetAttribute("name"), "addin:" + fileId + "#" + addinId);

                foreach (XmlElement node in addin.SelectNodes("ExtensionPoint"))
                {
                    string target = "extension-point:" + fileId + "#" + addinId + "#" + node.GetAttribute("path");
                    Node   newExt = newNode.CreateNode(node.GetAttribute("name"), target);

                    foreach (XmlElement en in node.SelectNodes("ExtensionNode"))
                    {
                        string nid   = en.GetAttribute("id");
                        string nname = en.GetAttribute("name");
                        newExt.CreateNode(nname, "extension-node:" + fileId + "#" + addinId + "#" + nid);
                    }
                }
            }
        }
Esempio n. 2
0
        public override void PopulateTree(Tree tree)
        {
            foreach (string TocFile in tocFiles)
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(TocFile);

                XmlNodeList nodeList            = doc.GetElementsByTagName("manpage");
                Node        nodeToAddChildrenTo = tree;

                foreach (XmlNode node in nodeList)
                {
                    XmlAttribute name = node.Attributes["name"];
                    XmlAttribute page = node.Attributes["page"];

                    if (name == null || page == null)
                    {
                        continue;
                    }

                    if (!File.Exists(page.Value))
                    {
                        continue;
                    }

                    string target = "man:" + name.Value;
                    nodeToAddChildrenTo.CreateNode(name.Value, target);

                    if (File.Exists(page.Value))
                    {
                        nodeToAddChildrenTo.tree.HelpSource.PackFile(page.Value, name.Value);
                    }
                }
            }
        }
Esempio n. 3
0
	//
	// Performs an XPath query on the document to extract the nodes for the various members
	// we also use some extra text to pluralize the caption
	//
	void PopulateMember (XmlDocument doc, string typename, Node node, string type, string caption)
	{
		string select = type;
		if (select == "Operator") select = "Method";
		
		XmlNodeList list1 = doc.SelectNodes (String.Format ("/Type/Members/Member[MemberType=\"{0}\"]", select));
		ArrayList list = new ArrayList();
		int i = 0;
		foreach (XmlElement n in list1) {
			n.SetAttribute("assembler_index", (i++).ToString());
			if (type == "Method" && GetMemberName(n).StartsWith("op_")) continue;
			if (type == "Operator" && !GetMemberName(n).StartsWith("op_")) continue;
			list.Add(n);
		}
		
		int count = list.Count;
		
		if (count == 0)
			return;

		Node nodes_node;
		string key = type.Substring (0, 1);
		nodes_node = node.CreateNode (caption, key);
		
		switch (type) {
			case "Event":
			case "Field":
				foreach (XmlElement n in list)
					nodes_node.CreateNode (GetMemberName (n), n.GetAttribute("assembler_index"));
				break;

			case "Constructor":
				foreach (XmlElement n in list)
					nodes_node.CreateNode (EcmaHelpSource.MakeSignature(n, typename), n.GetAttribute("assembler_index"));
				break;

			case "Property": // properties with indexers can be overloaded too
			case "Method":
			case "Operator":
				foreach (XmlElement n in list) {
					bool multiple = false;
					foreach (XmlNode nn in list) {
						if (n != nn && GetMemberName(n) == nn.Attributes ["MemberName"].InnerText) {
							multiple = true;
							break;
						}
					}
					
					string group, name, sig;
					if (type != "Operator") {
						name = GetMemberName(n);
						sig = EcmaHelpSource.MakeSignature(n, null);
						group = name;
					} else {
						EcmaHelpSource.MakeOperatorSignature(n, out name, out sig);
						group = name;
					}
					
					if (multiple) {
						nodes_node.LookupNode (group, group)
							.CreateNode (sig, n.GetAttribute("assembler_index"));
					} else {
						nodes_node.CreateNode (name, n.GetAttribute("assembler_index"));
					}
				}
				
				foreach (Node n in nodes_node.Nodes) {
					if (!n.IsLeaf)
						n.Sort ();
				}
				
				break;
				
			default:
				throw new InvalidOperationException();
		}
		
		nodes_node.Sort ();
	}
Esempio n. 4
0
        public void ParseUl(XmlNodeList items, Node monoTreeNode)
        {
            Node latestNodeAddition = monoTreeNode;

            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].LocalName == "li")
                {
                    string[] attribs = ParseLi(items[i]);

                    string filename = attribs[1];

                    if (i + 1 == items.Count || items[i + 1].LocalName == "ul")
                    {
                        Console.WriteLine(spaces + "+" + attribs[0] + ": " + filename);
                        // Put the node in the monodoc toc.

                        // FIXME: Change this to include the help-source ID?
                        // Not really sure what's going on here.....

                        // An empty node with subnodes
                        if (filename == "html/en/empty.html")
                        {
                            // emptysub.html indicates, that a subpage should be generated...
                            // For later use.

                            string exportstr = "<html><head><title>Monodoc</title></head><body><i>Currently Navigation is recommended through the treeview.</i><br />This chapter contains the following entries:<br /><br />";

                            if (items.Count > i + 1 && items[i + 1].HasChildNodes)
                            {
                                foreach (XmlNode node in items[i + 1].ChildNodes)
                                {
                                    if (node.LocalName == "li")
                                    {
                                        string[] list = ParseLi(node);
                                        if (list[1] == "html/en/empty.html")
                                        {
                                            exportstr += list[0] + "<br />";
                                        }
                                        else
                                        {
                                            exportstr += "<a href=\"/" + list[1] + "\">" + list[0] + "</a><br />";
                                        }
                                    }
                                }
                            }

                            exportstr += "</body></html>";
                            Random R  = new Random();
                            string rf = "mgrand_" + R.Next() + ".html";
                            using (FileStream fs = new  FileStream(rf, FileMode.OpenOrCreate, FileAccess.Write)){
                                StreamWriter streamWriter = new StreamWriter(fs);

                                streamWriter.WriteLine(exportstr);
                                streamWriter.Close();
                            }

                            filename = rf;                      //"html/en/emptysub.html";
                            tempfiles.Add(rf);
                        }

                        nodeToAddChildrenTo = latestNodeAddition.CreateNode(attribs[0].Trim(), "xhtml:" + filename);
                    }
                    else
                    {
                        Console.WriteLine(spaces + attribs[0] + ": " + filename);
                        // Put the node in the monodoc toc.
                        latestNodeAddition.CreateNode(attribs[0].Trim(), "xhtml:" + filename);
                    }
                    // Put the file in the archive.
                    if (File.Exists(filename))
                    {
                        if (packed_files [filename] == null)
                        {
                            packed_files [filename] = filename;
                            nodeToAddChildrenTo.tree.HelpSource.PackFile(filename, filename);
                        }
                    }

                    string fullpath = Path.Combine(Environment.CurrentDirectory, attribs[1]);
                    if (File.Exists(fullpath))
                    {
                        try {
                            XmlDocument newdoc = new XmlDocument();

                            newdoc.Load(fullpath);
                            IncludeAttribLinks(newdoc.GetElementsByTagName("a"), "href", filename);
                            IncludeAttribLinks(newdoc.GetElementsByTagName("img"), "src", filename);
                            IncludeAttribLinks(newdoc.GetElementsByTagName("link"), "href", filename);
                        } catch {
                            Console.WriteLine(spaces + "-- PARSE ERROR --");
                            throw;
                        }
                    }
                }

                if (items[i].LocalName == "ul")
                {
                    spaces += "      ";
                    ParseUl(items[i].ChildNodes, nodeToAddChildrenTo);
                    nodeToAddChildrenTo = latestNodeAddition;
                    spaces = spaces.Substring(6);
                }
            }
        }