2 // The assembler: Help compiler.
5 // Miguel de Icaza (miguel@gnome.org)
7 // (C) 2003 Ximian, Inc.
10 using System.Collections.Generic;
16 namespace Mono.Documentation {
18 public class MDocAssembler : MDocCommand {
19 public override void Run (IEnumerable<string> args)
21 string[] validFormats = {
30 var formats = new Dictionary<string, List<string>> ();
31 string prefix = "tree";
32 string cur_format = "ecma";
33 var options = new OptionSet () {
35 "The documentation {FORMAT} used in DIRECTORIES. " +
36 "Valid formats include:\n " +
37 string.Join ("\n ", validFormats) + "\n" +
38 "If not specified, the default format is `ecma'.",
40 if (Array.IndexOf (validFormats, v) < 0)
41 Error ("Invalid documentation format: {0}.", v);
45 "Provides the output file prefix; the files {PREFIX}.zip and " +
46 "{PREFIX}.tree will be created.\n" +
47 "If not specified, `tree' is the default PREFIX.",
49 { "<>", v => AddFormat (formats, cur_format, v) },
51 List<string> extra = Parse (options, args, "assemble",
52 "[OPTIONS]+ DIRECTORIES",
53 "Assemble documentation within DIRECTORIES for use within the monodoc browser.");
57 List<Provider> list = new List<Provider> ();
58 EcmaProvider ecma = null;
61 foreach (string format in formats.Keys) {
65 ecma = new EcmaProvider ();
69 foreach (string dir in formats [format])
70 ecma.AddDirectory (dir);
75 list.AddRange (formats [format].Select (d => (Provider) new XhtmlProvider (d)));
79 list.Add (new ManProvider (formats [format].ToArray ()));
83 list.AddRange (formats [format].Select (d => (Provider) new SimpleProvider (d)));
87 list.AddRange (formats [format].Select (d => (Provider) new ErrorProvider (d)));
91 list.AddRange (formats [format].Select (d => (Provider) new EcmaSpecProvider (d)));
95 list.AddRange (formats [format].Select (d => (Provider) new AddinsProvider (d)));
100 HelpSource hs = new HelpSource (prefix, true);
101 hs.TraceLevel = TraceLevel;
103 foreach (Provider p in list) {
104 p.PopulateTree (hs.Tree);
111 // Flushes the EcmaProvider
113 foreach (Provider p in list)
114 p.CloseTree (hs, hs.Tree);
119 private void AddFormat (Dictionary<string, List<string>> d, string format, string file)
122 Error ("No format specified.");
124 if (!d.TryGetValue (format, out l)) {
125 l = new List<string> ();