Example #1
0
        /// <summary>
        /// Verifies that all markdown links inside the documentation are valid. Prints warnings
        /// to the console for any invalid links. Also checks for orphaned documents.
        /// </summary>
        /// <param name="options"></param>
        /// <param name="docs"></param>
        private static async Task <bool> CheckLinksAsync(DocSetOptions options, DocSet docs = null)
        {
            const string testName = "Check-links";
            var          docset   = docs ?? await GetDocSetAsync(options);

            if (null == docset)
            {
                return(false);
            }


            TestReport.StartTest(testName);

            ValidationError[] errors;
            docset.ValidateLinks(options.EnableVerboseOutput, out errors);

            foreach (var error in errors)
            {
                MessageCategory category;
                if (error.IsWarning)
                {
                    category = MessageCategory.Warning;
                }
                else if (error.IsError)
                {
                    category = MessageCategory.Error;
                }
                else
                {
                    category = MessageCategory.Information;
                }

                string message = string.Format("{1}: {0}", error.Message.FirstLineOnly(), error.Code);
                await TestReport.LogMessageAsync(message, category);
            }

            return(await WriteOutErrorsAndFinishTestAsync(errors, options.SilenceWarnings, successMessage : "No link errors detected.", testName : testName));
        }