* Mono.Documentation/webdoc.cs: When extracting files from the .zip
authorJonathan Pryor <jpryor@novell.com>
Thu, 16 Apr 2009 00:45:43 +0000 (00:45 -0000)
committerJonathan Pryor <jpryor@novell.com>
Thu, 16 Apr 2009 00:45:43 +0000 (00:45 -0000)
  file, ensure that the output file is closed.  Properly pre-render
  ecma namespace documentation.

svn path=/trunk/mcs/; revision=131845

mcs/tools/mdoc/ChangeLog
mcs/tools/mdoc/Mono.Documentation/webdoc.cs

index dd1264c691655909ab996ed346d9a38b064b722d..dd978952e7e20358298dffc41880177ee28d0c44 100644 (file)
@@ -1,3 +1,9 @@
+2009-04-15  Jonathan Pryor <jpryor@novell.com>
+
+       * Mono.Documentation/webdoc.cs: When extracting files from the .zip
+         file, ensure that the output file is closed.  Properly pre-render
+         ecma namespace documentation.
+
 2009-04-15  Jonathan Pryor <jpryor@novell.com>
 
        * Makefile: Add reference to ICSharpCode.SharpZipLib.dll.
index 9d096b7f1e0349e39ab9b4696d1e071abc99ace8..5c50cd7620d90fd804326b5b2a6c6492cf2f8406 100644 (file)
@@ -115,7 +115,8 @@ namespace Mono.Documentation
                                string file = Path.Combine (outDir, entry.Name);
                                Console.WriteLine ("# Extracting zip entry: {0}; to: {1}", entry.Name, file);
                                Directory.CreateDirectory (Path.GetDirectoryName (file));
-                               zip.WriteTo (File.OpenWrite (file));
+                               using (var output = File.OpenWrite (file))
+                                       zip.WriteTo (output);
                        }
                }
 
@@ -139,7 +140,15 @@ namespace Mono.Documentation
                                Console.WriteLine ("# file={0}", file);
                                using (var o = File.AppendText (file)) {
                                        Node _;
-                                       o.Write (hs.GetText (url, out _));
+                                       // Sometimes the HelpSource won't directly support a url.
+                                       // Case in point: the Tree will contain N:Enter.Namespace.Here nodes
+                                       // which aren't supported by HelpSource.GetText.
+                                       // If this happens, docRoot.RenderUrl() works.
+                                       // (And no, we can't always use docRoot.RenderUrl() for URLs like
+                                       // "ecma:0#Foo/", as that'll just grab the 0th stream contents from
+                                       // the first EcmaHelpSource found...
+                                       string contents = hs.GetText (url, out _) ?? docRoot.RenderUrl (url, out _);
+                                       o.Write (contents);
                                }
                        }
                }