public void GenerateIndex() { IndexMaker indexMaker = new IndexMaker(); foreach (HelpSource current in this.helpSources) { current.PopulateIndex(indexMaker); } string text = Path.Combine(this.basedir, "monodoc.index"); try { indexMaker.Save(text); } catch (UnauthorizedAccessException) { text = Path.Combine(ConfigurationManager.AppSettings["docDir"], "monodoc.index"); try { indexMaker.Save(text); } catch (UnauthorizedAccessException) { Console.WriteLine("Unable to write index file in {0}", Path.Combine(ConfigurationManager.AppSettings["docDir"], "monodoc.index")); return; } } if (RootTree.IsUnix) { RootTree.chmod(text, 420); } Console.WriteLine("Documentation index at {0} updated", text); }
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); } RootTree.PurgeNode(rootTree.RootNode); rootTree.RootNode.Sort(); return(rootTree); }
public static RootTree LoadTree(string basedir, bool includeExternal = true) { if (string.IsNullOrEmpty(basedir)) { throw new ArgumentNullException("basedir"); } if (!Directory.Exists(basedir)) { throw new ArgumentException("basedir", string.Format("Base documentation directory at '{0}' doesn't exist", basedir)); } XmlDocument xmlDocument = new XmlDocument(); string filename = Path.Combine(basedir, "monodoc.xml"); xmlDocument.Load(filename); IEnumerable <string> sourceFiles = Directory.EnumerateFiles(Path.Combine(basedir, "sources"), "*.source"); if (includeExternal) { sourceFiles = sourceFiles.Concat(RootTree.ProbeExternalDirectorySources()); } return(RootTree.LoadTree(basedir, xmlDocument, sourceFiles)); }
static bool PurgeNode(Node node) { bool result = false; if (!node.Documented) { List <Node> list = new List <Node> (); foreach (Node current in node.Nodes) { bool flag = RootTree.PurgeNode(current); if (flag) { list.Add(current); } } result = (node.Nodes.Count == list.Count); foreach (Node current2 in list) { node.DeleteNode(current2); } } return(result); }
public static RootTree LoadTree() { return(RootTree.LoadTree(RootTree.ProbeBaseDirectories())); }
public static void MakeSearchIndex() { RootTree rootTree = RootTree.LoadTree(); rootTree.GenerateSearchIndex(); }
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.Nodes) { node2.AddNode(current); } node2.Sort(); } } return(true); }