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);
        }
        public TransformationData(Markdown markdown, List<ErrorDetail> errorList, List<ImageConversion> imageDetails,
            List<AttachmentConversionDetail> attachNames, FolderDetails currentFolderDetails, IEnumerable<string> languagesLinksToGenerate = null, bool nonDynamicHTMLOutput = false)
        {
            NonDynamicHTMLOutput = nonDynamicHTMLOutput;
            AttachNames = attachNames;
            CurrentFolderDetails = new FolderDetails(currentFolderDetails);
            ErrorList = errorList;
            ImageDetails = imageDetails;
            LanguagesLinksToGenerate = languagesLinksToGenerate ?? markdown.SupportedLanguages;

            HtmlBlocks = new Dictionary<string, string>();
            FoundDoxygenSymbols = new HashSet<string>();
            Markdown = markdown;

            processedDocumentCache = new ProcessedDocumentCache(currentFolderDetails.GetThisFileName(), this);
        }
        public static string TestCase(string inputFileName, List<ErrorDetail> errorList = null)
        {
            var errors = errorList ?? new List<ErrorDetail>();

            var targetFileName = GetTargetFileName(inputFileName);
            var sourceDirectory = Regex.Replace(Settings.Default.SourceDirectory, @"(^\.[/|\\])?[\\|/]*(.*?)[\\|/]*$", "$2");
            var outputDirectory = Regex.Replace(Settings.Default.OutputDirectory, @"(^\.[/|\\])?[\\|/]*(.*?)[\\|/]*$", "$2");

            Language.LangID = "INT";

            Language.Init(
                Path.Combine(sourceDirectory, Settings.Default.IncludeDirectory, Settings.Default.InternationalizationDirectory));

            var markdown = new Markdown();

            Markdown.MetadataErrorIfMissing = Settings.Default.MetadataErrorIfMissing.Split(',');
            Markdown.MetadataInfoIfMissing = Settings.Default.MetadataInfoIfMissing.Split(',');
            markdown.PublishFlags = new List<string>() { "Licensee", "Public" };
            markdown.AllSupportedAvailability =
                (Settings.Default.SupportedAvailability + ",Public").ToLower().Split(',').ToList();

            markdown.DoNotPublishAvailabilityFlag = "NoPublish";

            markdown.DefaultTemplate = Settings.Default.DefaultTemplate;

            markdown.ThisIsPreview = false;

            markdown.SupportedLanguages = Settings.Default.SupportedLanguages.ToUpper().Split(',');

            //Pass the default conversion settings to Markdown for use in the imagedetails creation.
            markdown.DefaultImageDoCompress = Settings.Default.DoCompressImages;
            markdown.DefaultImageFormatExtension = Settings.Default.CompressImageType;
            markdown.DefaultImageFillColor = ImageConversion.GetColorFromHexString(Settings.Default.ImageFillColor);
            markdown.DefaultImageFormat = ImageConversion.GetImageFormat(Settings.Default.CompressImageType);
            markdown.DefaultImageQuality = Settings.Default.ImageJPGCompressionValue;

            var imageDetails = new List<ImageConversion>();
            var attachNames = new List<AttachmentConversionDetail>();
            var languagesLinksToGenerate = new[] { "INT " };

            var fileOutputDirectory =
                (new DirectoryInfo(inputFileName).Parent).FullName.Replace(
                    sourceDirectory + Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), "")
                                                         .Replace(sourceDirectory, "");

            var currentFolderDetails = new FolderDetails(
                GetRelativeHTMLPath(targetFileName, outputDirectory),
                new DirectoryInfo(outputDirectory).FullName,
                new DirectoryInfo(sourceDirectory).FullName,
                "Temp",
                "API",
                (new DirectoryInfo(inputFileName).Parent).FullName.Replace(
                    sourceDirectory + Path.DirectorySeparatorChar.ToString(), "")
                                                         .Replace(sourceDirectory, "")
                                                         .Replace(Path.DirectorySeparatorChar.ToString(), " - "),
                GetLanguage(inputFileName));

            var text = File.ReadAllText(inputFileName);

            var actual = markdown.Transform(
                text, errors, imageDetails, attachNames, currentFolderDetails, languagesLinksToGenerate);

            return actual;
        }
        //Setup defaults and file values for this documents markdown transform
        private void markdownTransformSetup(string FileName, Markdown markdownTransform, FolderDetails CurrentFolderDetails)
        {
            DirectoryInfo SourceDirectoryInfo = new DirectoryInfo(FileName).Parent;

            //Source directory path is found using the SourceDirectoryName setting and the file
            while (SourceDirectoryInfo != null && SourceDirectoryInfo.Name != Settings.Default.SourceDirectoryName)
            {
                SourceDirectoryInfo = SourceDirectoryInfo.Parent;
            }

            if (SourceDirectoryInfo != null)
            {
                string SourceDirectory = SourceDirectoryInfo.FullName;

                string OutputDirectory = Path.Combine(Path.GetTempPath(), "UDTMarkdownMode") + "/";


                string FileOutputDirectory = (new DirectoryInfo(FileName).Parent).FullName.Replace(SourceDirectory + Path.DirectorySeparatorChar, "").Replace(SourceDirectory, "");

                CurrentFolderDetails.RelativeHTMLPath = OutputDirectory.Replace(@"C:\", @"file://127.0.0.1/c$/");
                CurrentFolderDetails.AbsoluteHTMLPath = OutputDirectory;
                CurrentFolderDetails.AbsoluteMarkdownPath = SourceDirectory;
                CurrentFolderDetails.CurrentFolderFromMarkdownAsTopLeaf = FileOutputDirectory;
                CurrentFolderDetails.DocumentTitle = (new DirectoryInfo(FileName).Parent).FullName.Replace(SourceDirectory + Path.DirectorySeparatorChar.ToString(), "").Replace(SourceDirectory, "").Replace(Path.DirectorySeparatorChar.ToString(), " - ");
                CurrentFolderDetails.Language = Regex.Replace(Path.GetFileNameWithoutExtension(FileName).ToUpper(), @"[^\.]*?\.(.*$)", "$1");
                CurrentFolderDetails.APIFolderLocationFromMarkdownAsTop = Settings.Default.APIFolderLocation;

                Language.Init(Path.Combine(CurrentFolderDetails.AbsoluteMarkdownPath, "Include", "Internationalization"));

                DoxygenHelper.DoxygenInputFilter =
                    new FileInfo(
                        Path.Combine(
                            CurrentFolderDetails.AbsoluteMarkdownPath,
                            "..",
                            "..",
                            "Binaries",
                            "DotNET",
                            "UnrealDocToolDoxygenInputFilter.exe")).FullName;

                if (CurrentFolderDetails.Language != "INT")
                {
                    CurrentFolderDetails.DocumentTitle += " - " + CurrentFolderDetails.Language;
                }
                CurrentFolderDetails.DocumentTitle += " - " + Language.Message("Preview");

                Markdown.MetadataErrorIfMissing = Settings.MetadataErrorIfMissing;
                Markdown.MetadataInfoIfMissing = Settings.MetadataInfoIfMissing;

                markdownTransform.DefaultTemplate = Settings.Default.DefaultTemplate;

                markdownTransform.ThisIsPreview = true;

                markdownTransform.SupportedLanguages = Settings.SupportedLanguages;
                markdownTransform.SupportedLanguageLabels = Settings.SupportedLanguageLabels;
                for (int i = 0; i < markdownTransform.SupportedLanguages.Length; i++)
                {
                    if (!markdownTransform.SupportedLanguageMap.ContainsKey(markdownTransform.SupportedLanguages[i]))
                    {
                        markdownTransform.SupportedLanguageMap.Add(markdownTransform.SupportedLanguages[i], markdownTransform.SupportedLanguageLabels[i]);
                    }
                }

                markdownTransform.AllSupportedAvailability = new List<string>();
                foreach (string Availablity in Settings.SupportedAvailabilities)
                {
                    markdownTransform.AllSupportedAvailability.Add(Availablity);
                }
                //Add public into list
                markdownTransform.AllSupportedAvailability.Add(Settings.Default.PublicAvailabilitiesString);

                markdownTransform.PublishFlags = new List<string>();
                markdownTransform.DoNotPublishAvailabilityFlag = Settings.Default.DoNotPublishAvailabilitiesFlag.ToLower();

                //Pass the default conversion settings to Markdown for use in the imagedetails creation.
                markdownTransform.DefaultImageDoCompress = Settings.Default.DoCompressImages;
                markdownTransform.DefaultImageFormatExtension = Settings.Default.CompressImageType;
                markdownTransform.DefaultImageFillColor = Settings.DefaultImageFillColor;
                markdownTransform.DefaultImageFormat = ImageConversion.GetImageFormat(Settings.Default.CompressImageType);
                markdownTransform.DefaultImageQuality = Settings.Default.JpegCompressionRate;
            }
        }
Example #5
0
        static ConvertFileResponse ConvertFile(MarkdownSharp.Markdown markdownToHtml, string inputFileName, string language, IEnumerable<string> languagesLinksToGenerate, OutputFormat format = OutputFormat.HTML)
        {
            var result = ConvertFileResponse.NoChange;
            var targetFileName = GetTargetFileName(inputFileName, language);

            //Set up parameters in Markdown to aid in processing and generating html
            Markdown.MetadataErrorIfMissing = MetadataErrorIfMissing;
            Markdown.MetadataInfoIfMissing = MetadataInfoIfMissing;
            markdownToHtml.DoNotPublishAvailabilityFlag = Settings.Default.DoNotPublishAvailabilityFlag;
            markdownToHtml.PublishFlags = PublishFlags.ToList();
            markdownToHtml.AllSupportedAvailability = AllSupportedAvailability;

            var fileOutputDirectory = FileHelper.GetRelativePath(
                SourceDirectory, Path.GetDirectoryName(inputFileName));

            var currentFolderDetails = new FolderDetails(
                GetRelativeHTMLPath(targetFileName), OutputDirectory, SourceDirectory, fileOutputDirectory,
                Settings.Default.APIFolderLocation,
                (new DirectoryInfo(inputFileName).Parent).FullName.Replace(
                    SourceDirectory + Path.DirectorySeparatorChar.ToString(), "")
                                                         .Replace(SourceDirectory, "")
                                                         .Replace(Path.DirectorySeparatorChar.ToString(), " - "),
                language);

            markdownToHtml.DefaultTemplate = DefaultTemplate;

            markdownToHtml.ThisIsPreview = ThisIsPreview;

            if (language != "INT")
            {
                currentFolderDetails.DocumentTitle += " - " + language;
            }

            if (ThisIsPreview)
            {
                currentFolderDetails.DocumentTitle += " - PREVIEW!";
            }

            markdownToHtml.SupportedLanguages = SupportedLanguages;

            //Pass the default conversion settings to Markdown for use in the image details creation.
            markdownToHtml.DefaultImageDoCompress = DoCompressImages;
            markdownToHtml.DefaultImageFormatExtension = CompressImageType;
            markdownToHtml.DefaultImageFillColor = DefaultImageFillColor;
            markdownToHtml.DefaultImageFormat = CompressImageFormat;
            markdownToHtml.DefaultImageQuality = JpegCompressionRate;

            var errorList = new List<ErrorDetail>();
            var imageDetails = new List<ImageConversion>();
            var attachNames = new List<AttachmentConversionDetail>();

            var output = markdownToHtml.Transform(FileContents(inputFileName), errorList, imageDetails, attachNames, currentFolderDetails, languagesLinksToGenerate, format != OutputFormat.HTML);

            var noFailedErrorReport = true;
            var stopProcessing = false;

            //If output empty then treat as failed, we are not converting most likely due to the publish flags and availability settings
            if (String.IsNullOrWhiteSpace(output))
            {
                noFailedErrorReport = false;
                stopProcessing = true;
                result = ConvertFileResponse.NoChange;
                log.Info(MarkdownSharp.Language.Message("NotConverted", inputFileName));
            }
            else
            {
                //Need to check for error types prior to processing to output log messages in the correct order.
                foreach (var errorInfo in errorList)
                {
                    if (errorInfo.ClassOfMessage == MessageClass.Error || errorInfo.ClassOfMessage == MessageClass.Warning)
                    {
                        log.Info(MarkdownSharp.Language.Message("FileFailed", inputFileName));
                        noFailedErrorReport = false;
                        break;
                    }
                }
            }

            if (noFailedErrorReport)
            {
                log.Info(MarkdownSharp.Language.Message("Converted", inputFileName));
            }

            //On warnings or errors stop processing the file to the publish folder but allow to continue if in preview.
            if (errorList.Count > 0)
            {
                Console.Write("\n");

                foreach (MarkdownSharp.ErrorDetail ErrorInfo in errorList)
                {
                    switch (ErrorInfo.ClassOfMessage)
                    {
                        case MarkdownSharp.MessageClass.Error:
                            log.Error(ErrorInfo.Path ?? inputFileName, ErrorInfo.Line, ErrorInfo.Column, ErrorInfo.Message);
                            if (!ThisIsPreview)
                            {
                                stopProcessing = true;
                                result = ConvertFileResponse.Failed;
                            }
                            break;
                        case MarkdownSharp.MessageClass.Warning:
                            log.Warn(ErrorInfo.Path ?? inputFileName, ErrorInfo.Line, ErrorInfo.Column, ErrorInfo.Message);
                            if (!ThisIsPreview)
                            {
                                stopProcessing = true;
                                result = ConvertFileResponse.Failed;
                            }
                            break;
                        default:
                            log.Info(ErrorInfo.Path ?? inputFileName, ErrorInfo.Line, ErrorInfo.Column, ErrorInfo.Message);
                            break;
                    }
                }
            }

            if (!stopProcessing)
            {
                if (ThisIsPreview || !ThisIsLogOnly)
                {
                    CommonUnrealFunctions.CopyDocumentsImagesAndAttachments(inputFileName, log, OutputDirectory, language, fileOutputDirectory, imageDetails, attachNames);
                }

                var expected = FileContents(targetFileName);

                if (output == expected)
                {
                    result = ConvertFileResponse.NoChange;
                }
                else
                {
                    if (!stopProcessing)
                    {
                        if (!AlreadyCreatedCommonDirectories)
                        {
                            AlreadyCreatedCommonDirectories = CommonUnrealFunctions.CreateCommonDirectories(OutputDirectory, SourceDirectory, log);
                        }

                        Console.Write("\n");
                        if (ThisIsPreview || !ThisIsLogOnly)
                        {
                            //Check output directory exists, if not create the full html structure for this language
                            CommonUnrealFunctions.GenerateDocsFolderStructure(OutputDirectory, fileOutputDirectory, language);

                            CommonUnrealFunctions.SetFileAttributeForReplace(new FileInfo(targetFileName));
                            File.WriteAllText(targetFileName, output);

                            if (format == OutputFormat.PDF)
                            {
                                PdfHelper.CreatePdfFromHtml(targetFileName);
                            }
                        }

                        result = ConvertFileResponse.Converted;
                    }
                }
            }
            return result;
        }
Example #6
0
 public EMDocument ParseDocument(
     string text,
     List<ErrorDetail> errorList,
     List<ImageConversion> imageDetails,
     List<AttachmentConversionDetail> attachNames,
     FolderDetails currentFolderDetails,
     IEnumerable<string> languagesLinksToGenerate = null)
 {
     return ParseDocument(
         text, new TransformationData(
             this, errorList, imageDetails, attachNames, currentFolderDetails, languagesLinksToGenerate));
 }
Example #7
0
        public string Transform(string text, List<ErrorDetail> ErrorList, List<ImageConversion> ImageDetails, List<AttachmentConversionDetail> AttachNames, FolderDetails CurrentFolderDetails, IEnumerable<string> LanguagesLinksToGenerate = null, bool nonDynamicHTMLOutput = false)
        {
            Setup();

            using (
                var td = new TransformationData(
                    this, ErrorList, ImageDetails, AttachNames, CurrentFolderDetails, LanguagesLinksToGenerate, nonDynamicHTMLOutput))
            {
                return Transform(text, td);
            }
        }
Example #8
0
        public FolderDetails(FolderDetails folderDetails)
            : this(folderDetails.RelativeHTMLPath, folderDetails.AbsoluteHTMLPath, folderDetails.AbsoluteMarkdownPath,
                folderDetails.CurrentFolderFromMarkdownAsTopLeaf, folderDetails.APIFolderLocationFromMarkdownAsTop,
                folderDetails.DocumentTitle, folderDetails.Language)
        {

        }