Beispiel #1
0
		public void ReachabilityWithShortGenericNotationTest ()
		{
			var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false);
			Node result;
			var generator = new CheckGenerator ();

			Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Concurrent.IProducerConsumerCollection`1", generator, out result), "#1");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary`2", generator, out result), "#2");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`4", generator, out result), "#3");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.EventHandler`1", generator, out result), "#4");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`5", generator, out result), "#5a");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`4", generator, out result), "#5b");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`6", generator, out result), "#5c");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`7", generator, out result), "#5d");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`3", generator, out result), "#5e");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`2", generator, out result), "#5f");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`1", generator, out result), "#5g");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`8", generator, out result), "#5h");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`9", generator, out result), "#5i");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`3", generator, out result), "#6a");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`2", generator, out result), "#6b");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`4", generator, out result), "#6c");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.IComparable`1", generator, out result), "#7");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Lazy`1", generator, out result), "#8");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`1", generator, out result), "#9a");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`2", generator, out result), "#9b");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`3", generator, out result), "#9c");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`4", generator, out result), "#9d");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary`2+ValueCollection", generator, out result), "#10");
			Assert.IsFalse (rootTree.RenderUrl ("T:System.EventHandler`2", generator, out result), "#11");
			Assert.IsFalse (rootTree.RenderUrl ("T:System.Lazy`2", generator, out result), "#12");
		}
Beispiel #2
0
 static void InitializeHelpTree()
 {
     lock (helpTreeLock) {
         if (helpTreeInitialized)
         {
             return;
         }
         try {
             var cacheDir = GetMonoDocCacheRoot();
             if (!cacheDir.IsNullOrEmpty)
             {
                 helpTree = RootTree.LoadTree(cacheDir);
             }
             else
             {
                 helpTree = RootTree.LoadTree();
             }
         } catch (Exception ex) {
             if (!(ex is ThreadAbortException) && !(ex.InnerException is ThreadAbortException))
             {
                 LoggingService.LogError("Monodoc documentation tree could not be loaded.", ex);
             }
         } finally {
             helpTreeInitialized = true;
             LoggingService.Trace("Ide.HelpService", "[ASYNC] Initialized Help Service");
         }
     }
 }
Beispiel #3
0
		public override void Run (IEnumerable<string> args)
		{
			string rootPath = null;

			var options = new OptionSet () {
				{ "r=|root=", "Specify which documentation root to use. Default is $libdir/monodoc", v => rootPath = v },
			};

			var extra = Parse (options, args, "index", 
			                   "[OPTIONS]+ ACTION",
			                   "Create Monodoc indexes depending on ACTION. Possible values are \"tree\" or \"search\" for, respectively, mdoc tree and lucene search");
			if (extra == null)
				return;

			var root = string.IsNullOrEmpty (rootPath) ? RootTree.LoadTree () : RootTree.LoadTree (rootPath);

			foreach (var action in extra) {
				switch (action) {
				case "tree":
					RootTree.MakeIndex (root);
					break;
				case "search":
					RootTree.MakeSearchIndex (root);
					break;
				}
			}
		}
Beispiel #4
0
        public void ReachabilityTest()
        {
            var  rootTree = RootTree.LoadTree(GetBaseDir(), false);
            Node result;
            var  generator  = new CheckGenerator();
            int  errorCount = 0;
            int  testCount  = 0;

            foreach (var leaf in GetLeaves(rootTree.RootNode))
            {
                if (!rootTree.RenderUrl(leaf.PublicUrl, generator, out result) || leaf.PublicUrl != result.PublicUrl)
                {
                    Console.WriteLine("Error: {0} with HelpSource {1} ", leaf.PublicUrl, leaf.Tree.HelpSource.Name);
                    errorCount++;
                }
                testCount++;
            }

            //Assert.AreEqual (0, errorCount, errorCount + " / " + testCount.ToString ());

            // HACK: in reality we have currently 17 known issues, mostly which are due to duplicated namespaces across
            // doc sources, something that was never supported and that we need to improve/fix at some stage.
            // also some issues with operators.
            Assert.That(errorCount, Is.LessThanOrEqualTo(17), errorCount + " / " + testCount.ToString());
        }
