Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions tests/Navigation.Tests/Isolation/ValidationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IReadOnlyCollection<Diagnostic>> 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<IDocumentationFile>(docSet, context, GenericDocumentationFileFactory.Instance);

await context.Collector.StopAsync(TestContext.Current!.Execution.CancellationToken);
return context.Diagnostics;
}

[Test]
public async Task ValidationEmitsHintForNestedPathVirtualFiles()
{
Expand Down
Loading