Skip to content

Commit fc83b6d

Browse files
committed
Delete existing docs when generating new docs (#4022)
This commit updates the doc generation process to delete existing documentation, except for the breaking changes directories, when generating new documentation. This is to prevent stale doc pages from carrying over. Closes #3976 (cherry picked from commit 0c674cd)
1 parent 1dc2e50 commit fc83b6d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/CodeGeneration/DocGenerator/LitUp.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ public static async Task GoAsync(string[] args)
6868
var projects = workspace.CurrentSolution.Projects
6969
.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
7070

71-
foreach (var file in GetDocumentFiles(projects).SelectMany(s => s)) await file.SaveToDocumentationFolderAsync();
71+
DeleteExistingDocs();
72+
73+
foreach (var file in GetDocumentFiles(projects).SelectMany(s => s))
74+
await file.SaveToDocumentationFolderAsync();
7275

7376
Console.ForegroundColor = ConsoleColor.Green;
7477
Console.WriteLine("Documentation generated.");
@@ -81,6 +84,20 @@ public static async Task GoAsync(string[] args)
8184
}
8285
}
8386

87+
private static void DeleteExistingDocs()
88+
{
89+
var outputDir = new DirectoryInfo(Program.OutputDirPath);
90+
91+
foreach (var file in outputDir.EnumerateFiles())
92+
file.Delete();
93+
94+
foreach (var dir in outputDir.EnumerateDirectories())
95+
{
96+
if (!dir.Name.EndsWith("breaking-changes"))
97+
dir.Delete(true);
98+
}
99+
}
100+
84101
private static void AddDocumentsToWorkspace(AdhocWorkspace workspace)
85102
{
86103
// we only need source for the Tests project.

0 commit comments

Comments
 (0)