Skip to content

Commit bac0778

Browse files
authored
toc not log warning if name is null but uid is present (dotnet#2338)
1 parent 29cd3f9 commit bac0778

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Microsoft.DocAsCode.Build.TableOfContents/TocResolver.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@ private TocItemInfo ResolveItemCore(TocItemInfo wrapper, Stack<FileAndType> stac
5050

5151
var item = wrapper.Content;
5252

53-
if (!isRoot && string.IsNullOrEmpty(item.Name))
54-
{
55-
Logger.LogWarning(
56-
$"TOC item ({item.ToString()}) with empty name found. Missing a name?",
57-
code: WarningCodes.Build.EmptyTocItemName);
58-
}
59-
6053
// HomepageUid and Uid is deprecated, unified to TopicUid
6154
if (string.IsNullOrEmpty(item.TopicUid))
6255
{
@@ -87,6 +80,14 @@ private TocItemInfo ResolveItemCore(TocItemInfo wrapper, Stack<FileAndType> stac
8780
// validate href
8881
ValidateHref(item);
8982

83+
// validate if name is missing
84+
if (!isRoot && string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.TopicUid))
85+
{
86+
Logger.LogWarning(
87+
$"TOC item ({item.ToString()}) with empty name found. Missing a name?",
88+
code: WarningCodes.Build.EmptyTocItemName);
89+
}
90+
9091
// TocHref supports 2 forms: absolute path and local toc file.
9192
// When TocHref is set, using TocHref as Href in output, and using Href as Homepage in output
9293
var tocHrefType = Utility.GetHrefType(item.TocHref);

0 commit comments

Comments
 (0)