Beispiel #5
0
        void GenerateCache(string basePath, string treeFile, string outDir)
        {
            Tree       tree           = new Tree(null, treeFile);
            RootTree   docRoot        = RootTree.LoadTree();
            string     helpSourceName = Path.GetFileName(basePath);
            HelpSource hs             = docRoot.HelpSources.Cast <HelpSource> ()
                                        .FirstOrDefault(h => h.Name == helpSourceName);

            if (hs == null)
            {
                throw new Exception("Only installed .tree and .zip files are supported.");
            }
            foreach (Node node in tree.TraverseDepthFirst <Node, Node> (t => t, t => t.Nodes.Cast <Node> ()))
            {
                var url = node.URL;
                Message(TraceLevel.Info, "\tProcessing URL: {0}", url);
                if (string.IsNullOrEmpty(url))
                {
                    continue;
                }
                var file = XmlDocUtils.GetCachedFileName(outDir, url);
                using (var o = File.AppendText(file)) {
                    Node _;
                    // 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);
                }
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            var initialUrl = string.Empty;
            var docSources = new List <string> ();

            new OptionSet {
                { "url=|u=", u => initialUrl = u },
                { "docdir=", dir => docSources.Add(dir) },
            }.Parse(args);

            if (initialUrl.StartsWith("mdoc://"))
            {
                initialUrl = initialUrl.Substring("mdoc://".Length);              // Remove leading scheme
                initialUrl = initialUrl.Substring(0, initialUrl.Length - 1);      // Remove trailing '/'
                initialUrl = Uri.UnescapeDataString(initialUrl);                  // Unescape URL
            }

            // Don't crash if any of these steps fails
            try {
                PrepareCache();
                SetupLogging();
                ExtractImages();
            } catch (Exception e) {
                Console.WriteLine("Non-fatal exception during initialization: {0}", e);
            }

            // Load documentation
            Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(Program).Assembly.Location));
            Root = RootTree.LoadTree();
            foreach (var dir in docSources)
            {
                Root.AddSource(dir);
            }
            if (Directory.Exists(externalMonodocPath))
            {
                Root.AddSource(externalMonodocPath);
            }

            var winDocPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WinDoc");

            if (!Directory.Exists(winDocPath))
            {
                Directory.CreateDirectory(winDocPath);
            }
            IndexUpdateManager = new IndexUpdateManager(Root.HelpSources
                                                        .Cast <HelpSource> ()
                                                        .Select(hs => Path.Combine(hs.BaseFilePath, hs.Name + ".zip"))
                                                        .Where(File.Exists),
                                                        winDocPath);
            BookmarkManager = new BookmarkManager(winDocPath);

            Application.ApplicationExit += (s, e) => BookmarkManager.SaveBookmarks();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainWindow(initialUrl));
        }
Beispiel #7
0
        //FIXME: allow adding sources without restart when extension installed (will need to be async)
        // will also be tricky we cause we'll also have update any running MonoDoc viewer
        void InitializeHelpTree()
        {
            lock (helpTreeLock) {
                if (helpTreeInitialized)
                {
                    return;
                }

                // Only attempt on Windows if we can find monodoc.xml (currently not the case).
                // This avoids a first-chance FileNotFoundException in LoadTree.
                if (Platform.IsWindows && !File.Exists("monodoc.xml"))
                {
                    LoggingService.LogError("Monodoc documentation tree could not be loaded because monodoc.xml was not found.");
                    helpTreeInitialized = true;
                    return;
                }

                Counters.HelpServiceInitialization.BeginTiming();

                try {
                    helpTree = RootTree.LoadTree();

                    foreach (var node in AddinManager.GetExtensionNodes("/MonoDevelop/ProjectModel/MonoDocSources"))
                    {
                        sources.Add(((MonoDocSourceNode)node).Directory);
                    }

                    if (Platform.IsWindows)
                    {
                        // windoc defines a special external directory used by XA. we need to read these docs too.
                        // Not sure why it wasn't defined in monodoc.dll
                        var commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                        sources.Add(Path.Combine(commonAppData, "Monodoc"));
                    }

                    //remove nonexistent sources
                    foreach (var s in sources.ToList().Where(d => !Directory.Exists(d)))
                    {
                        sources.Remove(s);
                    }

                    foreach (var s in sources)
                    {
                        helpTree.AddSource(s);
                    }
                } catch (Exception ex) {
                    if (!(ex is ThreadAbortException) && !(ex.InnerException is ThreadAbortException))
                    {
                        LoggingService.LogError("Monodoc documentation tree could not be loaded.", ex);
                    }
                } finally {
                    helpTreeInitialized = true;
                    Counters.HelpServiceInitialization.EndTiming();
                }
            }
        }
