diff --git a/src/Elastic.Documentation.Configuration/Toc/DocumentationSetFile.cs b/src/Elastic.Documentation.Configuration/Toc/DocumentationSetFile.cs index 47d3b342d8..2087fd40f9 100644 --- a/src/Elastic.Documentation.Configuration/Toc/DocumentationSetFile.cs +++ b/src/Elastic.Documentation.Configuration/Toc/DocumentationSetFile.cs @@ -368,25 +368,6 @@ private static TableOfContents ResolveTableOfContents( var tocYaml = fileSystem.File.ReadAllText(tocFilePath); var nestedTocFile = TableOfContentsFile.Deserialize(tocYaml, collector, tocFilePath); - // this is temporary after this lands in main we can update these files to include - // suppress: - // - DeepLinkingVirtualFile - string[] skip = - [ - "docs-content/solutions/toc.yml", - "docs-content/manage-data/toc.yml", - "docs-content/explore-analyze/toc.yml", - "docs-content/deploy-manage/toc.yml", - "docs-content/troubleshoot/toc.yml", - "docs-content/troubleshoot/ingest/opentelemetry/toc.yml", - "docs-content/reference/security/toc.yml" - ]; - - var path = tocFilePath.OptionalWindowsReplace(); - // Hardcode suppression for known problematic files - if (skip.Any(f => path.Contains(f, StringComparison.OrdinalIgnoreCase))) - _ = nestedTocFile.SuppressDiagnostics.Add(HintType.DeepLinkingVirtualFile); - // Recursively resolve children with the FULL TOC path as the parent path // This ensures all file paths within the TOC include the TOC directory path // The context for children is the toc.yml file that defines them diff --git a/tests/Navigation.Tests/Isolation/ValidationTests.cs b/tests/Navigation.Tests/Isolation/ValidationTests.cs index 1bc45a6b1a..26545b8ab2 100644 --- a/tests/Navigation.Tests/Isolation/ValidationTests.cs +++ b/tests/Navigation.Tests/Isolation/ValidationTests.cs @@ -207,6 +207,48 @@ public async Task ValidationEmitsHintForDeepLinkingVirtualFiles() ); } + [Test] + public async Task NestedToc_UnderFormerlyHardcodedPathWithoutSuppress_EmitsDeepLinkingHint() + { + var diagnostics = await LoadNestedDeepLinkingToc(suppress: false); + + diagnostics.Should().Contain( + d => d.Severity == Severity.Hint && d.File.Replace('\\', '/').EndsWith("solutions/toc.yml") && d.Message.Contains( + "a/b/overview.md" + ) && d.Message.Contains("deep-linking") + ); + } + + [Test] + public async Task NestedToc_UnderFormerlyHardcodedPathWithSuppress_DoesNotEmitDeepLinkingHint() + { + var diagnostics = await LoadNestedDeepLinkingToc(suppress: true); + + diagnostics.Should().NotContain(d => d.Message.Contains("deep-linking")); + } + + private async Task> LoadNestedDeepLinkingToc(bool suppress) + { + var suppressYaml = suppress ? "suppress:\n - DeepLinkingVirtualFile\n" : ""; + var tocYaml = suppressYaml + "toc:\n" + " - file: a/b/overview.md\n" + " children:\n" + " - file: a/b/setup.md\n"; + + var fileSystem = new MockFileSystem(); + fileSystem.AddDirectory("/docs-content"); + fileSystem.AddFile("/docs-content/solutions/toc.yml", new MockFileData(tocYaml)); + var context = CreateContext(fileSystem); + var docSet = DocumentationSetFile.LoadAndResolve( + context.Collector, + "project: 'test-project'\ntoc:\n - toc: solutions\n", + fileSystem.NewDirInfo("docs-content") + ); + _ = context.Collector.StartAsync(TestContext.Current!.Execution.CancellationToken); + + _ = new DocumentationSetNavigation(docSet, context, GenericDocumentationFileFactory.Instance); + + await context.Collector.StopAsync(TestContext.Current!.Execution.CancellationToken); + return context.Diagnostics; + } + [Test] public async Task ValidationEmitsHintForNestedPathVirtualFiles() {