Ejemplo n.º 1
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);
			}
		}
	}
Ejemplo n.º 2
0
	public override void PopulateTree (Tree tree)
	{
		XPathNavigator n = new XPathDocument (Path.Combine (basedir, "toc.xml")).CreateNavigator ();
		n.MoveToRoot ();
		n.MoveToFirstChild ();
		PopulateNode (n.SelectChildren ("node", ""), tree);
	}
Ejemplo n.º 3
0
		void TestTreeLoading (string treeFileName, int expectedVersion, int expectedNodeCount)
		{
			var filePath = Path.Combine (BaseDir, "trees", treeFileName);
			var tree = new Tree (null, filePath);
			Assert.AreEqual (expectedVersion, tree.VersionNumber);
			Assert.IsNotNull (tree.RootNode);
			Assert.AreEqual (expectedNodeCount, tree.RootNode.ChildNodes.Count);
		}
Ejemplo n.º 4
0
	public override void PopulateTree (Tree tree)
	{
		Node top = tree.LookupNode ("Directory at: " + basedir, "simple:");
		
		foreach (string dir in Directory.GetDirectories (basedir)){
			string url = Path.GetFileName (dir);
			Node n = top.LookupNode ("Dir: " + url, url);
			PopulateDir (n, dir);
		}
	}
Ejemplo n.º 5
0
	static int Main (string [] args)
	{
		int argc = args.Length;
		Tree t = null;
		
		for (int i = 0; i < argc; i++){
			string arg = args [i];
			
			switch (arg){
				
			default:
				if (t == null)
					t = new Tree (null, arg);
				break;
			}
		}

		if (t != null)
			Node.PrintTree (t);

		return 0;
	}
Ejemplo n.º 6
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);
					}
				}
			}
		}
Ejemplo n.º 7
0
Archivo: dump.cs Proyecto: nobled/mono
		public override void Run (IEnumerable<string> args)
		{
			var validFormats = RootTree.GetSupportedFormats ();
			string cur_format = "";
			var formats = new Dictionary<string, List<string>> ();
			var options = new OptionSet () {
				{ "f|format=",
					"The documentation {FORMAT} used in FILES.  " + 
						"Valid formats include:\n  " +
						string.Join ("\n  ", validFormats) + "\n" +
						"If not specified, no HelpSource is used.  This may " +
						"impact the PublicUrls displayed for nodes.",
					v => {
						if (Array.IndexOf (validFormats, v) < 0)
							Error ("Invalid documentation format: {0}.", v);
						cur_format = v;
					} },
				{ "<>", v => AddFormat (formats, cur_format, v) },
			};
			List<string> files = Parse (options, args, "dump-tree", 
					"[OPTIONS]+ FILES",
					"Print out the nodes within the assembled .tree FILES,\n" + 
					"as produced by 'mdoc assemble'.");
			if (files == null)
				return;

			foreach (string format in formats.Keys) {
				foreach (string file in formats [format]) {
					HelpSource hs = format == ""
						? null
						: RootTree.GetHelpSource (format, file.Replace (".tree", ""));
					Tree t = new Tree (hs, file);
					TreeDumper.PrintTree (t.RootNode);
				}
			}
		}
Ejemplo n.º 8
0
	public HelpSource() {
		Tree = new Tree (this, "Blah", "Blah");
		source_id = id++;
	}
Ejemplo n.º 9
0
	/// <summary>
	///    Creates a node from an on-disk representation
	/// </summary>
	Node (Node parent, int address)
	{
		this.parent = parent;
		position = address;
		this.tree = parent.tree;
		if (address > 0)
			LoadNode ();
	}
Ejemplo n.º 10
0
	public HelpSource (string base_filename, bool create)
	{
		this.name = Path.GetFileName (base_filename);
		tree_filename = base_filename + ".tree";
		zip_filename = base_filename + ".zip";
		base_dir = XmlDocUtils.GetCacheDirectory (base_filename);
		if (UseWebdocCache && !create && Directory.Exists (base_dir)) {
			nozip = true;
		}

		if (create)
			SetupForOutput ();
		else 
			Tree = new Tree (this, tree_filename);

		source_id = id++;
		try {
			FileInfo fi = new FileInfo (zip_filename);
			zipFileWriteTime = fi.LastWriteTime;
		} catch {
			zipFileWriteTime = DateTime.Now;
		}
	}