Beispiel #8
0
        public void ReachabilityWithShortGenericNotationTest()
        {
            var  rootTree = RootTree.LoadTree(Path.GetFullPath(BaseDir), false);
            Node result;
            var  generator = new CheckGenerator();

            Assert.IsTrue(rootTree.RenderUrl("T:System.Collections.Concurrent.IProducerConsumerCollection`1", generator, out result), "#1");
            Assert.IsTrue(rootTree.RenderUrl("T:System.Collections.Generic.Dictionary`2", generator, out result), "#2");
            Assert.IsTrue(rootTree.RenderUrl("T:System.Action`4", generator, out result), "#3");
        }
Beispiel #9
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Let's Render!");

            string   contentPath = IO.Path.GetDirectoryName(typeof(MainClass).Assembly.Location);
            RootTree tree        = RootTree.LoadTree(contentPath, includeExternal: false);

            MyRenderer renderer = new MyRenderer();

            string renderedOutput = tree.RenderUrl("T:My.Sample.SomeClass", renderer);

            Console.WriteLine(renderedOutput);
        }
Beispiel #10
0
		public void AspNetStyleUrlReachabilityTest ()
		{
			var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false);
			Node result;
			var generator = new CheckGenerator ();

			Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary{TKey,TValue}", generator, out result), "#1");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Action{T1,T2}", generator, out result), "#2");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.EventHandler{TEventArgs}", generator, out result), "#3");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Func{T1,T2,T3,TResult}", generator, out result), "#4");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary{TKey,TValue}+ValueCollection", generator, out result), "#5");
			Assert.IsTrue (rootTree.RenderUrl ("T:System.IComparable{T}", generator, out result), "#6");
		}
Beispiel #11
0
        //FIXME: allow adding sources without restart when extension installed (will need to be async)
        // will also be tricky we cause we'll also have update any running MonoDoc viewer
        static void InitializeHelpTree()
        {
            lock (helpTreeLock)
            {
                if (helpTreeInitialized)
                {
                    return;
                }

                //Counters.HelpServiceInitialization.BeginTiming();

                try
                {
                    //foreach (var node in AddinManager.GetExtensionNodes("/MonoDevelop/ProjectModel/MonoDocSources"))
                    //    sources.Add(((MonoDocSourceNode)node).Directory);
                    sources.Add("/usr/lib/monodoc");
                    sources.Add("/Library/Frameworks/Mono.framework/Versions/Current/lib/monodoc/");
                    string monodoc = System.Environment.GetEnvironmentVariable("MONO_MONODOC");
                    if (monodoc != null)
                    {
                        foreach (string searchPath in monodoc.Split(':'))
                        {
                            sources.Add(searchPath);
                        }
                    }

                    //remove nonexistent sources
                    foreach (var s in sources.ToList().Where(d => !Directory.Exists(d)))
                    {
                        sources.Remove(s);
                    }

                    //foreach (var s in sources)
                    //    helpTree.AddSource(s);
                    helpTree = RootTree.LoadTree(sources.First());
                }
                catch (Exception ex)
                {
                    if (!(ex is ThreadAbortException) && !(ex.InnerException is ThreadAbortException))
                    {
                        //LoggingService.LogError("Monodoc documentation tree could not be loaded.", ex);
                        Console.WriteLine("Monodoc documentation tree could not be loaded." + ex);
                    }
                }
                finally
                {
                    helpTreeInitialized = true;
                    //Counters.HelpServiceInitialization.EndTiming();
                }
            }
        }
