[monodoc] Handle global `root:' url
authorJérémie Laval <jeremie.laval@gmail.com>
Wed, 13 Mar 2013 14:25:46 +0000 (14:25 +0000)
committerJérémie Laval <jeremie.laval@gmail.com>
Wed, 13 Mar 2013 14:25:46 +0000 (14:25 +0000)
mcs/class/monodoc/Monodoc/RootTree.cs
mcs/class/monodoc/Monodoc/generators/HtmlGenerator.cs
mcs/class/monodoc/Resources/home.html

index f679740da30dab1bde87e159e88e37fe8a77311f..ec153f75557c42ed09b55ffaf76c2cd543a851e2 100644 (file)
@@ -382,6 +382,13 @@ namespace Monodoc
                        internalId = null;
                        context = null;
 
+                       if (url == "root:") {
+                               context = new Dictionary<string, string> { {"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<string, string> { {"specialpage", "root"} };
                                return this.GetHelpSourceAndIdFromName (url.Substring (RootNamespace.Length), out internalId, out node);
index 4500c9d30bbe29fcef7aa1a8c4720dc83d354cdf..dc2c08c3aa9fbf515baf9b25ecb11078a92901c4 100644 (file)
@@ -48,6 +48,10 @@ namespace Monodoc.Generators
 
                public string Generate (HelpSource hs, string id, Dictionary<string, string> 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 ("<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)
index 2d748a7e92ec4c1fd0ac39167d35538413ddb588..dde2ec9deade307cfe5732898bbd4e859ca2974e 100644 (file)
@@ -1,69 +1,17 @@
+<html>
 <head>
-<style type="text/css">
-/* GENERAL */
-
-body, table {
-       font-family: @@FONT_FAMILY@@, sans-serif;
-       font-size: @@FONT_SIZE@@%;
-}
-
-/* ECMA BLOCK */
-#docs {
-       margin-bottom: 1em;
-}
-
-/* CONTRIBUTIONS */
-#contrib {
-       margin-top: 2em;
-       width: 98%;
-       margin-left: 1%;
-       color: black;
-       background: #fff3f3;
-       border: 1px solid #ffc9c9;
-       @@EDITING_ENABLED@@
-       }
-#contribTitle {
-       text-align: left;
-       font-weight: bold;
-       padding: .4em;
-       font-size: 110%;
-       @@CONTRIB_DISP@@
-}
-#contrib #content {
-       padding: .4em;
-}
-#some-contrib {
-       @@CONTRIB_DISP@@
-}
-#no-contrib {
-       @@NO_CONTRIB_DISP@@
-}
-#contrib p {
-       text-indent: 1em;
-       text-align: justify;
-       }
-</style>
 <link type="text/css" rel="stylesheet" href="mono-ecma.css"/>
 </head>
 
-<div class="Content">
-  <p>The following documentation collections are available:
+<body>
+  <div class="Content">
+       <p>The following documentation collections are available:</p>
   
-  <div id="docs">
-       <ul>
+       <div id="docs">
+         <ul>
            @@API_DOCS@@
-       </ul>
-  </div>
-  
-  <div id="contrib">
-       <div id="contribTitle">Contributions</div>
-       <div id="content">
-               <div id="some-contrib">
-                       @@CONTRIBS@@
-               </div>
-               <div id="no-contrib">
-                       <p><b>You have not made any contributions yet.</b></p>
-                       <p>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 <font color="blue">[Edit]</font> link to start writing documentation.</p>
-                       <p>When you are happy with your changes, use the Contributing--&gt; Upload Contribution--&gt; menu to send your contributions to our server.</p></div>  </div>
+         </ul>
+       </div>
   </div>
-</div>
+</body>
+</html>