Exemple #1
0
        private void DoxygenHelperOnDoxygenRebuildingFinished()
        {
            _doxygenIsRebuilding = false;
            DoxygenHelper.DoxygenRebuildingFinished        -= DoxygenHelperOnDoxygenRebuildingFinished;
            DoxygenHelper.RebuildingDoxygenProgressChanged -= DoxygenHelperOnRebuildingDoxygenProgressChanged;

            DoxygenHelper.InvalidateDbCache();

            var shell = GetService(typeof(SVsUIShell)) as IVsUIShell;

            Debug.Assert(shell != null, "shell != null");

            shell.UpdateCommandUI(1);
        }
Exemple #2
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();
            }
        }
Exemple #3
0
        public UDNParsingResults(string path, ITextSnapshot snapshot, MarkdownPackage package, Markdown markdown, FolderDetails folderDetails)
        {
            var log = new OutputPaneLogger();

            ParsedSnapshot = snapshot;

            // Use the Publish Flag combo box to set the markdown details.
            markdown.PublishFlags.Clear();

            // Always include public
            markdown.PublishFlags.Add(Settings.Default.PublicAvailabilitiesString);

            foreach (var flagName in package.PublishFlags)
            {
                markdown.PublishFlags.Add(flagName);
            }

            Errors      = new List <ErrorDetail>();
            Images      = new List <ImageConversion>();
            Attachments = new List <AttachmentConversionDetail>();

            Document = markdown.ParseDocument(ParsedSnapshot.GetText(), Errors, Images, Attachments, folderDetails);

            DoxygenHelper.SetTrackedSymbols(Document.TransformationData.FoundDoxygenSymbols);

            CommonUnrealFunctions.CopyDocumentsImagesAndAttachments(
                path, log, folderDetails.AbsoluteHTMLPath, folderDetails.Language,
                folderDetails.CurrentFolderFromMarkdownAsTopLeaf, Images, Attachments);

            // Create common directories like css includes top level images etc.
            // Needs to be created everytime the document is generated to allow
            // changes to these files to show in the preview window without
            // restarting VS.
            CommonUnrealFunctions.CreateCommonDirectories(
                folderDetails.AbsoluteHTMLPath, folderDetails.AbsoluteMarkdownPath, log);
        }
        private string ParseInLineVariableOrMetadata(Match match, FileInfo currentFile, FileInfo originalScope, TransformationData data, EMDocument doc, Stack <Tuple <string, string> > visitedVariables)
        {
            var    pathToLinkedFile         = match.Groups["path"].Value;
            var    variableName             = match.Groups["variableName"].Value.ToLower();
            var    originalString           = match.Value;
            string relativePathToLinkedFile = null;

            var outString       = "";
            var isProblem       = false;
            var changedLanguage = false;

            var errorId = 0;
            var OnErrorStringToUseForMatch = originalString;

            //ignore if the value is STOPPUBLISH STARTPUBLISH
            if (variableName.Equals("STOPPUBLISH") || variableName.Equals("STARTPUBLISH") || originalString.ToUpper() == "%ROOT%" || VariableManager.IsKeywordToSkip(originalString))
            {
                return(originalString);
            }
            else
            {
                if (pathToLinkedFile.Equals("doxygen"))
                {
                    var excerptName = ("doxygen:" + match.Groups["variableName"].Value).Replace(':', 'x');

                    if (!doc.Excerpts.Exists(excerptName))
                    {
                        var content =
                            DoxygenHelper.GetSymbolDescriptionAndCatchExceptionIntoMarkdownErrors(
                                match.Groups["variableName"].Value,
                                match.Value,
                                DoxygenHelper.DescriptionType.Full,
                                data,
                                data.Markdown,
                                data.FoundDoxygenSymbols).Trim();

                        content = Normalizer.Normalize(content, null);

                        doc.Excerpts.AddExcerpt(
                            excerptName, new EMExcerpt(doc, 0, 0, content, data, excerptName == ""));
                    }

                    return(string.Format("[INCLUDE:#{0}]", excerptName));
                }
                if (pathToLinkedFile.Equals("orig"))
                {
                    currentFile = originalScope;
                    relativePathToLinkedFile = data.CurrentFolderDetails.CurrentFolderFromMarkdownAsTopLeaf;
                }
                else if (!String.IsNullOrWhiteSpace(pathToLinkedFile))
                {
                    // Link other file and get metadata from there.
                    var languageForFile = data.CurrentFolderDetails.Language;
                    relativePathToLinkedFile = pathToLinkedFile;

                    var linkedFileDir = new DirectoryInfo(Path.Combine(Path.Combine(data.CurrentFolderDetails.AbsoluteMarkdownPath, pathToLinkedFile)));

                    if (!linkedFileDir.Exists || linkedFileDir.GetFiles(string.Format("*.{0}.udn", data.CurrentFolderDetails.Language)).Length == 0)
                    {
                        // if this is not an INT file check for the INT version.
                        if (data.CurrentFolderDetails.Language != "INT")
                        {
                            if (!linkedFileDir.Exists || linkedFileDir.GetFiles("*.INT.udn").Length == 0)
                            {
                                errorId = data.ErrorList.Count;
                                data.ErrorList.Add(
                                    Markdown.GenerateError(
                                        Language.Message(
                                            "BadLinkOrMissingMarkdownFileAndNoINTFile", pathToLinkedFile, variableName),
                                        MessageClass.Error,
                                        Markdown.Unescape(OnErrorStringToUseForMatch),
                                        errorId,
                                        data));

                                isProblem = true;
                            }
                            else
                            {
                                // Found int file
                                languageForFile = "INT";

                                // Raise info so that now we are allowing missing linked files to still allow processing of the file if INT file is there
                                errorId = data.ErrorList.Count;
                                data.ErrorList.Add(
                                    Markdown.GenerateError(
                                        Language.Message(
                                            "BadLinkOrMissingMarkdownFileINTUsed", pathToLinkedFile, variableName),
                                        MessageClass.Info,
                                        Markdown.Unescape(OnErrorStringToUseForMatch),
                                        errorId,
                                        data));

                                isProblem = true;

                                changedLanguage = true;
                            }
                        }
                        else
                        {
                            errorId = data.ErrorList.Count;
                            data.ErrorList.Add(
                                Markdown.GenerateError(
                                    Language.Message("BadLinkOrMissingMarkdownFile", pathToLinkedFile, variableName),
                                    MessageClass.Error,
                                    Markdown.Unescape(OnErrorStringToUseForMatch),
                                    errorId,
                                    data));

                            isProblem = true;
                            outString = OnErrorStringToUseForMatch;
                        }
                    }

                    if (linkedFileDir.Exists && linkedFileDir.GetFiles(string.Format("*.{0}.udn", languageForFile)).Length > 0)
                    {
                        currentFile = linkedFileDir.GetFiles(string.Format("*.{0}.udn", languageForFile))[0];
                    }
                }

                // Cycle detection mechanism. First check if there was request for that variable in the visited stack.
                var currentVisitedVariableTuple = new Tuple <string, string>(currentFile.FullName, variableName);
                if (visitedVariables != null && visitedVariables.Contains(currentVisitedVariableTuple))
                {
                    // cycle detected
                    visitedVariables.Push(currentVisitedVariableTuple);
                    string visitedVariablesMessage = string.Join(", ", visitedVariables.Select(
                                                                     (v) =>
                    {
                        return(string.Format("[{0}, {1}]", v.Item1, v.Item2));
                    }));
                    visitedVariables.Pop();

                    data.ErrorList.Add(
                        Markdown.GenerateError(Language.Message("CycleDetectedInVariableRefs", visitedVariablesMessage), MessageClass.Error,
                                               "", data.ErrorList.Count, data));

                    return("");
                }

                if (!data.ProcessedDocumentCache.TryGetLinkedFileVariable(currentFile, variableName, out outString))
                {
                    if (doc.PerformStrictConversion())
                    {
                        //error
                        errorId = data.ErrorList.Count;
                        data.ErrorList.Add(
                            Markdown.GenerateError(
                                Language.Message("VariableOrMetadataNotFoundInFile", variableName, currentFile.FullName),
                                MessageClass.Error,
                                OnErrorStringToUseForMatch,
                                errorId,
                                data));

                        isProblem = true;
                    }
                    outString = OnErrorStringToUseForMatch.Replace("%", "&#37;");
                }
                else
                {
                    // If there was no request for this variable then push it.
                    visitedVariables.Push(currentVisitedVariableTuple);

                    outString = InLineVariableOrMetadata.Replace(
                        outString,
                        everyMatch =>
                        ParseInLineVariableOrMetadata(everyMatch, currentFile, originalScope, data, doc, visitedVariables));

                    // After parsing inner string pop visited variable from the stack.
                    visitedVariables.Pop();
                }

                if (changedLanguage)
                {
                    //If we had to replace the language with INT then update the linkText to include link to image of flag
                    outString += Templates.ImageFrame.Render(
                        Hash.FromAnonymousObject(
                            new
                    {
                        imageClass = "languageinline",
                        imagePath  = Path.Combine(
                            data.CurrentFolderDetails.RelativeHTMLPath,
                            "Include", "Images", "INT_flag.jpg")
                    }));
                }
            }

            if (data.Markdown.ThisIsPreview && isProblem)
            {
                return(Templates.ErrorHighlight.Render(
                           Hash.FromAnonymousObject(
                               new
                {
                    errorId = errorId,
                    errorText = outString
                })));
            }

            return(outString);
        }
        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);
            }
        }