public static int Main (string [] args) { string output = "tree"; HelpSource hs; ArrayList list = new ArrayList (); EcmaProvider ecma = null; bool sort = false; int argc = args.Length; for (int i = 0; i < argc; i++){ string arg = args [i]; switch (arg){ case "-o": case "--out": if (i < argc) output = args [++i]; else { Usage (); return 1; } break; case "--ecma": if (i < argc){ if (ecma == null) { ecma = new EcmaProvider (); list.Add (ecma); sort = true; } ecma.AddDirectory (args [++i]); } else { Usage (); return 1; } break; case "--xhtml": case "--hb": if (i < argc){ Provider populator = new XhtmlProvider (args [++i]); list.Add (populator); } else { Usage (); return 1; } break; case "--man": if (i < argc){ int countfiles = args.Length - ++i; string[] xmlfiles = new String[countfiles]; for (int a = 0;a< countfiles;a++) { xmlfiles[a] = args [i]; i++; } Provider populator = new ManProvider (xmlfiles); list.Add (populator); } else { Usage (); return 1; } break; case "--simple": if (i < argc){ Provider populator = new SimpleProvider (args [++i]); list.Add (populator); } else { Usage (); return 1; } break; case "--error": if (i < argc){ Provider populator = new ErrorProvider (args [++i]); list.Add (populator); } else { Usage (); return 1; } break; case "--ecmaspec": if (i < argc){ Provider populator = new EcmaSpecProvider (args [++i]); list.Add (populator); } else { Usage (); return 1; } break; case "--addins": if (i < argc){ Provider populator = new AddinsProvider (args [++i]); list.Add (populator); } else { Usage (); return 1; } break; default: Usage (); return 1; } } hs = new HelpSource (output, true); foreach (Provider p in list){ p.PopulateTree (hs.Tree); } if (sort) hs.Tree.Sort (); // // Flushes the EcmaProvider // foreach (Provider p in list) p.CloseTree (hs, hs.Tree); hs.Save (); return 0; }
public static Provider GetProvider (string provider, params string[] basefilepaths) { switch (provider) { case "addins": return new AddinsProvider (basefilepaths [0]); case "ecma": { EcmaProvider p = new EcmaProvider (); foreach (string d in basefilepaths) p.AddDirectory (d); return p; } case "ecmaspec": return new EcmaSpecProvider (basefilepaths [0]); case "error": return new ErrorProvider (basefilepaths [0]); case "man": return new ManProvider (basefilepaths); case "simple": return new SimpleProvider (basefilepaths [0]); case "xhtml": case "hb": return new XhtmlProvider (basefilepaths [0]); default: throw new NotSupportedException (provider); } }
public override void Run (IEnumerable<string> args) { var formats = new Dictionary<string, List<string>> (); string prefix = "tree"; var formatOptions = CreateFormatOptions (this, formats); var options = new OptionSet () { formatOptions [0], { "o|out=", "Provides the output file prefix; the files {PREFIX}.zip and " + "{PREFIX}.tree will be created.\n" + "If not specified, `tree' is the default PREFIX.", v => prefix = v }, formatOptions [1], }; List<string> extra = Parse (options, args, "assemble", "[OPTIONS]+ DIRECTORIES", "Assemble documentation within DIRECTORIES for use within the monodoc browser."); if (extra == null) return; List<Provider> list = new List<Provider> (); EcmaProvider ecma = null; bool sort = false; foreach (string format in formats.Keys) { switch (format) { case "ecma": if (ecma == null) { ecma = new EcmaProvider (); list.Add (ecma); sort = true; } foreach (string dir in formats [format]) ecma.AddDirectory (dir); break; case "xhtml": case "hb": list.AddRange (formats [format].Select (d => (Provider) new XhtmlProvider (d))); break; case "man": list.Add (new ManProvider (formats [format].ToArray ())); break; case "simple": list.AddRange (formats [format].Select (d => (Provider) new SimpleProvider (d))); break; case "error": list.AddRange (formats [format].Select (d => (Provider) new ErrorProvider (d))); break; case "ecmaspec": list.AddRange (formats [format].Select (d => (Provider) new EcmaSpecProvider (d))); break; case "addins": list.AddRange (formats [format].Select (d => (Provider) new AddinsProvider (d))); break; } } HelpSource hs = new HelpSource (prefix, true); hs.TraceLevel = TraceLevel; foreach (Provider p in list) { p.PopulateTree (hs.Tree); } if (sort && hs.Tree != null) hs.Tree.Sort (); // // Flushes the EcmaProvider // foreach (Provider p in list) p.CloseTree (hs, hs.Tree); hs.Save (); }