public override void Run(IEnumerable <string> args)
        {
            var    validFormats = RootTree.GetSupportedFormats();
            string cur_format   = "";
            var    formats      = new Dictionary <string, List <string> > ();
            var    options      = new OptionSet()
            {
                { "f|format=",
                  "The documentation {FORMAT} used in FILES.  " +
                  "Valid formats include:\n  " +
                  string.Join("\n  ", validFormats) + "\n" +
                  "If not specified, no HelpSource is used.  This may " +
                  "impact the PublicUrls displayed for nodes.",
                  v =>
                  {
                      if (Array.IndexOf(validFormats, v) < 0)
                      {
                          Error("Invalid documentation format: {0}.", v);
                      }
                      cur_format = v;
                  } },
                { "<>", v => AddFormat(formats, cur_format, v) },
            };
            List <string> files = Parse(options, args, "dump-tree",
                                        "[OPTIONS]+ FILES",
                                        "Print out the nodes within the assembled .tree FILES,\n" +
                                        "as produced by 'mdoc assemble'.");

            if (files == null)
            {
                return;
            }

            foreach (string format in formats.Keys)
            {
                foreach (string file in formats[format])
                {
                    HelpSource hs = format == ""
                                ? null
                                : RootTree.GetHelpSource(format, file.Replace(".tree", ""));
                    Tree t = new Tree(hs, file);
                    Node.PrintTree(t);
                }
            }
        }
Example #2
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);
                }
            }
        }