Beispiel #12
0
		public void ReachabilityWithCrefsTest ()
		{
			var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false);
			Node result;
			var htmlGenerator = new HtmlGenerator (null);
			var crefs = new HashSet<string> ();
			var generator = new CheckGenerator ();
			int errorCount = 0;

			foreach (var leaf in GetLeaves (rootTree.RootNode)) {
				Dictionary<string, string> context;
				string internalId = leaf.Tree.HelpSource.GetInternalIdForUrl (leaf.PublicUrl, out result, out context);
				if (leaf.Tree.HelpSource.GetDocumentTypeForId (internalId) != DocumentType.EcmaXml)
					continue;

				string content = null;
				if (string.IsNullOrEmpty (content = rootTree.RenderUrl (leaf.PublicUrl, htmlGenerator, out result)) || leaf != result) {
					Console.WriteLine ("Error: {0} with HelpSource {1} ", leaf.PublicUrl, leaf.Tree.HelpSource.Name);
					continue;
				}

				HtmlDocument doc = new HtmlDocument();
				try {
					doc.LoadHtml (content);
				} catch {
					Console.WriteLine ("Couldn't load a HTML document for URL {0}", leaf.PublicUrl);
					continue;
				}

				foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]")) {
					var newUrl = link.Attributes["href"].Value;
					var hashIndex = newUrl.IndexOf ('#');
					if (hashIndex != -1)
						newUrl = newUrl.Substring (0, hashIndex);
					if (newUrl.Length > 1 && newUrl[1] == ':' && char.IsLetter (newUrl, 0) && char.ToLowerInvariant (newUrl[0]) != 'c')
						crefs.Add (newUrl);
				}

				foreach (var cref in crefs) {
					if (!rootTree.RenderUrl (cref, generator, out result) || result == null) {
						Console.WriteLine ("Error with cref: `{0}'", cref);
						errorCount++;
					}
				}

				crefs.Clear ();
			}

			Assert.AreEqual (0, errorCount, errorCount + " / " + crefs.Count);
		}
        //FIXME: allow adding sources without restart when extension installed (will need to be async)
        // will also be tricky we cause we'll also have update any running MonoDoc viewer
        static void InitializeHelpTree()
        {
            lock (helpTreeLock)
            {
                if (helpTreeInitialized)
                {
                    return;
                }

                Counters.HelpServiceInitialization.BeginTiming();

                try
                {
                    helpTree = RootTree.LoadTree();

                    foreach (var node in AddinManager.GetExtensionNodes("/MonoDevelop/ProjectModel/MonoDocSources"))
                    {
                        sources.Add(((MonoDocSourceNode)node).Directory);
                    }

                    //remove nonexistent sources
                    foreach (var s in sources.ToList().Where(d => !Directory.Exists(d)))
                    {
                        sources.Remove(s);
                    }

                    foreach (var s in sources)
                    {
                        helpTree.AddSource(s);
                    }
                }
                catch (Exception ex)
                {
                    if (!(ex is ThreadAbortException) && !(ex.InnerException is ThreadAbortException))
                    {
                        LoggingService.LogError("Monodoc documentation tree could not be loaded.", ex);
                    }
                }
                finally
                {
                    helpTreeInitialized = true;
                    Counters.HelpServiceInitialization.EndTiming();
                }
            }
        }
