// Miguel de Icaza (miguel@ximian.com)
//
// (C) 2002, Ximian, Inc.
+// Copyright 2003-2011 Novell
+// Copyright 2011 Xamarin Inc
//
// TODO:
// Each node should have a provider link
using System.Diagnostics;
using System.Configuration;
using System.Reflection;
-using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.XPath;
using ICSharpCode.SharpZipLib.Zip;
if (other.position < 0)
other.LoadNode ();
- Regex digits = new Regex (@"([\d]+)|([^\d]+)");
- MatchEvaluator eval = delegate (Match m) {
- return (m.Value.Length > 0 && char.IsDigit (m.Value [0]))
- ? m.Value.PadLeft (System.Math.Max (caption.Length, other.caption.Length))
- : m.Value;
- };
- return digits.Replace (caption, eval).CompareTo (digits.Replace (other.caption, eval));
+ var cap1 = caption;
+ var cap2 = other.caption;
+
+ /* Some node (notably from ecmaspec) have number prepended to them
+ * which we need to sort better by padding them to the same number
+ * of digits
+ */
+ if (char.IsDigit (cap1[0]) && char.IsDigit (cap2[0])) {
+ int c1 = cap1.TakeWhile (char.IsDigit).Count ();
+ int c2 = cap2.TakeWhile (char.IsDigit).Count ();
+
+ if (c1 != c2) {
+ cap1 = cap1.PadLeft (cap1.Length + Math.Max (0, c2 - c1), '0');
+ cap2 = cap2.PadLeft (cap2.Length + Math.Max (0, c1 - c2), '0');
+ }
+ }
+
+ return string.Compare (cap1, cap2, StringComparison.OrdinalIgnoreCase);
}
}
int source_id;
DateTime zipFileWriteTime;
string name;
+ string basepath;
TraceLevel trace_level = TraceLevel.Warning;
protected bool nozip;
protected string base_dir;
public HelpSource (string base_filename, bool create)
{
this.name = Path.GetFileName (base_filename);
+ this.basepath = Path.GetDirectoryName (base_filename);
tree_filename = base_filename + ".tree";
zip_filename = base_filename + ".zip";
base_dir = XmlDocUtils.GetCacheDirectory (base_filename);
}
}
+ /* This gives the full path of the source/ directory */
+ public string BaseFilePath {
+ get {
+ return basepath;
+ }
+ }
+
public TraceLevel TraceLevel {
get { return trace_level; }
set { trace_level = value; }
{
if (nozip) {
Stream s = File.OpenRead (XmlDocUtils.GetCachedFileName (base_dir, id));
- string url = "monodoc:///" + SourceID + "@" + System.Web.HttpUtility.UrlEncode (id) + "@";
+ string url = "monodoc:///" + SourceID + "@" + Uri.EscapeUriString (id) + "@";
return new XmlTextReader (url, s);
}
ZipEntry entry = zip_file.GetEntry (id);
if (entry != null) {
Stream s = zip_file.GetInputStream (entry);
- string url = "monodoc:///" + SourceID + "@" + System.Web.HttpUtility.UrlEncode (id) + "@";
+ string url = "monodoc:///" + SourceID + "@" + Uri.EscapeUriString (id) + "@";
return new XmlTextReader (url, s);
}
return null;
{
if (nozip) {
Stream s = File.OpenRead (XmlDocUtils.GetCachedFileName (base_dir, id));
- string url = "monodoc:///" + SourceID + "@" + System.Web.HttpUtility.UrlEncode (id) + "@";
+ string url = "monodoc:///" + SourceID + "@" + Uri.EscapeUriString (id) + "@";
XmlReader r = new XmlTextReader (url, s);
XmlDocument ret = new XmlDocument ();
ret.Load (r);
ZipEntry entry = zip_file.GetEntry (id);
if (entry != null) {
Stream s = zip_file.GetInputStream (entry);
- string url = "monodoc:///" + SourceID + "@" + System.Web.HttpUtility.UrlEncode (id) + "@";
+ string url = "monodoc:///" + SourceID + "@" + Uri.EscapeUriString (id) + "@";
XmlReader r = new XmlTextReader (url, s);
XmlDocument ret = new XmlDocument ();
ret.Load (r);
}
}
}
- Console.WriteLine ("Basedir={0}", basedir);
//
// Load the layout
.Concat (osxExternalSources));
}
-
// Compatibility shim w/ Mono 2.6
public static RootTree LoadTree (string indexDir, XmlDocument docTree, IEnumerable sourceFiles)
{
//
// Load the sources
//
- foreach (var sourceFile in sourceFiles){
+ foreach (var sourceFile in sourceFiles)
root.AddSourceFile (sourceFile);
- }
foreach (string path in UncompiledHelpSources) {
EcmaUncompiledHelpSource hs = new EcmaUncompiledHelpSource(path);
return lastHelpSourceTime;
}
}
-
+
public static bool GetNamespaceAndType (string url, out string ns, out string type)
{
int nsidx = -1;
// No octal in C#, how lame is that
chmod (path, 0x1a4);
}
- Console.WriteLine ("Documentation index updated");
+ Console.WriteLine ("Documentation index at {0} updated", path);
}
static bool IsUnix {