static int Main(string [] args) { string topic = null; for (int i = 0; i < args.Length; i++) { switch (args [i]) { case "--html": if (i + 1 == args.Length) { Console.WriteLine("--html needed argument"); return(1); } Node n; RootTree help_tree = RootTree.LoadTree(); string res = help_tree.RenderUrl(args [i + 1], out n); if (res != null) { Console.WriteLine(res); return(0); } else { return(1); } case "--make-index": RootTree.MakeIndex(); return(0); case "--help": Console.WriteLine("Options are:\n" + "browser [--html TOPIC] [--make-index] [TOPIC] [--merge-changes CHANGE_FILE TARGET_DIR+]"); return(0); case "--merge-changes": if (i + 2 == args.Length) { Console.WriteLine("--merge-changes 2+ args"); return(1); } ArrayList targetDirs = new ArrayList(); for (int j = i + 2; j < args.Length; j++) { targetDirs.Add(args [j]); } EditMerger e = new EditMerger( GlobalChangeset.LoadFromFile(args [i + 1]), targetDirs ); e.Merge(); return(0); default: topic = args [i]; break; } } Settings.RunningGUI = true; DocumentBrowser browser = new DocumentBrowser(); browser.Run(); return(0); }
static int Main (string [] args) { string topic = null; bool remote_mode = false; string engine = engines[0]; string basedir = null; string mergeConfigFile = null; bool show_help = false, show_version = false; bool show_gui = true; var sources = new List<string> (); int r = 0; var p = new OptionSet () { { "docrootdir=", "Load documentation tree & sources from {DIR}. The default directory is $libdir/monodoc.", v => { basedir = v != null && v.Length > 0 ? v : null; string md; if (basedir != null && !File.Exists (Path.Combine (basedir, "monodoc.xml"))) { Error ("Missing required file monodoc.xml."); r = 1; } } }, { "docdir=", "Load documentation from {DIR}.", v => sources.Add (v) }, { "edit=", "Edit mdoc(5) XML documentation found within {PATH}.", v => RootTree.UncompiledHelpSources.Add (v) }, { "engine=", "Specify which HTML rendering {ENGINE} to use:\n" + " " + string.Join ("\n ", engines) + "\n" + "If the chosen engine isn't available " + "(or you\nhaven't chosen one), monodoc will fallback to the next " + "one on the list until one is found.", v => engine = v }, { "html=", "Write to stdout the HTML documentation for {CREF}.", v => { show_gui = false; Node n; RootTree help_tree = LoadTree (basedir, sources); string res = help_tree.RenderUrl (v, out n); if (res != null) Console.WriteLine (res); else { Error ("Could not find topic: {0}", v); r = 1; } } }, { "make-index", "Generate a documentation index. Requires write permission to $libdir/monodoc.", v => { show_gui = false; RootTree.MakeIndex (); } }, { "make-search-index", "Generate a search index. Requires write permission to $libdir/monodoc.", v => { show_gui = false; RootTree.MakeSearchIndex () ; } }, { "merge-changes=", "Merge documentation changes found within {FILE} and target directories.", v => { show_gui = false; if (v != null) mergeConfigFile = v; else { Error ("Missing config file for --merge-changes."); r = 1; } } }, { "remote-mode", "Accept CREFs from stdin to display in the browser.\n" + "For MonoDevelop integration.", v => remote_mode = v != null }, { "about|version", "Write version information and exit.", v => show_version = v != null }, { "h|?|help", "Show this message and exit.", v => show_help = v != null }, }; List<string> topics = p.Parse (args); if (show_version) { Console.WriteLine ("Mono Documentation Browser"); Version ver = Assembly.GetExecutingAssembly ().GetName ().Version; if (ver != null) Console.WriteLine (ver.ToString ()); return r; } if (show_help) { Console.WriteLine ("usage: monodoc [--html TOPIC] [--make-index] [--make-search-index] [--merge-changes CHANGE_FILE TARGET_DIR+] [--about] [--edit path] [--remote-mode] [--engine engine] [TOPIC]"); p.WriteOptionDescriptions (Console.Out); return r; } if (mergeConfigFile != null) { ArrayList targetDirs = new ArrayList (); for (int i = 0; i < topics.Count; i++) targetDirs.Add (topics [i]); EditMerger e = new EditMerger ( GlobalChangeset.LoadFromFile (mergeConfigFile), targetDirs ); e.Merge (); return 0; } if (r != 0 || !show_gui) return r; SettingsHandler.CheckUpgrade (); Settings.RunningGUI = true; Application.Init (); Browser browser = new Browser (basedir, sources, engine); if (topic != null) browser.LoadUrl (topic); Thread in_thread = null; if (remote_mode) { in_thread = new Thread (delegate () { while (true) { string url = Console.ReadLine (); if (url == null) return; Gtk.Application.Invoke (delegate { browser.LoadUrl (url); browser.MainWindow.Present (); }); } }); in_thread.Start (); } Application.Run (); if (in_thread != null) in_thread.Abort (); return 0; }
static int Main(string [] args) { string topic = null; for (int i = 0; i < args.Length; i++){ switch (args [i]){ case "--html": if (i+1 == args.Length){ Console.WriteLine ("--html needed argument"); return 1; } Node n; RootTree help_tree = RootTree.LoadTree(); string res = help_tree.RenderUrl (args [i+1], out n); if (res != null){ Console.WriteLine (res); return 0; } else { return 1; } case "--make-index": RootTree.MakeIndex (); return 0; case "--help": Console.WriteLine ("Options are:\n"+ "browser [--html TOPIC] [--make-index] [TOPIC] [--merge-changes CHANGE_FILE TARGET_DIR+]"); return 0; case "--merge-changes": if (i+2 == args.Length) { Console.WriteLine ("--merge-changes 2+ args"); return 1; } ArrayList targetDirs = new ArrayList (); for (int j = i+2; j < args.Length; j++) targetDirs.Add (args [j]); EditMerger e = new EditMerger ( GlobalChangeset.LoadFromFile (args [i+1]), targetDirs ); e.Merge (); return 0; default: topic = args [i]; break; } } Settings.RunningGUI = true; DocumentBrowser browser = new DocumentBrowser (); browser.Run(); return 0; }