public string Generate (HelpSource hs, string id, Dictionary<string, string> context)
{
+ string specialPage = null;
+ if (context != null && context.TryGetValue ("specialpage", out specialPage) && specialPage == "master-root")
+ return GenerateMasterRootPage (hs != null ? hs.RootTree : null);
+
+ if (id == "root:" && hs == null)
+ return MakeEmptySummary ();
+
if (hs == null || string.IsNullOrEmpty (id))
return MakeHtmlError (string.Format ("Your request has found no candidate provider [hs=\"{0}\", id=\"{1}\"]",
hs == null ? "(null)" : hs.Name, id ?? "(null)"));
+
var cache = defaultCache ?? hs.Cache;
if (cache != null && cache.IsCached (MakeCacheKey (hs, id, null)))
return cache.GetCachedString (MakeCacheKey (hs, id, null));
return sb.ToString ();
}
+ string GenerateMasterRootPage (RootTree rootTree)
+ {
+ if (rootTree == null)
+ return string.Empty;
+ var assembly = System.Reflection.Assembly.GetAssembly (typeof (HtmlGenerator));
+ var hpStream = assembly.GetManifestResourceStream ("home.html");
+ var home = new StreamReader (hpStream).ReadToEnd ();
+ var links = string.Join (Environment.NewLine,
+ rootTree.RootNode.ChildNodes.Select (n => string.Format ("<li><a href=\"{0}\">{1}</a></li>", n.Element, n.Caption)));
+ return home.Replace ("@@API_DOCS@@", links);
+ }
+
public static string InlineCss {
get {
if (css_code != null)
string MakeHtmlError (string error)
{
- return string.Format ("<html><head></head><body><p>{0}</p></body></html>", error);
+ return string.Format ("<html><head></head><body><p><em>Error:</em> {0}</p></body></html>", error);
+ }
+
+ string MakeEmptySummary ()
+ {
+ return @"<html><head></head><body><p><em>This node doesn't have a summary available</p></body></html>";
}
string MakeCacheKey (HelpSource hs, string page, IDictionary<string,string> extraParams)