public bool GenerateIndex() { IndexMaker indexMaker = new IndexMaker(); foreach (HelpSource current in this.helpSources) { current.PopulateIndex(indexMaker); } var paths = GetIndexesPathPrefixes().Select(bp => Path.Combine(bp, "monodoc.index")); bool successful = false; foreach (var path in paths) { try { indexMaker.Save(path); successful = true; if (RootTree.IsUnix) { RootTree.chmod(path, 420); } } catch (UnauthorizedAccessException) { } } if (!successful) { Console.WriteLine("You don't have permissions to write on any of [" + string.Join(", ", paths) + "]"); return(false); } Console.WriteLine("Documentation index updated"); return(true); }
public override void PopulateIndex(IndexMaker index_maker) { foreach (Node n in Tree.Nodes) { index_maker.Add(n.Caption, n.Caption, n.Element); } }
public void WriteTopics(IndexMaker maker, Stream stream, BinaryWriter writer) { // // Convention: entries with the same SortKey should have the same Caption // Position = (int)stream.Position; writer.Write(Count); if (topics is ArrayList) { bool first = true; foreach (Topic t in (ArrayList)topics) { if (first) { writer.Write(maker.GetCode(t.Caption)); first = false; } writer.Write(maker.GetCode(t.Url)); } } else { Topic t = (Topic)topics; writer.Write(maker.GetCode(t.Caption)); writer.Write(maker.GetCode(t.Url)); } }
public void WriteTopics(IndexMaker maker, Stream stream, BinaryWriter writer) { // // Convention: entries with the same SortKey should have the same Caption // Position = (int)stream.Position; writer.Write(Count); if (Count == 0) { return; } writer.Write(maker.GetCode(topics[0].Caption)); foreach (Topic t in topics) { writer.Write(maker.GetCode(t.Url)); } }
// // Populates the searchable index. // // The idea of this index is to capture the most common search terms, the UI for this // usually updates automatically as the user types. // public override void PopulateIndex (IndexMaker index_maker) { foreach (Node ns_node in Tree.Nodes){ foreach (Node type_node in ns_node.Nodes){ string typename = type_node.Caption.Substring (0, type_node.Caption.IndexOf (' ')); string full = ns_node.Caption + "." + typename; string doc_tag = GetKindFromCaption (type_node.Caption); string url = "T:" + full; // // Add MonoMac/MonoTouch [Export] attributes, those live only in classes // if (doc_tag == "Class" && (ns_node.Caption.StartsWith ("MonoTouch") || ns_node.Caption.StartsWith ("MonoMac"))){ try { string rest; var xdoc = GetXmlFromUrl (type_node.URL, out rest); if (xdoc != null){ var nodesWithExports = xdoc.SelectNodes ("/Type/Members/Member[contains (Attributes/Attribute/AttributeName, 'Foundation.Export') and (MemberType='Property' or MemberType='Method' or MemberType='Constructor')]"); foreach (XmlNode n in nodesWithExports){ string cref = EcmaDoc.GetCref ((XmlElement) n); var exports = n.SelectNodes ("Attributes/Attribute/AttributeName"); foreach (XmlNode exportNode in exports){ var inner = exportNode.InnerText; int p = inner.IndexOf ("Foundation.Export(\""); if (p == -1){ Console.WriteLine ("Not found the Export attribute in {0}", inner); continue; } var pa = inner.IndexOf ("\"", p); if (pa == -1){ Console.WriteLine ("Export has no target in {0}", inner); continue; } var end = inner.IndexOf ("\"", pa+1); var export = end == -1 ? inner.Substring (pa+1) : inner.Substring (pa+1, end-(pa+1)); index_maker.Add (export + " selector", export, cref); } } } } catch (Exception e){ Console.WriteLine ("Problem processing {0} for MonoTouch/MonoMac exports\n\n{0}", e); } } if (doc_tag == "Class" || doc_tag == "Structure" || doc_tag == "Interface"){ index_maker.Add (type_node.Caption, typename, url); index_maker.Add (full + " " + doc_tag, full, url); foreach (Node c in type_node.Nodes){ switch (c.Caption){ case "Constructors": index_maker.Add (" constructors", typename+"0", url + "/C"); break; case "Fields": index_maker.Add (" fields", typename+"1", url + "/F"); break; case "Events": index_maker.Add (" events", typename+"2", url + "/E"); break; case "Properties": index_maker.Add (" properties", typename+"3", url + "/P"); break; case "Methods": index_maker.Add (" methods", typename+"4", url + "/M"); break; case "Operators": index_maker.Add (" operators", typename+"5", url + "/O"); break; } } // // Now repeat, but use a different sort key, to make sure we come after // the summary data above, start the counter at 6 // string keybase = typename + "6."; foreach (Node c in type_node.Nodes){ switch (c.Caption){ case "Constructors": break; case "Fields": foreach (Node nc in c.Nodes){ string res = nc.Caption; string nurl = String.Format ("F:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} field", typename, res), keybase + res, nurl); index_maker.Add (String.Format ("{0} field", res), res, nurl); } break; case "Events": foreach (Node nc in c.Nodes){ string res = nc.Caption; string nurl = String.Format ("E:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} event", typename, res), keybase + res, nurl); index_maker.Add (String.Format ("{0} event", res), res, nurl); } break; case "Properties": foreach (Node nc in c.Nodes){ string res = nc.Caption; string nurl = String.Format ("P:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} property", typename, res), keybase + res, nurl); index_maker.Add (String.Format ("{0} property", res), res, nurl); } break; case "Methods": foreach (Node nc in c.Nodes){ string res = nc.Caption; int p = res.IndexOf ("("); if (p > 0) res = res.Substring (0, p); string nurl = String.Format ("M:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} method", typename, res), keybase + res, nurl); index_maker.Add (String.Format ("{0} method", res), res, nurl); } break; case "Operators": foreach (Node nc in c.Nodes){ string res = nc.Caption; string nurl = String.Format ("O:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} operator", typename, res), keybase + res, nurl); } break; } } } else if (doc_tag == "Enumeration"){ // // Enumerations: add the enumeration values // index_maker.Add (type_node.Caption, typename, url); index_maker.Add (full + " " + doc_tag, full, url); // Now, pull the values. string rest; XmlDocument x = GetXmlFromUrl (type_node.URL, out rest); if (x == null) continue; XmlNodeList members = x.SelectNodes ("/Type/Members/Member"); if (members == null) continue; foreach (XmlNode member_node in members){ string enum_value = member_node.Attributes ["MemberName"].InnerText; string caption = enum_value + " value"; index_maker.Add (caption, caption, url); } } else if (doc_tag == "Delegate"){ index_maker.Add (type_node.Caption, typename, url); index_maker.Add (full + " " + doc_tag, full, url); } } } }
public override void PopulateIndex (IndexMaker index_maker) { foreach (Node n in Tree.Nodes) index_maker.Add (n.Caption, n.Caption, n.Element); }
// // Populates the index. // public virtual void PopulateIndex (IndexMaker index_maker) { }
public static void MakeIndex () { RootTree root = LoadTree (); if (root == null) return; IndexMaker index_maker = new IndexMaker (); foreach (HelpSource hs in root.help_sources){ hs.PopulateIndex (index_maker); } // if the user has no write permissions use config dir string path = Path.Combine (root.basedir, "monodoc.index"); try { index_maker.Save (path); } catch (System.UnauthorizedAccessException) { path = Path.Combine (SettingsHandler.Path, "monodoc.index"); try { index_maker.Save (path); } catch (System.UnauthorizedAccessException) { Console.WriteLine ("Unable to write index file in {0}", Path.Combine (SettingsHandler.Path, "monodoc.index")); return; } } if (IsUnix){ // No octal in C#, how lame is that chmod (path, 0x1a4); } Console.WriteLine ("Documentation index updated"); }
public void WriteTopics (IndexMaker maker, Stream stream, BinaryWriter writer) { // // Convention: entries with the same SortKey should have the same Caption // Position = (int) stream.Position; writer.Write (Count); if (Count == 0) return; writer.Write (maker.GetCode (topics[0].Caption)); foreach (Topic t in topics) writer.Write (maker.GetCode (t.Url)); }
public override void PopulateIndex (IndexMaker index_maker) { PopulateIndexFromNodes (Tree); }
// // Populates the index. // public override void PopulateIndex (IndexMaker index_maker) { foreach (Node ns_node in Tree.Nodes){ foreach (Node type_node in ns_node.Nodes){ string typename = type_node.Caption.Substring (0, type_node.Caption.IndexOf (' ')); string full = ns_node.Caption + "." + typename; string doc_tag = GetKindFromCaption (type_node.Caption); string url = "T:" + full; if (doc_tag == "Class" || doc_tag == "Structure" || doc_tag == "Interface"){ index_maker.Add (type_node.Caption, typename, url); index_maker.Add (full + " " + doc_tag, full, url); foreach (Node c in type_node.Nodes){ switch (c.Caption){ case "Constructors": index_maker.Add (" constructors", typename+"0", url + "/C"); break; case "Fields": index_maker.Add (" fields", typename+"1", url + "/F"); break; case "Events": index_maker.Add (" events", typename+"2", url + "/E"); break; case "Properties": index_maker.Add (" properties", typename+"3", url + "/P"); break; case "Methods": index_maker.Add (" methods", typename+"4", url + "/M"); break; case "Operators": index_maker.Add (" operators", typename+"5", url + "/O"); break; } } // // Now repeat, but use a different sort key, to make sure we come after // the summary data above, start the counter at 6 // string keybase = typename + "6."; foreach (Node c in type_node.Nodes){ switch (c.Caption){ case "Constructors": break; case "Fields": foreach (Node nc in c.Nodes){ string res = nc.Caption; string nurl = String.Format ("F:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} field", typename, res), keybase + res, nurl); index_maker.Add (String.Format ("{0} field", res), res, nurl); } break; case "Events": foreach (Node nc in c.Nodes){ string res = nc.Caption; string nurl = String.Format ("E:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} event", typename, res), keybase + res, nurl); index_maker.Add (String.Format ("{0} event", res), res, nurl); } break; case "Properties": foreach (Node nc in c.Nodes){ string res = nc.Caption; string nurl = String.Format ("P:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} property", typename, res), keybase + res, nurl); index_maker.Add (String.Format ("{0} property", res), res, nurl); } break; case "Methods": foreach (Node nc in c.Nodes){ string res = nc.Caption; int p = res.IndexOf ("("); if (p > 0) res = res.Substring (0, p); string nurl = String.Format ("M:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} method", typename, res), keybase + res, nurl); index_maker.Add (String.Format ("{0} method", res), res, nurl); } break; case "Operators": foreach (Node nc in c.Nodes){ string res = nc.Caption; string nurl = String.Format ("O:{0}.{1}", full, res); index_maker.Add (String.Format ("{0}.{1} operator", typename, res), keybase + res, nurl); } break; } } } else if (doc_tag == "Enumeration"){ // // Enumerations: add the enumeration values // index_maker.Add (type_node.Caption, typename, url); index_maker.Add (full + " " + doc_tag, full, url); // Now, pull the values. string rest; XmlDocument x = GetXmlFromUrl (type_node.URL, out rest); if (x == null) continue; XmlNodeList members = x.SelectNodes ("/Type/Members/Member"); if (members == null) continue; foreach (XmlNode member_node in members){ string enum_value = member_node.Attributes ["MemberName"].InnerText; string caption = enum_value + " value"; index_maker.Add (caption, caption, url); } } else if (doc_tag == "Delegate"){ index_maker.Add (type_node.Caption, typename, url); index_maker.Add (full + " " + doc_tag, full, url); } } } }
public override void PopulateIndex(IndexMaker index_maker) { PopulateIndexFromNodes(Tree); }
// // Populates the index. // public virtual void PopulateIndex(IndexMaker index_maker) { }
public void WriteTopics (IndexMaker maker, Stream stream, BinaryWriter writer) { // // Convention: entries with the same SortKey should have the same Caption // Position = (int) stream.Position; writer.Write (Count); if (topics is ArrayList){ bool first = true; foreach (Topic t in (ArrayList) topics){ if (first){ writer.Write (maker.GetCode (t.Caption)); first = false; } writer.Write (maker.GetCode (t.Url)); } } else { Topic t = (Topic) topics; writer.Write (maker.GetCode (t.Caption)); writer.Write (maker.GetCode (t.Url)); } }