예제 #1
0
        void RebuildDoxygen(object sender, EventArgs e)
        {
            Action <string, Exception> showExceptionBox = (reason, ex) =>
            {
                MessageBox.Show(reason + " The error was: " + ex.Message);
            };

            DirectoryInfo currentSourceDir;

            currentSourceDir = new DirectoryInfo(Path.GetDirectoryName(CurrentUDNDocView.SourceFilePath));

            while (currentSourceDir != null && currentSourceDir.Name != "Source")
            {
                currentSourceDir = currentSourceDir.Parent;
            }

            Debug.Assert(currentSourceDir != null, "currentSourceDir != null");
            Debug.Assert(currentSourceDir.Parent != null, "currentSourceDir.Parent != null");
            Debug.Assert(currentSourceDir.Parent.Parent != null, "currentSourceDir.Parent.Parent != null");

            var engineDir = currentSourceDir.Parent.Parent;
            var sourceDir = engineDir.GetDirectories("Source")[0];

            _doxygenIsRebuilding = true;
            DoxygenHelper.DoxygenRebuildingFinished        += DoxygenHelperOnDoxygenRebuildingFinished;
            DoxygenHelper.RebuildingDoxygenProgressChanged += DoxygenHelperOnRebuildingDoxygenProgressChanged;

            try
            {
                DoxygenHelper.DoxygenInputFilter = Path.Combine(
                    engineDir.FullName, "Binaries", "DotNET", "UnrealDocToolDoxygenInputFilter.exe");
                DoxygenHelper.RebuildCache(sourceDir.FullName, null, true);
            }
            catch (Exception ex)
            {
                if (!(ex is DoxygenHelper.DoxygenExecMissing) && !(ex is DoxygenHelper.InvalidDoxygenPath))
                {
                    showExceptionBox("Could not rebuild Doxygen database. Unhandled exception.", ex);
                    throw;
                }

                showExceptionBox("Could not rebuild Doxygen database.", ex);
                DoxygenHelperOnDoxygenRebuildingFinished();
            }
        }
        public static void RunUDNConversion(Configuration config, Logger log)
        {
            log.WriteToLog(Language.Message("UnrealDocToolStarted"));

            if (config.HelpFlag)
            {
                log.Info(config.ParamsManager.GetHelp());
                return;
            }

            ThisIsPreview = config.PreviewFlag;

            if (ThisIsPreview)
            {
                //output to a preview file
                OutputDirectory = Path.Combine(Path.GetTempPath(), "UDT");
            }

            ThisIsLogOnly = config.LogOnlyFlag;

            PublishFlags =
                config.PublishFlagsParam.ChosenStringOptions.Union(new string[] { PublicAvailabilityFlag }).ToArray();
            SubsetOfSupportedLanguages = config.LangParam.ChosenStringOptions;
            DefaultTemplate            = config.TemplateParam.Value;

            DoxygenHelper.DoxygenXmlPath = config.DoxygenCacheParam;

            switch (config.LogVerbosityParam.ChosenOption)
            {
            case LogVerbosity.Info:
                log.SetInfoVerbosityLogLevel();
                break;

            case LogVerbosity.Warn:
                log.SetWarnVerbosityLogLevel();
                break;

            case LogVerbosity.Error:
                log.SetErrorVerbosityLogLevel();
                break;
            }

            // The output directory in app.config is over-ridden with this value
            // make sure does not start with \ or / or end with them
            // strip ./ from start if there.
            if (!ThisIsPreview)
            {
                // Preview output temp directory take precedence.
                OutputDirectory = Regex.Replace(config.OutputParam.Value, @"(^\.[/|\\])?[\\|/]*(.*?)[\\|/]*$", "$2");
            }

            // The source directory in app.config is over-ridden with this value.
            SourceDirectory = Regex.Replace(config.SourceParam.Value, @"(^\.[/|\\])?[\\|/]*(.*?)[\\|/]*$", "$2");

            // If this path is set, then we should rebuild doxygen cache.
            if (!string.IsNullOrWhiteSpace(config.RebuildDoxygenCacheParam))
            {
                var engineDir = new DirectoryInfo(Path.Combine(SourceDirectory, "..", "..")).FullName;
                log.Info(Language.Message("RebuildingDoxygenCache"));
                DoxygenHelper.DoxygenExec        = new FileInfo(config.RebuildDoxygenCacheParam.Value);
                DoxygenHelper.DoxygenInputFilter = Path.Combine(
                    engineDir,
                    "Binaries",
                    "DotNET",
                    "UnrealDocToolDoxygenInputFilter.exe");
                DoxygenHelper.RebuildCache(
                    Path.Combine(engineDir, "Source"), (sender, eventArgs) => log.Info(eventArgs.Data));
                return;
            }

            // If running clean really only need the SourceDirectory value.
            if (config.CleanFlag)
            {
                if (SourceDirectory == "")
                {
                    throw new ParsingErrorException(null, Language.Message("NoOutputDir"));
                }
            }
            else
            {
                if (OutputDirectory == "" || SourceDirectory == "")
                {
                    throw new ParsingErrorException(null, Language.Message("NoOutputOrSourceDir"));
                }

                //If the OutputDirectory is relative then find absolute path
                if (Regex.IsMatch(OutputDirectory, @"\.[/|\\]"))
                {
                    string tempOutputDirectory =
                        (new Uri(Path.GetDirectoryName(Assembly.GetAssembly(typeof(UnrealDocTool)).CodeBase))).LocalPath;
                    while (OutputDirectory.StartsWith(".."))
                    {
                        tempOutputDirectory = Directory.GetParent(tempOutputDirectory).FullName;
                        OutputDirectory     = Regex.Replace(OutputDirectory, @"^\.\.[/|\\](.*)", "$1");
                    }

                    OutputDirectory = (new DirectoryInfo(Path.Combine(tempOutputDirectory, OutputDirectory))).FullName;
                }

                //If the SourceDirectory is relative then find absolute path
                if (Regex.IsMatch(SourceDirectory, @"\.[/|\\]"))
                {
                    string tempSourceDirectory =
                        (new Uri(Path.GetDirectoryName(Assembly.GetAssembly(typeof(UnrealDocTool)).CodeBase))).LocalPath;
                    while (SourceDirectory.StartsWith(".."))
                    {
                        tempSourceDirectory = Directory.GetParent(tempSourceDirectory).FullName;
                        SourceDirectory     = Regex.Replace(SourceDirectory, @"^\.\.[/|\\](.*)", "$1");
                    }

                    SourceDirectory =
                        CaseSensitivePath(new DirectoryInfo(Path.Combine(tempSourceDirectory, SourceDirectory)));
                }
            }

            // Delete previously created temp folder.
            if (Directory.Exists(Path.Combine(Path.GetTempPath(), "UDT")))
            {
                DeleteDirRecursive(Path.Combine(Path.GetTempPath(), "UDT"));
            }

            if (config.CleanFlag)
            {
                log.Info(Language.Message("CleaningDuplicateLanguageImageFilesAndRecursing", SourceDirectory));
                CleanImagesRecursiveDirectory(SourceDirectory);
                log.Info(Language.Message("CleaningMetadataFromFileInDirAndRecursing", SourceDirectory));
                CleanMetaDataRecursiveDirectory(SourceDirectory);
            }
            else if (ThisIsLogOnly || InitialDirectoryChecksOk())
            {
                RunMarkdownConversion(config.PathsSpec, config, new MarkdownSharp.Markdown(), log);
            }
        }