Ejemplo n.º 11
0
	public HelpSource (string base_filename, bool create)
	{
		this.name = Path.GetFileName (base_filename);
		tree_filename = base_filename + ".tree";
		zip_filename = base_filename + ".zip";

		if (create)
			SetupForOutput ();
		else 
			Tree = new Tree (this, tree_filename);

		source_id = id++;
		try {
			FileInfo fi = new FileInfo (zip_filename);
			zipFileWriteTime = fi.LastWriteTime;
		} catch {
			zipFileWriteTime = DateTime.Now;
		}
	}
Ejemplo n.º 12
0
	public Node (Node parent, string caption, string element)
	{
		this.parent = parent;
		this.tree = parent.tree;
		this.caption = caption;
		this.element = element;
	}
Ejemplo n.º 13
0
	//
	// Packs a file with the summary data
	//
	public override void CloseTree (HelpSource hs, Tree tree)
	{
		foreach (DictionaryEntry de in class_summaries){
			XmlDocument doc = new XmlDocument ();
			string ns = (string) de.Key;
			
			ArrayList list = (ArrayList) de.Value;
			list.Sort();

			XmlElement elements = doc.CreateElement ("elements");
			doc.AppendChild (elements);
			
			if (namespace_summaries [ns] != null)
				elements.AppendChild (doc.ImportNode ((XmlNode)namespace_summaries [ns],true));
			else
				elements.AppendChild (doc.CreateElement("summary"));
			
			if (namespace_remarks [ns] != null)
				elements.AppendChild (doc.ImportNode ((XmlNode)namespace_remarks [ns],true));
			else
				elements.AppendChild (doc.CreateElement("remarks"));
			
			hs.Message (TraceLevel.Info, "Have {0} elements in the {1}", list.Count, ns);
			foreach (TypeInfo p in list){
				XmlElement e = null;
				
				switch (p.type_kind){
				case "Class":
					e = doc.CreateElement ("class"); 
					break;
					
				case "Enumeration":
					e = doc.CreateElement ("enum");
					break;
					
				case "Structure":
					e = doc.CreateElement ("struct");
					break;
					
				case "Delegate":
					e = doc.CreateElement ("delegate");
					break;
					
				case "Interface":
					e = doc.CreateElement ("interface");
					break;
				}
				
				e.SetAttribute ("name", p.type_name);
				e.SetAttribute ("fullname", p.type_full);
				e.SetAttribute ("assembly", p.type_assembly);
				XmlNode copy = doc.ImportNode (p.type_doc, true);
				e.AppendChild (copy);
				elements.AppendChild (e);
			}
			hs.PackXml ("xml.summary." + ns, doc,(string) namespace_realpath[ns]);
		}
		
		
		XmlDocument nsSummary = new XmlDocument ();
		XmlElement root = nsSummary.CreateElement ("elements");
		nsSummary.AppendChild (root);
		
		foreach (DictionaryEntry de in namespace_summaries) {
			XmlNode n = (XmlNode)de.Value;
			XmlElement summary = nsSummary.CreateElement ("namespace");
			summary.SetAttribute ("ns", (string)de.Key);
			root.AppendChild (summary);
			if (n != null)
				summary.AppendChild (nsSummary.ImportNode (n,true));
			else
				summary.AppendChild (nsSummary.CreateElement("summary"));
		}
		tree.HelpSource.PackXml ("mastersummary.xml", nsSummary, null);
		AddExtensionMethods (tree);
		AddImageFiles (hs, tree);
	}
Ejemplo n.º 14
0
	void AddImageFiles (HelpSource hs, Tree tree)
	{
		foreach (string asm in asm_dirs) {
			string path = Path.Combine (asm, "_images");
			if (!Directory.Exists (path))
				return;

#if NET_2_0
			foreach (var img in Directory.GetFiles (path))
#else
			foreach (var img in Directory.EnumerateFiles (path))
#endif
				hs.PackFile (img, Path.GetFileName (img));
		}
	}
