From: Jérémie Laval Date: Wed, 13 Mar 2013 14:25:46 +0000 (+0000) Subject: [monodoc] Handle global `root:' url X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=112da01bdc56f86244effe9ee74d5fe3ee7a6f5d;p=mono.git [monodoc] Handle global `root:' url --- diff --git a/mcs/class/monodoc/Monodoc/RootTree.cs b/mcs/class/monodoc/Monodoc/RootTree.cs index f679740da30..ec153f75557 100644 --- a/mcs/class/monodoc/Monodoc/RootTree.cs +++ b/mcs/class/monodoc/Monodoc/RootTree.cs @@ -382,6 +382,13 @@ namespace Monodoc internalId = null; context = null; + if (url == "root:") { + context = new Dictionary { {"specialpage", "master-root"} }; + internalId = url; + node = null; + // We return the first help source available since the generator will simply fetch this RootTree instance through it + return helpSources.FirstOrDefault (); + } if (url.StartsWith (RootNamespace, StringComparison.OrdinalIgnoreCase)) { context = new Dictionary { {"specialpage", "root"} }; return this.GetHelpSourceAndIdFromName (url.Substring (RootNamespace.Length), out internalId, out node); diff --git a/mcs/class/monodoc/Monodoc/generators/HtmlGenerator.cs b/mcs/class/monodoc/Monodoc/generators/HtmlGenerator.cs index 4500c9d30bb..dc2c08c3aa9 100644 --- a/mcs/class/monodoc/Monodoc/generators/HtmlGenerator.cs +++ b/mcs/class/monodoc/Monodoc/generators/HtmlGenerator.cs @@ -48,6 +48,10 @@ namespace Monodoc.Generators public string Generate (HelpSource hs, string id, Dictionary context) { + string specialPage; + if (context != null && context.TryGetValue ("specialpage", out specialPage) && specialPage == "master-root") + return GenerateMasterRootPage (hs != null ? hs.RootTree : null); + 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)")); @@ -91,6 +95,18 @@ namespace Monodoc.Generators 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 ("
  • {1}
  • ", n.Element, n.Caption))); + return home.Replace ("@@API_DOCS@@", links); + } + public static string InlineCss { get { if (css_code != null) diff --git a/mcs/class/monodoc/Resources/home.html b/mcs/class/monodoc/Resources/home.html index 2d748a7e92e..dde2ec9dead 100644 --- a/mcs/class/monodoc/Resources/home.html +++ b/mcs/class/monodoc/Resources/home.html @@ -1,69 +1,17 @@ + - -
    -

    The following documentation collections are available: + +

    +

    The following documentation collections are available:

    -
    -
      +
      +
        @@API_DOCS@@ -
      -
      - -
      -
      Contributions
      -
      -
      - @@CONTRIBS@@ -
      -
      -

      You have not made any contributions yet.

      -

      The Documentation of the libraries is not complete and your contributions would be greatly appreciated. The procedure is easy, browse to the part of the documentation you want to contribute to and click on the [Edit] link to start writing documentation.

      -

      When you are happy with your changes, use the Contributing--> Upload Contribution--> menu to send your contributions to our server.

      +
    +
    -
    + +