update copyrights
[mono.git] / mcs / tools / monodoc / Monodoc / error-provider.cs
index 9758d25b9e6070cf98bef8d4b36d5f00e28e7f6e..79337119d90eb988fab1c82adc91201236db1bc4 100644 (file)
@@ -5,6 +5,8 @@
 //   Ben Maurer (bmaurer@users.sourceforge.net)
 //
 // (C) 2003 Ben Maurer
+// Copyright 2003-2011 Novell
+// Copyright 2011 Xamarin Inc
 //
 
 using System;
@@ -15,6 +17,9 @@ using System.IO;
 using System.Text;
 using System.Xml;
 using System.Xml.Serialization;
+using System.Linq;
+using Mono.Lucene.Net.Index;
+using Mono.Lucene.Net.Documents;
 
 namespace Monodoc {
 
@@ -270,6 +275,21 @@ namespace Monodoc {
                                index_maker.Add (n.Caption, n.Caption, n.Element);
                }
 
+               public override void PopulateSearchableIndex (IndexWriter writer) 
+               {
+                       foreach (Node n in Tree.Nodes) {
+                               XmlSerializer reader = new XmlSerializer (typeof (ErrorDocumentation));
+                               ErrorDocumentation d = (ErrorDocumentation)reader.Deserialize (GetHelpStream (n.Element.Substring (6)));
+                               SearchableDocument doc = new SearchableDocument ();
+                               doc.title = d.ErrorName;
+                               doc.url = n.Element;
+                               doc.text = d.Details != null ? d.Details.ToString () : string.Empty;
+                               doc.examples = d.Examples.Cast<string> ().Aggregate ((e1, e2) => e1 + Environment.NewLine + e2);
+                               doc.hottext = d.ErrorName;
+                               writer.AddDocument (doc.LuceneDoc);
+                       }
+               }
+
                public static string css_error_code = @"
                                                                 #error_ref { 
                                                                    background: #debcb0;