private IEnumerable <CompilationResult> GenerateTableOfContentItems(string directory, string keyPrefix, string documentationVersion, CompilationUtils.Context context) { var docsFilePath = Path.Combine(directory, Constants.DocumentationFileName); if (File.Exists(docsFilePath) == false) { yield break; } foreach (var item in DocumentationFileHelper.ParseFile(docsFilePath)) { Validate(item, docsFilePath); var tableOfContentsItem = new CompilationResult { Key = keyPrefix + "/" + item.Name, Title = item.Description, IsFolder = item.IsFolder }; if (item.IsFolder) { var compilationResults = GenerateTableOfContentItems(Path.Combine(directory, item.Name), tableOfContentsItem.Key, documentationVersion, context).ToList(); tableOfContentsItem.Items = compilationResults; var supportedVersions = compilationResults.SelectMany(x => x.SupportedVersions); tableOfContentsItem.AddSupportedVersions(supportedVersions); } else { tableOfContentsItem.Languages = GetLanguagesForTableOfContentsItem(directory, item.Name).ToList(); if (MarkdownFileExists(directory, item)) { var supportedVersions = _versions.GetMinorVersionsInRange(documentationVersion, item.LastSupportedVersion); tableOfContentsItem.AddSupportedVersions(supportedVersions); tableOfContentsItem.SourceVersion = documentationVersion; } context.RegisterCompilation(new CompilationUtils.Context.RegistrationInput { Key = tableOfContentsItem.Key, Language = item.Language, DocumentationVersion = documentationVersion, LastSupportedVersion = item.LastSupportedVersion, SupportedVersions = tableOfContentsItem.SupportedVersions?.ToList() }); } yield return(tableOfContentsItem); } }