Skip to content

Commit cbf10db

Browse files
authored
Allow dangling toc definitions in navigation.yml (#1539)
1 parent 47e4d24 commit cbf10db

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/tooling/docs-assembler/Navigation/GlobalNavigationHtmlWriter.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,25 @@ private bool TryGetNavigationRoot(
3232
navigationRootSource = null;
3333
if (!assembleSources.TocTopLevelMappings.TryGetValue(navigationSource, out var topLevelMapping))
3434
{
35-
assembleContext.Collector.EmitWarning(assembleContext.NavigationPath.FullName, $"Could not find a top level mapping for {navigationSource}");
35+
if (assembleSources.TreeCollector.TryGetTableOfContentsTree(navigationSource, out navigationRoot))
36+
{
37+
if (navigationRoot.Parent is DocumentationGroup parent &&
38+
assembleSources.TocTopLevelMappings.TryGetValue(parent.NavigationSource, out var topLevelMapping2))
39+
{
40+
navigationRootSource = topLevelMapping2.TopLevelSource;
41+
return true;
42+
}
43+
44+
assembleContext.Collector.EmitError(assembleContext.NavigationPath.FullName, $"The following toc: {navigationSource} is not declared in navigation.yml and it's parent failed to yield a navigation root.");
45+
return false;
46+
}
47+
assembleContext.Collector.EmitError(assembleContext.NavigationPath.FullName, $"The following toc: {navigationSource} is not declared in navigation.yml");
3648
return false;
3749
}
3850

3951
if (!assembleSources.TreeCollector.TryGetTableOfContentsTree(topLevelMapping.TopLevelSource, out navigationRoot))
4052
{
41-
assembleContext.Collector.EmitWarning(assembleContext.NavigationPath.FullName, $"Could not find a toc tree for {topLevelMapping.TopLevelSource}");
53+
assembleContext.Collector.EmitError(assembleContext.NavigationPath.FullName, $"None of the assemble sources define a toc for: {topLevelMapping.TopLevelSource}");
4254
return false;
4355
}
4456
navigationRootSource = topLevelMapping.TopLevelSource;

0 commit comments

Comments
 (0)