Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Laval <jeremie.laval@gmail.com>2013-01-28 15:57:49 +0400
committerJeremie Laval <jeremie.laval@gmail.com>2013-01-28 15:57:49 +0400
commitb6c4ef50f1b08614007c6a94595e23b14eba2018 (patch)
tree71262d411396dc5794d9ec5f5ddb1878092a6bea
parentf49eadbdc4f04e4cddb3c45abec873cfeb3dc4e6 (diff)
[windoc] Backport changes from macdoc
-rw-r--r--windoc/WinDoc/BookmarkManager.cs6
-rw-r--r--windoc/WinDoc/DocTools.cs31
-rw-r--r--windoc/WinDoc/IndexUpdateManager.cs16
-rw-r--r--windoc/WinDoc/Logger.cs36
-rw-r--r--windoc/WinDoc/MainWindow.cs8
-rw-r--r--windoc/WinDoc/Program.cs7
-rw-r--r--windoc/WinDoc/WinDoc.csproj1
-rw-r--r--windoc/WinDoc/lib/ICSharpCode.SharpZipLib.dllbin131072 -> 131072 bytes
-rw-r--r--windoc/WinDoc/lib/monodoc.dllbin1150464 -> 1098240 bytes
-rw-r--r--windoc/WinDoc/lib/monodoc.dll.config10
10 files changed, 81 insertions, 34 deletions
diff --git a/windoc/WinDoc/BookmarkManager.cs b/windoc/WinDoc/BookmarkManager.cs
index eab19e58..1353d8ce 100644
--- a/windoc/WinDoc/BookmarkManager.cs
+++ b/windoc/WinDoc/BookmarkManager.cs
@@ -96,8 +96,10 @@ namespace WinDoc
if (!Directory.Exists (storagePath))
Directory.CreateDirectory (storagePath);
var path = Path.Combine (storagePath, "bookmarks.xml");
- using (var file = File.Create (path))
- serializer.Serialize (file, bookmarks);
+ try {
+ using (var file = File.Create (path))
+ serializer.Serialize (file, bookmarks);
+ } catch (UnauthorizedAccessException) {}
}
public void CommitBookmarkChange (Entry entry)
diff --git a/windoc/WinDoc/DocTools.cs b/windoc/WinDoc/DocTools.cs
index 18f67821..01ee2b4f 100644
--- a/windoc/WinDoc/DocTools.cs
+++ b/windoc/WinDoc/DocTools.cs
@@ -4,11 +4,15 @@
using System;
using Monodoc;
+using Monodoc.Generators;
using System.IO;
namespace WinDoc
{
- public class DocTools {
+ public class DocTools
+ {
+ static IDocGenerator<string> generator = new HtmlGenerator (null);
+
public static string GetHtml (string url, HelpSource helpSource)
{
Node _;
@@ -17,23 +21,20 @@ namespace WinDoc
public static string GetHtml (string url, HelpSource helpSource, out Node match)
{
- Console.WriteLine ("Calling URL {0} with HelpSource {1}", url, helpSource == null ? "(null)" : helpSource.Name);
-
string htmlContent = null;
match = null;
if (helpSource != null)
- htmlContent = helpSource.GetText (url, out match);
- if (htmlContent == null){
+ htmlContent = Program.Root.RenderUrl (url, generator, out match, helpSource);
+ if (htmlContent == null) {
// the displayed url have a lower case type code (e.g. t: instead of T:) which confuse monodoc
if (url.Length > 2 && url[1] == ':')
url = char.ToUpperInvariant (url[0]) + url.Substring (1);
// It may also be url encoded so decode it
url = Uri.UnescapeDataString (url);
- htmlContent = Program.Root.RenderUrl (url, out match);
- if (htmlContent != null && match != null && match.tree != null){
- helpSource = match.tree.HelpSource;
- }
+ htmlContent = Program.Root.RenderUrl (url, generator, out match, helpSource);
+ if (htmlContent != null && match != null && match.Tree != null)
+ helpSource = match.Tree.HelpSource;
}
if (htmlContent == null)
return null;
@@ -41,17 +42,17 @@ namespace WinDoc
var html = new StringWriter ();
html.Write ("<html>\n<head><title>{0}</title>", url);
- if (helpSource != null){
- if (helpSource.InlineCss != null)
- html.Write (" <style type=\"text/css\">{0}</style>\n", helpSource.InlineCss);
- if (helpSource.InlineJavaScript != null)
- html.Write ("<script type=\"text/JavaScript\">{0}</script>\n", helpSource.InlineJavaScript);
+ if (helpSource != null) {
+ if (HtmlGenerator.InlineCss != null)
+ html.Write (" <style type=\"text/css\">{0}</style>\n", HtmlGenerator.InlineCss);
+ /*if (helpSource.InlineJavaScript != null)
+ html.Write ("<script type=\"text/JavaScript\">{0}</script>\n", helpSource.InlineJavaScript);*/
}
html.Write ("</head><body>");
html.Write (htmlContent);
html.Write ("</body></html>\n");
- return html.ToString ();
+ return html.ToString ();
}
}
}
diff --git a/windoc/WinDoc/IndexUpdateManager.cs b/windoc/WinDoc/IndexUpdateManager.cs
index 3a248554..e8d0ae05 100644
--- a/windoc/WinDoc/IndexUpdateManager.cs
+++ b/windoc/WinDoc/IndexUpdateManager.cs
@@ -22,7 +22,7 @@ namespace WinDoc
public IndexUpdateManager (IEnumerable<string> sourceFiles, string baseUserDir)
{
- Console.WriteLine ("Going to verify [{0}]", sourceFiles.Aggregate ((e1, e2) => e1 + ", " + e2));
+ Logger.Log ("Going to verify [{0}]", sourceFiles.Aggregate ((e1, e2) => e1 + ", " + e2));
this.baseUserDir = baseUserDir;
this.sourceFiles = sourceFiles;
}
@@ -61,7 +61,7 @@ namespace WinDoc
md5sums[source] = hash;
}
- Console.WriteLine ("We have a {0} fresh index", isFresh);
+ Logger.Log ("Index fresh? {0}", isFresh ? "yes" : "no");
return IsFresh = isFresh;
});
@@ -91,8 +91,16 @@ namespace WinDoc
public void PerformSearchIndexCreation ()
{
FireSearchIndexCreationEvent (true);
- RootTree.MakeSearchIndex ();
- RootTree.MakeIndex ();
+ try {
+ RootTree.MakeSearchIndex ();
+ } catch (Exception e) {
+ Logger.LogError ("Error making search index", e);
+ }
+ try {
+ RootTree.MakeIndex ();
+ } catch (Exception e) {
+ Logger.LogError ("Error making normal index", e);
+ }
IsFresh = true;
FireSearchIndexCreationEvent (false);
if (md5sums != null)
diff --git a/windoc/WinDoc/Logger.cs b/windoc/WinDoc/Logger.cs
new file mode 100644
index 00000000..10b192be
--- /dev/null
+++ b/windoc/WinDoc/Logger.cs
@@ -0,0 +1,36 @@
+using System;
+using System.IO;
+
+namespace WinDoc
+{
+ public static class Logger
+ {
+ static readonly string LogFilePath;
+
+ static Logger ()
+ {
+ var baseLogFolder = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "WinDoc", "Logs");
+ if (!Directory.Exists (baseLogFolder))
+ Directory.CreateDirectory (baseLogFolder);
+ LogFilePath = Path.Combine (baseLogFolder, string.Format ("WinDoc-{0}.log", DateTime.Now.ToString ("yyyy-MM-ddTHHmmss")));
+ }
+
+ public static void Log (string message)
+ {
+ Console.WriteLine (message);
+ File.AppendAllText (LogFilePath, message + Environment.NewLine);
+ }
+
+ public static void Log (string messageFormat, params object[] args)
+ {
+ Log (string.Format (messageFormat, args));
+ }
+
+ public static void LogError (string message, Exception ex)
+ {
+ Console.WriteLine (message + ": " + ex.Message);
+ File.AppendAllText (LogFilePath, message + ". " + ex.ToString () + Environment.NewLine);
+ }
+ }
+}
+
diff --git a/windoc/WinDoc/MainWindow.cs b/windoc/WinDoc/MainWindow.cs
index 636bf516..aea0bd52 100644
--- a/windoc/WinDoc/MainWindow.cs
+++ b/windoc/WinDoc/MainWindow.cs
@@ -49,12 +49,12 @@ namespace WinDoc
indexManager.UpdaterChange += IndexUpdaterCallback;
indexManager.CheckIndexIsFresh ().ContinueWith (t => {
if (t.IsFaulted)
- Console.WriteLine ("Error while checking indexes: {0}", t.Exception);
+ Logger.LogError ("Error while checking indexes", t.Exception);
else if (!t.Result)
indexManager.PerformSearchIndexCreation ();
else
indexManager.AdvertiseFreshIndex ();
- }).ContinueWith (t => Console.WriteLine ("Error while creating indexes: {0}", t.Exception), TaskContinuationOptions.OnlyOnFaulted);
+ }).ContinueWith (t => Logger.LogError ("Error while creating indexes", t.Exception), TaskContinuationOptions.OnlyOnFaulted);
SetupSearch ();
SetupDocTree ();
@@ -123,7 +123,7 @@ namespace WinDoc
void SetupDocTree ()
{
- var node = (Node)Program.Root;
+ var node = Program.Root.RootNode;
var rootTreeNode = new TreeNode ();
foreach (Node child in node.Nodes)
@@ -137,7 +137,7 @@ namespace WinDoc
docTree.AfterSelect += (s, e) => {
var treeNode = e.Node;
var n = treeNode.Tag as Node;
- LoadUrl (n.PublicUrl, true, n.tree.HelpSource);
+ LoadUrl (n.PublicUrl, true, n.Tree.HelpSource);
};
docTree.DrawNode += CustomDrawing.DrawDocTreeNodeText;
}
diff --git a/windoc/WinDoc/Program.cs b/windoc/WinDoc/Program.cs
index 603366a3..5f7661e6 100644
--- a/windoc/WinDoc/Program.cs
+++ b/windoc/WinDoc/Program.cs
@@ -41,7 +41,7 @@ namespace WinDoc
// Load documentation
Directory.SetCurrentDirectory (Path.GetDirectoryName (typeof (Program).Assembly.Location));
- Root = RootTree.LoadTree (null);
+ Root = RootTree.LoadTree ();
foreach (var dir in docSources)
Root.AddSource (dir);
if (Directory.Exists (externalMonodocPath))
@@ -56,11 +56,6 @@ namespace WinDoc
.Where (File.Exists),
winDocPath);
BookmarkManager = new BookmarkManager (winDocPath);
-
- // Configure the documentation rendering.
- SettingsHandler.Settings.EnableEditing = false;
- SettingsHandler.Settings.preferred_font_size = 200;
- HelpSource.use_css = true;
Application.ApplicationExit += (s, e) => BookmarkManager.SaveBookmarks ();
Application.EnableVisualStyles();
diff --git a/windoc/WinDoc/WinDoc.csproj b/windoc/WinDoc/WinDoc.csproj
index 4343138c..83f541f6 100644
--- a/windoc/WinDoc/WinDoc.csproj
+++ b/windoc/WinDoc/WinDoc.csproj
@@ -69,6 +69,7 @@
<Compile Include="history.cs" />
<Compile Include="IndexSearcher.cs" />
<Compile Include="IndexUpdateManager.cs" />
+ <Compile Include="Logger.cs" />
<Compile Include="MainWindow.cs">
<SubType>Form</SubType>
</Compile>
diff --git a/windoc/WinDoc/lib/ICSharpCode.SharpZipLib.dll b/windoc/WinDoc/lib/ICSharpCode.SharpZipLib.dll
index 42515d9a..83f9a8f5 100644
--- a/windoc/WinDoc/lib/ICSharpCode.SharpZipLib.dll
+++ b/windoc/WinDoc/lib/ICSharpCode.SharpZipLib.dll
Binary files differ
diff --git a/windoc/WinDoc/lib/monodoc.dll b/windoc/WinDoc/lib/monodoc.dll
index 4fdd17fb..eceb1022 100644
--- a/windoc/WinDoc/lib/monodoc.dll
+++ b/windoc/WinDoc/lib/monodoc.dll
Binary files differ
diff --git a/windoc/WinDoc/lib/monodoc.dll.config b/windoc/WinDoc/lib/monodoc.dll.config
index befa5169..df4bd627 100644
--- a/windoc/WinDoc/lib/monodoc.dll.config
+++ b/windoc/WinDoc/lib/monodoc.dll.config
@@ -1,3 +1,7 @@
-<config>
- <path docsPath="C:\Monodoc\" />
-</config>
+<configuration>
+ <appSettings>
+ <add key="docPath" value="C:\Monodoc" />
+ <add key="docExternalPath" value="" />
+ <!-- <add key="cache" value="file,~/path/to/cache/directory" /> -->
+ </appSettings>
+</configuration>