Skip to content

Commit 0c674cd

Browse files
authored
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
1 parent 11d3ba3 commit 0c674cd

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
@@ -66,7 +66,10 @@ public static async Task GoAsync(string[] args)
6666
var projects = workspace.CurrentSolution.Projects
6767
.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
6868

69-
foreach (var file in GetDocumentFiles(projects).SelectMany(s => s)) await file.SaveToDocumentationFolderAsync();
69+
DeleteExistingDocs();
70+
71+
foreach (var file in GetDocumentFiles(projects).SelectMany(s => s))
72+
await file.SaveToDocumentationFolderAsync();
7073

7174
Console.ForegroundColor = ConsoleColor.Green;
7275
Console.WriteLine("Documentation generated.");
@@ -79,6 +82,20 @@ public static async Task GoAsync(string[] args)
7982
}
8083
}
8184

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

0 commit comments

Comments
 (0)