[monkeydoc] Add an extra optional HelpSource parameter to RenderUrl and GetHelpSource...
authorJérémie Laval <jeremie.laval@gmail.com>
Mon, 17 Dec 2012 18:55:41 +0000 (19:55 +0100)
committerJérémie Laval <jeremie.laval@gmail.com>
Tue, 18 Dec 2012 09:43:55 +0000 (10:43 +0100)
mcs/tools/monkeydoc/Monkeydoc/RootTree.cs

index 799ed9514f6a47d0d734ca69b9d79e264c53ec4b..d47418305c2041f2741b754714d2b83405f61697 100644 (file)
@@ -342,15 +342,15 @@ namespace MonkeyDoc
                        return result;
                }
 
-               public TOutput RenderUrl<TOutput> (string url, IDocGenerator<TOutput> generator, out Node node)
+               public TOutput RenderUrl<TOutput> (string url, IDocGenerator<TOutput> generator, out Node node, HelpSource hintSource = null)
                {
                        node = null;
                        string internalId = null;
-                       HelpSource hs = GetHelpSourceAndIdForUrl (url, out internalId, out node);
+                       HelpSource hs = GetHelpSourceAndIdForUrl (url, hintSource, out internalId, out node);
                        return generator.Generate (hs, internalId);
                }
 
-               public HelpSource GetHelpSourceAndIdForUrl (string url, out string internalId, out Node node)
+               public HelpSource GetHelpSourceAndIdForUrl (string url, HelpSource hintSource, out string internalId, out Node node)
                {
                        node = null;
                        internalId = null;
@@ -358,11 +358,13 @@ namespace MonkeyDoc
                        if (url.StartsWith ("root:/", StringComparison.OrdinalIgnoreCase))
                                return this.GetHelpSourceAndIdFromName (url.Substring ("root:/".Length), out internalId, out node);
 
-                       HelpSource helpSource = null;
-                       foreach (var hs in helpSources.Where (h => h.CanHandleUrl (url))) {
-                               if (!string.IsNullOrEmpty (internalId = hs.GetInternalIdForUrl (url, out node))) {
-                                       helpSource = hs;
-                                       break;
+                       HelpSource helpSource = hintSource;
+                       if (helpSource == null || string.IsNullOrEmpty (internalId = helpSource.GetInternalIdForUrl (url, out node))) {
+                               foreach (var hs in helpSources.Where (h => h.CanHandleUrl (url))) {
+                                       if (!string.IsNullOrEmpty (internalId = hs.GetInternalIdForUrl (url, out node))) {
+                                               helpSource = hs;
+                                               break;
+                                       }
                                }
                        }