public async Task RefreshDocumentationIndex(IDocumentationIndex documentationIndex) { int documentCountAfter = documentationIndex.DefaultProject.DocumentCount + documentationIndex.Projects.Sum(s => s.DocumentCount); _Logger.LogInformation($"Finalizing documentation index. {documentCountAfter} documents added."); DocumentationIndex = documentationIndex; await SetProjectDefaultDocuments(DocumentationIndex.DefaultProject); foreach (var project in DocumentationIndex.Projects) { await SetProjectDefaultDocuments(project); } var documentationDirectoryInfo = _Options.GetDocumentationFolderAsAbsolute(_HostingEnvironment.ContentRootPath); RemoteLiveDocsOptions remoteOptions = new RemoteLiveDocsOptions { ApplicationName = _Options.ApplicationName, Documents = _Options.Documents, Search = _Options.Search, Documentation = new RemoteDocumentationIndex(documentationIndex, documentationDirectoryInfo.FullName), Navigation = _Options.Navigation }; var json = JsonSerializer.Serialize(remoteOptions, new JsonSerializerOptions { IgnoreNullValues = true }); var navDocumentPath = Path.Combine(documentationDirectoryInfo.FullName, "app.json"); _Logger.LogInformation($"Saving {navDocumentPath}"); await File.WriteAllTextAsync(navDocumentPath, json); }
public async Task RefreshDocumentationIndex(IDocumentationIndex documentationIndex) { int documentCountAfter = documentationIndex.DefaultProject.DocumentCount + documentationIndex.Projects.Sum(s => s.DocumentCount); if (DocumentationIndex == null) { _Logger.LogInformation($"Initializing documentation index. {documentCountAfter} documents added."); } else { int documentToSkip = 1; // app.json if (_Options.Search?.Enabled ?? true) // Search is enabled by default. { documentToSkip += 1; // search.json } int documentCountBefore = DocumentationIndex.DefaultProject.DocumentCount + DocumentationIndex.Projects.Sum(s => s.DocumentCount); _Logger.LogInformation($"Refreshing documentation index. Before {documentCountBefore - documentToSkip}; After {documentCountAfter}."); } DocumentationIndex = documentationIndex; await SetProjectDefaultDocuments(DocumentationIndex.DefaultProject); foreach (var project in DocumentationIndex.Projects) { await SetProjectDefaultDocuments(project); } var documentationDirectoryInfo = _Options.GetDocumentationFolderAsAbsolute(_HostingEnvironment.ContentRootPath); RemoteLiveDocsOptions remoteOptions = new RemoteLiveDocsOptions { ApplicationName = _Options.ApplicationName, Documents = _Options.Documents, Search = _Options.Search, Documentation = new RemoteDocumentationIndex(documentationIndex, documentationDirectoryInfo.FullName), Navigation = _Options.Navigation }; var json = JsonSerializer.Serialize(remoteOptions, new JsonSerializerOptions { IgnoreNullValues = true }); var navDocumentPath = Path.Combine(documentationDirectoryInfo.FullName, "app.json"); await File.WriteAllTextAsync(navDocumentPath, json); documentationIndex.DefaultProject.Documents.Add(new GenericDocumentationDocument { Path = navDocumentPath, LastUpdate = DateTime.Now }); }