private static int MainImpl(string[] args) { if (args.Length != 1) { throw new UserErrorException("Please specify the API name"); } string api = args[0]; var layout = DirectoryLayout.FromApi(api); string output = layout.DocsOutputDirectory; if (Directory.Exists(output)) { Directory.Delete(output, true); } Directory.CreateDirectory(output); var apiDirectory = layout.ApiSourceDirectory; var projects = Project.LoadProjects(apiDirectory).ToList(); CreateDocfxJson(api, projects, output); CopyAndGenerateArticles(api, layout.ApiDocsSourceDirectory, output); CreateToc(api, output); return(0); }
private static int MainImpl(string[] args) { if (args.Length != 1) { throw new UserErrorException("Please specify the API name as the sole argument"); } string api = args[0]; var layout = DirectoryLayout.FromApi(api); string snippetsSource = Directory.GetDirectories(layout.ApiSourceDirectory, "*.Snippets").FirstOrDefault(); if (snippetsSource == null) { throw new UserErrorException($"Unable to find snippets within API. Aborting."); } string output = layout.SnippetOutputDirectory; if (!Directory.Exists(output)) { Directory.CreateDirectory(output); } else { foreach (var file in Directory.GetFiles(output)) { File.Delete(file); } } var memberLookup = LoadMembersByType(layout.ApiMetadataDirectory); Console.WriteLine($"Loaded {memberLookup.Count} types with {memberLookup.Sum(x => x.Count())} members"); List <string> errors = new List <string>(); var snippets = LoadAllSnippets(snippetsSource, errors); Console.WriteLine($"Loaded {snippets.Sum(x => x.Count())} snippets"); foreach (var entry in snippets) { string snippetFile = entry.Key + ".txt"; GenerateSnippetText(Path.Combine(output, snippetFile), entry); MapMetadataUids(entry, memberLookup[entry.Key], errors); GenerateSnippetMarkdown(Path.Combine(output, entry.Key + ".md"), snippetFile, entry); } if (errors.Any()) { foreach (var error in errors) { Console.Error.WriteLine(error); } return(1); } return(0); }
private static int MainImpl(string[] args) { if (args.Length == 0 || args.Length > 2) { ThrowUsageError(); } string api = args[0]; bool generateReport = false; string reportFile = null; if (args.Length == 2) { generateReport = true; string reportArg = args[1]; if (!reportArg.StartsWith("--report")) { ThrowUsageError(); } if (reportArg != "--report") { if (!reportArg.StartsWith("--report=")) { ThrowUsageError(); } reportFile = reportArg.Substring("--report=".Length); } } var layout = DirectoryLayout.FromApi(api); string snippetsSource = Directory.GetDirectories(layout.ApiSourceDirectory, "*.Snippets").FirstOrDefault(); if (snippetsSource == null) { throw new UserErrorException($"Unable to find snippets within API. Aborting."); } string output = layout.SnippetOutputDirectory; if (!Directory.Exists(output)) { Directory.CreateDirectory(output); } else { foreach (var file in Directory.GetFiles(output)) { File.Delete(file); } } var memberLookup = LoadMembersByType(layout.ApiMetadataDirectory); Console.WriteLine($"Loaded {memberLookup.Count} types with {memberLookup.Sum(x => x.Count())} members"); List <string> errors = new List <string>(); var snippets = LoadAllSnippets(snippetsSource, errors); Console.WriteLine($"Loaded {snippets.Sum(x => x.Count())} snippets"); foreach (var entry in snippets) { string snippetFile = entry.Key + ".txt"; GenerateSnippetText(Path.Combine(output, snippetFile), entry); MapSnippetMetadataUids(entry, memberLookup[entry.Key], errors); GenerateSnippetMarkdown(Path.Combine(output, entry.Key + ".md"), snippetFile, entry); } var seeAlsos = LoadAllSeeAlsos(snippetsSource, errors); Console.WriteLine($"Loaded {seeAlsos.Sum(x => x.Count())} see-alsos"); foreach (var entry in seeAlsos) { MapSeeAlsoMetadataUids(entry, memberLookup, entry.Key, errors); GenerateSeeAlsoMarkdown(Path.Combine(output, entry.Key + ".md"), entry); } ValidateSeeAlsos(seeAlsos.SelectMany(x => x), snippets.SelectMany(x => x), errors); if (errors.Any()) { foreach (var error in errors) { Console.Error.WriteLine(error); } return(1); } if (generateReport) { using (var writer = reportFile == null ? Console.Out : File.CreateText(reportFile)) { GenerateReport(memberLookup, snippets, seeAlsos, writer); } } return(0); }