Example #1
0
        void ProcessFiles(Options opts, string format, List <string> files)
        {
            foreach (var basePath in
                     files.Select(f =>
                                  Path.Combine(Path.GetDirectoryName(f), Path.GetFileNameWithoutExtension(f)))
                     .Distinct())
            {
                string treeFile = basePath + ".tree";
                string zipFile  = basePath + ".zip";
                if (!Exists(treeFile) || !Exists(zipFile))
                {
                    continue;
                }
                string outDir = opts.OutputDirectory != null
                                        ? Path.Combine(opts.OutputDirectory, Path.GetFileName(basePath))
                                        : XmlDocUtils.GetCacheDirectory(basePath);

                if (!opts.ForceUpdate && Directory.Exists(outDir) &&
                    MaxWriteTime(treeFile, zipFile) < Directory.GetLastWriteTime(outDir))
                {
                    continue;
                }
                Message(TraceLevel.Warning, "Processing files: {0}, {1}", treeFile, zipFile);
                Directory.CreateDirectory(outDir);
                ExtractZipFile(zipFile, outDir);
                GenerateCache(opts, basePath, format, outDir);
            }
        }
Example #2
0
        public override void Run(IEnumerable <string> args)
        {
            string dir         = null;
            bool   forceUpdate = false;
            var    options     = new OptionSet()
            {
                { "force-update",
                  "Always generate new files.  If not specified, will only generate " +
                  "files if the write time of the output directory is older than the " +
                  "write time of the source .tree/.zip files.",
                  v => forceUpdate = v != null },
                { "o|out=",
                  "The {PREFIX} to place the generated files and directories.  " +
                  "Default: \"`dirname FILE`/cache/\".\n" +
                  "Underneath {PREFIX}, `basename FILE .tree` directories will be " +
                  "created which will contain the pre-generated HTML content.",
                  v => dir = v },
            };
            List <string> files = Parse(options, args, "export-html-webdoc",
                                        "[OPTIONS]+ FILES",
                                        "Export mdoc documentation within FILES to HTML for use by ASP.NET webdoc.\n\n" +
                                        "FILES are .tree or .zip files as produced by 'mdoc assemble'.");

            if (files == null)
            {
                return;
            }
            if (files.Count == 0)
            {
                Error("No files specified.");
            }
            HelpSource.use_css  = true;
            HelpSource.FullHtml = false;
            SettingsHandler.Settings.EnableEditing = false;
            foreach (var basePath in
                     files.Select(f =>
                                  Path.Combine(Path.GetDirectoryName(f), Path.GetFileNameWithoutExtension(f)))
                     .Distinct())
            {
                string treeFile = basePath + ".tree";
                string zipFile  = basePath + ".zip";
                if (!Exists(treeFile) || !Exists(zipFile))
                {
                    continue;
                }
                string outDir = dir != null
                                        ? Path.Combine(dir, Path.GetFileName(basePath))
                                        : XmlDocUtils.GetCacheDirectory(basePath);

                if (!forceUpdate && Directory.Exists(outDir) &&
                    MaxWriteTime(treeFile, zipFile) < Directory.GetLastWriteTime(outDir))
                {
                    continue;
                }
                Message(TraceLevel.Warning, "Processing files: {0}, {1}", treeFile, zipFile);
                Directory.CreateDirectory(outDir);
                ExtractZipFile(zipFile, outDir);
                GenerateCache(basePath, treeFile, outDir);
            }
        }