7 using System.Collections.Generic;
9 using Lucene.Net.Index;
10 using Lucene.Net.Documents;
13 using Monodoc.Storage;
16 namespace Monodoc.Providers
18 public class EcmaUncompiledHelpSource : EcmaHelpSource
20 readonly DirectoryInfo basedir;
21 readonly string basedoc;
23 public readonly string BasePath;
25 public new string Name {
30 /* base_file: the directory containing the index.xml file, usually in Mono land .../Documentation/en
31 * markName: if true, we encase the node caption with [] to clearly mark it's from an uncompiled source
33 public EcmaUncompiledHelpSource (string base_file, bool markName = true) : base ()
35 basedir = new DirectoryInfo (base_file);
36 BasePath = basedir.FullName;
38 basedoc = Path.Combine (basedir.FullName, "index.xml");
40 Name = ((string)XDocument.Load (basedoc).Root.Element ("Title")) ?? "UnnamedUncompiledSource";
42 Name = '[' + Name + ']';
43 Tree.RootNode.Caption = Name;
45 Func<XElement, string> indexGenerator = type => {
46 var nsName = (string)type.Parent.Attribute ("Name");
47 var typeName = (string)type.Attribute ("Name");
48 return Path.ChangeExtension (nsName + '/' + typeName, ".xml");
51 this.Storage = new UncompiledDocStorage (BasePath);
53 EcmaDoc.PopulateTreeFromIndexFile (basedoc, UriPrefix, Tree, null, null, indexGenerator);
56 protected override string UriPrefix {
62 public override Stream GetImage (string url)
64 var path = Path.Combine (BasePath, "_images", url);
65 return File.Exists (path) ? File.OpenRead (path) : (Stream)null;