Пример #1
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);
					
					foreach (var s in sources)
						if (Directory.Exists (s))
							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 ();
				}
			}
		}
Пример #2
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 ();
					
					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 ();
				}
			}
		}
Пример #3
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 ();
					
					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 ();
				}
			}
		}
Пример #4
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.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;
		}
Пример #5
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));
        }