Ejemplo n.º 15
0
		public override void CloseTree (HelpSource hs, Tree tree)
		{
			Hashtable entries = config.Compile ();
			MemoryStream ms = new MemoryStream ();
			XmlSerializer writer = new XmlSerializer (typeof (ErrorDocumentation));
			
			foreach (DictionaryEntry de in entries) {
				ErrorDocumentation d = (ErrorDocumentation)de.Value;
				string s = (string)de.Key;

				tree.LookupNode (s, "error:" + s);
				
				writer.Serialize (ms, d);
				ms.Position = 0;
				hs.PackStream (ms, s);
				ms.SetLength (0);
			}
			
			tree.Sort ();
		}
Ejemplo n.º 16
0
	//
	// Called at shutdown time after the tree has been populated to perform
	// any fixups or final tasks.
	//
	public abstract void CloseTree (HelpSource hs, Tree tree);
Ejemplo n.º 17
0
	void SetupForOutput ()
	{
		Tree = new Tree (this, "", "");

		FileStream stream = File.Create (zip_filename);
		
		zip_output = new ZipOutputStream (stream);
		zip_output.SetLevel (9);

		buffer = new byte [buffer_size];
	}		
Ejemplo n.º 18
0
 public override void CloseTree(HelpSource hs, Tree tree)
 {
 }
Ejemplo n.º 19
0
		public static void PrintTree (Tree t)
		{
			TreeDumper.PrintTree (t.RootNode);
		}
Ejemplo n.º 20
0
	public abstract void PopulateTree (Tree tree);
	public override void PopulateTree (Tree tree)
	{
		new SimpleHandbookTOCParser(tree, tocFile);
	}
Ejemplo n.º 22
0
		public override void PopulateTree (Tree tree)
		{
			// everything is done in CloseTree so we can pack
		}
  	public SimpleHandbookTOCParser(Tree monodocTree, string tocFile)
  	{
		XmlDocument doc = new XmlDocument();
		doc.Load(tocFile);

		XmlNodeList nodeList = doc.GetElementsByTagName("body");
		XmlNodeList bodylist = nodeList[0].ChildNodes[1].ChildNodes;
		//Node top = monodocTree.LookupNode ("Mono handbook root", "hb:");
		nodeToAddChildrenTo = monodocTree;
		ParseUl(bodylist[1].ChildNodes,monodocTree);

		foreach (string file in tempfiles)
			System.IO.File.Delete (file);
   	}
Ejemplo n.º 24
0
	public override void PopulateTree (Tree tree)
	{
		ArrayList ns_dirs = new ArrayList ();
		foreach (string asm in asm_dirs) {
			ns_dirs.AddRange (Directory.GetDirectories (asm));
		}

		foreach (string ns in ns_dirs){
			string basedir = Directory.GetParent (ns).FullName;
			string [] files = Directory.GetFiles (ns);
			Node ns_node = null;
			string tn = null;
			
			Hashtable nsnodes = new Hashtable();

			foreach (string file in files){
				if (!file.EndsWith (".xml"))
					continue;

				if (ns_node == null) {
					tn = Path.GetFileName (ns);
					tree.HelpSource.Message (TraceLevel.Info, "Processing namespace {0}", tn);
					ns_node = tree.LookupNode (tn, "N:" + tn);
					string ns_summary_file = EcmaDoc.GetNamespaceFile (basedir, tn);
					
					nsnodes[ns_node] = nsnodes;
					
					if (File.Exists (ns_summary_file)) {
						XmlDocument nsSummaryFile = new XmlDocument ();
						nsSummaryFile.Load (ns_summary_file);
						namespace_realpath [tn] = ns_summary_file;
						
						XmlNode ns_summary = nsSummaryFile.SelectSingleNode ("Namespace/Docs/summary");
						if (ns_summary != null && ns_summary.InnerText.Trim () != "To be added." && ns_summary.InnerText != "") {
							namespace_summaries [tn]  = detached.ImportNode (ns_summary, true);
							namespace_remarks [tn]    = detached.ImportNode (nsSummaryFile.SelectSingleNode ("Namespace/Docs/remarks"), true);
						}
						
					} else if (!namespace_summaries.ContainsKey (tn)) {
						namespace_summaries [tn] = null;
						namespace_remarks [tn] = null;
					}
				}
				tree.HelpSource.Message (TraceLevel.Verbose, "    Processing input file {0}", Path.GetFileName (file));

				PopulateClass (tree, tn, ns_node, file);
			}
			
			// Sort the list of types in each namespace
			foreach (Node ns_node2 in nsnodes.Keys)
				ns_node2.Sort();
		}

	}
	public override void CloseTree (HelpSource hs, Tree tree)
	{
	}