Beispiel #14
0
        //FIXME: allow adding sources without restart when extension installed (will need to be async)
        // will also be tricky we cause we'll also have update any running MonoDoc viewer
        static void InitializeHelpTree()
        {
            lock (helpTreeLock) {
                if (helpTreeInitialized)
                {
                    return;
                }

                Counters.HelpServiceInitialization.BeginTiming();

                try {
                    helpTree = RootTree.LoadTree();

                    //FIXME: don't do this when monodoc itself does it or we'll get duplicates!
                    if (PropertyService.IsMac)
                    {
                        sources.Add("/Library/Frameworks/Mono.framework/External/monodoc");
                    }

                    foreach (var node in AddinManager.GetExtensionNodes("/MonoDevelop/ProjectModel/MonoDocSources"))
                    {
                        sources.Add(((MonoDocSourceNode)node).Directory);
                    }

                    //remove nonexistent sources
                    foreach (var s in sources.ToList().Where(d => !Directory.Exists(d)))
                    {
                        sources.Remove(s);
                    }

                    foreach (var s in sources)
                    {
                        helpTree.AddSource(s);
                    }
                } catch (Exception ex) {
                    if (!(ex is ThreadAbortException) && !(ex.InnerException is ThreadAbortException))
                    {
                        LoggingService.LogError("Monodoc documentation tree could not be loaded.", ex);
                    }
                } finally {
                    helpTreeInitialized = true;
                    Counters.HelpServiceInitialization.EndTiming();
                }
            }
        }
Beispiel #15
0
        public void PublicUrlOnUnattachedHelpSourceRoot()
        {
            // Unattached help source have no root:/ URL attributed
            var hs       = new EcmaHelpSource(Path.Combine(BaseDir, "sources", "netdocs"), false);
            var rootTree = RootTree.LoadTree(Path.GetFullPath(BaseDir), false);

            hs.RootTree = rootTree;
            Assert.IsNull(hs.Tree.RootNode.PublicUrl);
            var nsChildUrl = hs.Tree.RootNode.ChildNodes.First().PublicUrl;

            Assert.IsNotNull(nsChildUrl);
            StringAssert.StartsWith("N:", nsChildUrl);
            // Verify GetNodeTypeParent
            var typeNode = hs.Tree.RootNode.ChildNodes.First().ChildNodes.First();
            var metaNode = typeNode.ChildNodes.First(cn => cn.Element == "M");

            StringAssert.StartsWith(typeNode.PublicUrl, metaNode.PublicUrl);
        }
Beispiel #16
0
        void GenerateCache(Options opts, string basePath, string format, string outDir)
        {
            var hs = RootTree.GetHelpSource(format, basePath);

            if (hs == null)
            {
                Error("Unable to find a HelpSource for provider '{0}' and file '{1}.tree'.", format, basePath);
            }
            var      tree    = hs.Tree;
            RootTree docRoot = null;

            if (!opts.UseSystemSources)
            {
                docRoot = RootTree.LoadTree(null, null, opts.Sources);
            }
            else
            {
                docRoot = RootTree.LoadTree();
                foreach (var source in opts.Sources)
                {
                    docRoot.AddSourceFile(source);
                }
            }
            hs.RootTree = docRoot;
            string helpSourceName = Path.GetFileName(basePath);

            foreach (Node node in tree.TraverseDepthFirst <Node, Node> (t => t, t => t.Nodes.Cast <Node> ()))
            {
                var url = node.URL;
                Message(TraceLevel.Info, "\tProcessing URL: {0}", url);
                if (string.IsNullOrEmpty(url))
                {
                    continue;
                }
                var file = XmlDocUtils.GetCachedFileName(outDir, url);
                using (var o = File.AppendText(file)) {
                    Node   _;
                    string contents = hs.GetText(url, out _) ?? hs.RenderNamespaceLookup(url, out _);
                    o.Write(contents);
                }
            }
        }
Beispiel #17
0
        public void ReachabilityTest()
        {
            var  rootTree = RootTree.LoadTree(Path.GetFullPath(BaseDir), false);
            Node result;
            var  generator  = new CheckGenerator();
            int  errorCount = 0;
            int  testCount  = 0;

            foreach (var leaf in GetLeaves(rootTree.RootNode))
            {
                if (!rootTree.RenderUrl(leaf.PublicUrl, generator, out result) || leaf != result)
                {
                    Console.WriteLine("Error: " + leaf.PublicUrl);
                    errorCount++;
                }
                testCount++;
            }

            Assert.AreEqual(0, errorCount, errorCount + " / " + testCount.ToString());
        }
 public void Setup()
 {
     rootTree = RootTree.LoadTree(GetBaseDir(), false);
 }
