Skip to content

Commit 585ff32

Browse files
committed
Fixed override of directories
1 parent 8ebdbd1 commit 585ff32

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/DocFxTocGenerator/DocFxTocGenerator.Test/ContentInventoryActionTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ public async Task Run_WithOverrideOnly()
264264
current.Folders[0].Name.Should().Be("germany");
265265
current.Folders[0].DisplayName.Should().Be("Germany");
266266
current.Folders[1].Name.Should().Be("netherlands");
267-
current.Folders[1].DisplayName.Should().Be("Netherlands");
267+
// here is a folder title from .override
268+
current.Folders[1].DisplayName.Should().Be("The Netherlands");
268269
current.FileCount.Should().Be(1);
269270
current.Files[0].Name.Should().Be("README.md");
270271
current.Files[0].DisplayName.Should().Be($"Europe");

src/DocFxTocGenerator/DocFxTocGenerator.Test/Helpers/MockFileService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ public void FillDemoSet()
101101
AddFile(folder, "README.md", string.Empty
102102
.AddHeading("Europe", 1)
103103
.AddParagraphs(1));
104+
AddFile(folder, ".override",
105+
@"netherlands;The Netherlands");
104106

105107
folder = AddFolder("continents/europe/germany");
106108
AddFile(folder, "README.md", string.Empty

src/DocFxTocGenerator/DocFxTocGenerator.Test/TableOfContentsServiceTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ public async Task GetTocItems_GetTocFolderReferenceFirst()
183183
toc.IsFolder.Should().BeTrue();
184184
toc.Depth.Should().Be(5);
185185
toc.Base.Should().Be(current);
186-
toc.Name.Should().Be("Netherlands");
186+
// override name
187+
toc.Name.Should().Be("The Netherlands");
187188
toc.Sequence.Should().Be(current!.Sequence);
188189
toc.Href.Should().BeNull();
189190

@@ -412,7 +413,7 @@ public async Task SerializeTocItem_Hierarchy()
412413
href: continents/europe/germany/berlin.md
413414
- name: München
414415
href: continents/europe/germany/munchen.md
415-
- name: Netherlands
416+
- name: The Netherlands
416417
items:
417418
- name: Noord holland
418419
items:
@@ -531,7 +532,7 @@ public async Task SerializeTocItem_Hierarchy_CamelCase()
531532
href: continents/europe/germany/berlin.md
532533
- name: münchen
533534
href: continents/europe/germany/munchen.md
534-
- name: netherlands
535+
- name: The Netherlands
535536
items:
536537
- name: noord holland
537538
items:

src/DocFxTocGenerator/DocFxTocGenerator/Actions/ContentInventoryAction.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ public Task<ReturnCode> RunAsync()
121121
Parent = parent,
122122
};
123123

124+
if (parent != null)
125+
{
126+
// see if we have an override for the folder name
127+
if (parent.OverrideList.TryGetValue(folder.Name, out string? name))
128+
{
129+
folder.DisplayName = name;
130+
}
131+
}
132+
124133
// read config files
125134
if (_useOrder)
126135
{

0 commit comments

Comments
 (0)