Ejemplo n.º 26
0
	void AddExtensionMethods (Tree tree)
	{
		XmlDocument extensions = null;
		XmlNode root = null;
		int numMethods = 0;
		foreach (string asm in asm_dirs) {
			string overview_file = Path.Combine (asm, "index.xml");
			if (File.Exists (overview_file)) {
				XmlDocument overview = new XmlDocument ();
				overview.Load (overview_file);
				XmlNodeList e = overview.SelectNodes ("/Overview/ExtensionMethods/*");
				if (e.Count > 0) {
					if (extensions == null) {
						extensions = new XmlDocument ();
						root = extensions.CreateElement ("ExtensionMethods");
						extensions.AppendChild (root);
					}
					foreach (XmlNode n in e) {
						++numMethods;
						root.AppendChild (extensions.ImportNode (n, true));
					}
				}
			}
		}
		if (extensions != null) {
			tree.HelpSource.Message (TraceLevel.Info, "Have {0} extension methods", numMethods);
			tree.HelpSource.PackXml ("ExtensionMethods.xml", extensions, "ExtensionMethods.xml");
		}
	}
Ejemplo n.º 27
0
	/// <summary>
	///    Creates a node, called by the Tree.
	/// </summary>
	public Node (string caption, string element)
	{
		this.tree = (Tree) this;
		this.caption = caption;
		this.element = element;
		parent = null;
	}
Ejemplo n.º 28
0
	void PopulateClass (Tree tree, string ns, Node ns_node, string file)
	{
		XmlDocument doc = new XmlDocument ();
		doc.Load (file);
		
		string name = EcmaDoc.GetClassName (doc);
		string assembly = EcmaDoc.GetClassAssembly (doc);
		string kind = EcmaDoc.GetTypeKind (doc);
		string full = EcmaDoc.GetFullClassName (doc);

		Node class_node;
		string file_code = ns_node.tree.HelpSource.PackFile (file);

		XmlNode class_summary = detached.ImportNode (doc.SelectSingleNode ("/Type/Docs/summary"), true);
		ArrayList l = (ArrayList) class_summaries [ns];
		if (l == null){
			l = new ArrayList ();
			class_summaries [ns] = (object) l;
		}
		l.Add (new TypeInfo (kind, assembly, full, name, class_summary));
	       
		class_node = ns_node.LookupNode (String.Format ("{0} {1}", name, kind), "ecma:" + file_code + "#" + name + "/");
		
		if (kind == "Delegate") {
			if (doc.SelectSingleNode("/Type/ReturnValue") == null)
				tree.HelpSource.Message (TraceLevel.Error, "Delegate " + name + " does not have a ReturnValue node.  See the ECMA-style updates.");
		}

		if (kind == "Enumeration")
			return;

		if (kind == "Delegate")
			return;
		
		//
		// Always add the Members node
		//
		class_node.CreateNode ("Members", "*");

		PopulateMember (doc, name, class_node, "Constructor", "Constructors");
		PopulateMember (doc, name, class_node, "Method", "Methods");
		PopulateMember (doc, name, class_node, "Property", "Properties");
		PopulateMember (doc, name, class_node, "Field", "Fields");
		PopulateMember (doc, name, class_node, "Event", "Events");
		PopulateMember (doc, name, class_node, "Operator", "Operators");
	}
Ejemplo n.º 29
0
		void TestLegacyNodesSameAsChildNodes (string treeFileName)
		{
			var filePath = Path.Combine (BaseDir, "trees", treeFileName);
			var tree = new Tree (null, filePath);
			CollectionAssert.AreEqual (tree.RootNode.ChildNodes, tree.RootNode.Nodes);
		}