Beispiel #19
0
        public AppDelegate()
        {
            PrepareCache();
            ExtractImages();
            controller = new MonodocDocumentController();

            // Some UI feature we use rely on Lion or better, so special case it
            try {
                var version    = new NSDictionary("/System/Library/CoreServices/SystemVersion.plist");
                var osxVersion = Version.Parse(version.ObjectForKey(new NSString("ProductVersion")).ToString());
                isOnLion = osxVersion.Major == 10 && osxVersion.Minor >= 7;
            } catch {}

            // Load documentation
            var args = Environment.GetCommandLineArgs();
            IEnumerable <string> extraDocs = null, extraUncompiledDocs = null;

            if (args != null && args.Length > 1)
            {
                var extraDirs = args.Skip(1);
                extraDocs = extraDirs
                            .Where(d => d.StartsWith("+"))
                            .Select(d => d.Substring(1))
                            .Where(d => Directory.Exists(d));
                extraUncompiledDocs = extraDirs
                                      .Where(d => d.StartsWith("@"))
                                      .Select(d => d.Substring(1))
                                      .Where(d => Directory.Exists(d));
            }

            if (extraUncompiledDocs != null)
            {
                foreach (var dir in extraUncompiledDocs)
                {
                    RootTree.AddUncompiledSource(dir);
                }
            }

            Root = RootTree.LoadTree();

            if (extraDocs != null)
            {
                foreach (var dir in extraDocs)
                {
                    Root.AddSource(dir);
                }
            }

            var macDocPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "macdoc");

            if (!Directory.Exists(macDocPath))
            {
                Directory.CreateDirectory(macDocPath);
            }
            var helpSources = Root.HelpSources
                              .Cast <HelpSource> ()
                              .Where(hs => !string.IsNullOrEmpty(hs.BaseFilePath) && !string.IsNullOrEmpty(hs.Name))
                              .Select(hs => Path.Combine(hs.BaseFilePath, hs.Name + ".zip"))
                              .Where(File.Exists);

            IndexUpdateManager = new IndexUpdateManager(helpSources,
                                                        macDocPath);
            BookmarkManager = new BookmarkManager(macDocPath);
        }
        public AppDelegate()
        {
            PrepareCache();
            ExtractImages();
            controller = new MonodocDocumentController();

            // Some UI feature we use rely on Lion, so special case it
            try
            {
                var version = new NSDictionary("/System/Library/CoreServices/SystemVersion.plist");
                isOnLion = version.ObjectForKey(new NSString("ProductVersion")).ToString().StartsWith("10.7");
            }
            catch {}

            // Load documentation
            var args = Environment.GetCommandLineArgs();
            IEnumerable <string> extraDocs = null, extraUncompiledDocs = null;

            if (args != null && args.Length > 1)
            {
                var extraDirs = args.Skip(1);
                extraDocs = extraDirs
                            .Where(d => d.StartsWith("+"))
                            .Select(d => d.Substring(1))
                            .Where(d => Directory.Exists(d));
                extraUncompiledDocs = extraDirs
                                      .Where(d => d.StartsWith("@"))
                                      .Select(d => d.Substring(1))
                                      .Where(d => Directory.Exists(d));
            }

            if (extraUncompiledDocs != null)
            {
                foreach (var dir in extraUncompiledDocs)
                {
                    RootTree.UncompiledHelpSources.Add(dir);
                }
            }

            Root = RootTree.LoadTree(null);

            if (extraDocs != null)
            {
                foreach (var dir in extraDocs)
                {
                    Root.AddSource(dir);
                }
            }

            var macDocPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "macdoc");

            if (!Directory.Exists(macDocPath))
            {
                Directory.CreateDirectory(macDocPath);
            }
            var helpSources = Root.HelpSources
                              .Cast <HelpSource> ()
                              .Where(hs => !string.IsNullOrEmpty(hs.BaseFilePath) && !string.IsNullOrEmpty(hs.Name))
                              .Select(hs => Path.Combine(hs.BaseFilePath, hs.Name + ".zip"))
                              .Where(File.Exists);

            IndexUpdateManager = new IndexUpdateManager(helpSources,
                                                        macDocPath);
            BookmarkManager = new BookmarkManager(macDocPath);
            AppleDocHandler = new AppleDocHandler("/Library/Frameworks/Mono.framework/Versions/Current/etc/");

            // Configure the documentation rendering.
            SettingsHandler.Settings.EnableEditing       = false;
            SettingsHandler.Settings.preferred_font_size = 200;
            HelpSource.use_css = true;
        }
