Beispiel #1
0
        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);
        }
Beispiel #2
0
        public async Task RefreshSearchIndex(IDocumentationIndex documentationIndex)
        {
            if (!_Options.Search?.Enabled ?? false)
            {
                return;
            }

            var documentationDirectoryInfo = _Options.GetDocumentationFolderAsAbsolute(_HostingEnvironment.ContentRootPath);

            SearchIndex = new BasicSearchIndex(_SearchPipeline, documentationIndex, _Options, _Logger);
            await SearchIndex.BuildIndex();

            var json = JsonSerializer.Serialize((BasicSearchIndex)SearchIndex, new JsonSerializerOptions
            {
                IgnoreNullValues = true
            });
            var searchDocumentPath = Path.Combine(documentationDirectoryInfo.FullName, "search.json");
            await File.WriteAllTextAsync(searchDocumentPath, json);

            documentationIndex.DefaultProject.Documents.Add(new GenericDocumentationDocument
            {
                Path       = searchDocumentPath,
                LastUpdate = DateTime.Now
            });
        }
Beispiel #3
0
 public BasicSearchIndex(SearchPipeline searchPipeline, IDocumentationIndex documentationIndex, ILiveDocsOptions options, ILogger logger)
 {
     _SearchPipeline     = searchPipeline;
     _DocumentationIndex = documentationIndex;
     _Options            = options;
     _Logger             = logger;
 }
        public RemoteDocumentationIndex(IDocumentationIndex localDocumentationIndex, string documentationRootPath)
        {
            DefaultProject                  = new RemoteDocumentationProject();
            DefaultProject.Documents        = CopyDocuments(localDocumentationIndex.DefaultProject.Documents, documentationRootPath).ToList();
            DefaultProject.DefaultDocuments = CopyDocuments(localDocumentationIndex.DefaultProject.DefaultDocuments, documentationRootPath).ToList();
            if (localDocumentationIndex.DefaultProject.LandingPage != null)
            {
                DefaultProject.LandingPage = new RemoteDocumentationDocument
                {
                    Path       = localDocumentationIndex.DefaultProject.LandingPage.Path.Replace(documentationRootPath, "").Replace("\\", "/"),
                    LastUpdate = localDocumentationIndex.DefaultProject.LandingPage.LastUpdate
                };
            }

            Projects = new List <RemoteDocumentationProject>();
            foreach (var localProject in localDocumentationIndex.Projects)
            {
                RemoteDocumentationProject project = new RemoteDocumentationProject();
                project.Path             = localProject.Path.Replace(documentationRootPath, "").Replace("\\", "/");
                project.KeyPath          = localProject.KeyPath;
                project.Documents        = CopyDocuments(localProject.Documents, documentationRootPath).ToList();
                project.DefaultDocuments = CopyDocuments(localProject.DefaultDocuments, documentationRootPath).ToList();

                if (localProject.LandingPage != null)
                {
                    project.LandingPage = new RemoteDocumentationDocument
                    {
                        Path       = localProject.LandingPage.Path.Replace(documentationRootPath, "").Replace("\\", "/"),
                        LastUpdate = localProject.LandingPage.LastUpdate
                    };
                }

                Projects.Add(project);
            }
        }
Beispiel #5
0
        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
            });
        }
        public async Task RefreshSearchIndex(IDocumentationIndex documentationIndex)
        {
            if (SearchIndex != null)
            {
                return;
            }

            using (var scope = _Services.CreateScope())
            {
                var httpClient = scope.ServiceProvider.GetRequiredService <HttpClient>();
                var index      = await httpClient.GetFromJsonAsync <BasicSearchIndex>("search.json");

                var searchPipeline = scope.ServiceProvider.GetRequiredService <SearchPipeline>();
                var options        = scope.ServiceProvider.GetRequiredService <RemoteLiveDocsOptions>();
                index.Setup(searchPipeline, documentationIndex, options);
                SearchIndex = index;
            }
        }
        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 documentCountBefore = DocumentationIndex.DefaultProject.DocumentCount + DocumentationIndex.Projects.Sum(s => s.DocumentCount);
                _Logger.LogInformation($"Refreshing documentation index. Before {documentCountBefore}; After {documentCountAfter}.");
            }

            DocumentationIndex = documentationIndex;

            await SetProjectDefaultDocuments(DocumentationIndex.DefaultProject);

            foreach (var project in DocumentationIndex.Projects)
            {
                await SetProjectDefaultDocuments(project);
            }
        }
Beispiel #8
0
        public async Task RefreshSearchIndex(IDocumentationIndex documentationIndex)
        {
            if (!_Options.Search?.Enabled ?? false)
            {
                return;
            }

            _Logger.LogInformation("Building search index.");

            var documentationDirectoryInfo = _Options.GetDocumentationFolderAsAbsolute(_HostingEnvironment.ContentRootPath);

            SearchIndex = new BasicSearchIndex(_SearchPipeline, documentationIndex, _Options, _Logger);
            await SearchIndex.BuildIndex();

            var json = JsonSerializer.Serialize((BasicSearchIndex)SearchIndex, new JsonSerializerOptions
            {
                IgnoreNullValues = true
            });
            var searchDocumentPath = Path.Combine(documentationDirectoryInfo.FullName, "search.json");

            _Logger.LogInformation($"Saving {searchDocumentPath}");

            await File.WriteAllTextAsync(searchDocumentPath, json);
        }
 public Task RefreshDocumentationIndex(IDocumentationIndex documentationIndex)
 {
     DocumentationIndex = documentationIndex;
     return(Task.CompletedTask);
 }
 public async Task RefreshSearchIndex(IDocumentationIndex documentationIndex)
 {
     SearchIndex = new LuceneSearchIndex(documentationIndex);
     await SearchIndex.BuildIndex();
 }
Beispiel #11
0
 public LuceneSearchIndex(IDocumentationIndex documentationIndex)
 {
     DocumentationIndex = documentationIndex;
 }
Beispiel #12
0
 /// <summary>
 /// For setup post-deserialization
 /// </summary>
 /// <param name="searchPipeline"></param>
 /// <param name="documentationIndex"></param>
 public void Setup(SearchPipeline searchPipeline, IDocumentationIndex documentationIndex, ILiveDocsOptions options)
 {
     _SearchPipeline     = searchPipeline;
     _DocumentationIndex = documentationIndex;
     _Options            = options;
 }