public APIDocumentation() { if (root_ == null) { string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); dir = System.IO.Path.Combine(System.IO.Path.Combine(dir, "bin"), "ScriptAPI.dox"); if (!System.IO.File.Exists(dir)) { //\todo, do something about the case where it doesn't exist? invoke the script API } string[] lines = File.ReadAllLines(dir); APINode current = new APINode { Name = "Root" }; APINode lastPage = null; APINode lastSection = null; APINode lastSubsection = null; foreach (string line in lines) { if (line.StartsWith("\\page")) { string[] words = line.Split(' '); APINode nd = new APINode { Name = string.Join(" ", words, 2, words.Length - 2) }; current.Children.Add(nd); nd.Parent = current; lastPage = nd; lastSection = null; lastSubsection = null; } else if (line.StartsWith("\\section")) { string[] words = line.Split(' '); APINode nd = new APINode { Name = string.Join(" ", words, 2, words.Length - 2) }; if (lastSection != null) { lastSection.Children.Add(nd); nd.Parent = lastSection; } else { lastPage.Children.Add(nd); nd.Parent = lastPage; } lastSubsection = nd; } else if (line.StartsWith("## ")) { APINode nd = new APINode { Name = line.Replace("## ", "").Replace("%", "") }; lastSection = nd; lastPage.Children.Add(nd); nd.Parent = lastPage; } else if (line.StartsWith("### ")) { APINode nd = new APINode { Name = line.Replace("### ", "").Replace("%", "") }; if (lastSection == null) { lastPage.Children.Add(nd); nd.Parent = lastPage; } else { lastSection.Children.Add(nd); nd.Parent = lastSection; } lastSubsection = nd; } else if (line.StartsWith("- ")) { APILeaf leaf = new APILeaf { Name = line.Replace("- ", "").Replace("%", "") }; if (leaf.Name.Contains(":")) { leaf.TypeAnnote = leaf.Name.Substring(leaf.Name.IndexOf(':') + 2); } lastSubsection.Children.Add(leaf); leaf.Parent = lastSubsection; } } //current.Prune(); DocumentNode = current; } }