Beispiel #21
0
 public void Setup()
 {
     root      = RootTree.LoadTree(GetBaseDir(), includeExternal: false);
     generator = new HtmlGenerator(defaultCache: null);
 }
 public void Setup()
 {
     rootTree = RootTree.LoadTree(Path.GetFullPath(BaseDir), false);
 }
Beispiel #23
0
        public AppDelegate()
        {
            PrepareCache();
            ExtractImages();
            controller = new MonodocDocumentController();

            // Some UI feature we use rely on Lion or better, so special case it
            try {
                var version    = new NSDictionary("/System/Library/CoreServices/SystemVersion.plist");
                var osxVersion = Version.Parse(version.ObjectForKey(new NSString("ProductVersion")).ToString());
                isOnLion = osxVersion.Major == 10 && osxVersion.Minor >= 7;
            } catch {}

            // Load documentation
            var args = Environment.GetCommandLineArgs();
            IEnumerable <string> extraDocs = null, extraUncompiledDocs = null;

            if (args != null && args.Length > 1)
            {
                var extraDirs = args.Skip(1);
                extraDocs = extraDirs
                            .Where(d => d.StartsWith("+"))
                            .Select(d => d.Substring(1))
                            .Where(d => Directory.Exists(d));
                extraUncompiledDocs = extraDirs
                                      .Where(d => d.StartsWith("@"))
                                      .Select(d => d.Substring(1))
                                      .Where(d => Directory.Exists(d));
            }

            if (extraUncompiledDocs != null)
            {
                foreach (var dir in extraUncompiledDocs)
                {
                    RootTree.AddUncompiledSource(dir);
                }
            }

            if (ConfigurationManager.AppSettings == null)
            {
                Logger.Log("Setting default settings because ConfigurationManager.AppSettings is null");
                var keyValueConfigurationCollection = new KeyValueConfigurationCollection();
                keyValueConfigurationCollection.Add("docPath", "/Library/Frameworks/Mono.framework/Versions/Current/lib/monodoc/");
                keyValueConfigurationCollection.Add("docExternalPath", "");
                typeof(Config).GetField("exeConfig", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, keyValueConfigurationCollection);
                Lucene.Net.Support.AppSettings.Set("java.version", "");
                Lucene.Net.Support.AppSettings.Set("java.vendor", "");
            }

            Root = RootTree.LoadTree();

            if (extraDocs != null)
            {
                foreach (var dir in extraDocs)
                {
                    Root.AddSource(dir);
                }
            }

            var macDocPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "macdoc");

            if (!Directory.Exists(macDocPath))
            {
                Directory.CreateDirectory(macDocPath);
            }
            var helpSources = Root.HelpSources
                              .Cast <HelpSource> ()
                              .Where(hs => !string.IsNullOrEmpty(hs.BaseFilePath) && !string.IsNullOrEmpty(hs.Name))
                              .Select(hs => Path.Combine(hs.BaseFilePath, hs.Name + ".zip"))
                              .Where(File.Exists);

            IndexUpdateManager = new IndexUpdateManager(helpSources,
                                                        macDocPath);
            BookmarkManager = new BookmarkManager(macDocPath);
        }
Beispiel #24
0
 public void Setup()
 {
     rootTree = RootTree.LoadTree(BaseDir, false);
 }