Improve overview of modified pages

This commit is contained in:
Christoph Hagen 2022-09-02 23:19:13 +02:00
parent 6a2d63462e
commit d1c418af3e
5 changed files with 26 additions and 6 deletions

View File

@ -76,6 +76,11 @@ final class FileSystem {
*/
private var imageTasks: [String : ImageOutput] = [:]
/**
The paths to all pages which were changed
*/
private var generatedPages: Set<String> = []
init(in input: URL, to output: URL) {
self.input = input
self.output = output
@ -474,6 +479,21 @@ final class FileSystem {
pagePaths[id]
}
func generated(page: String) {
generatedPages.insert(page)
}
func printGeneratedPages() {
guard !generatedPages.isEmpty else {
print("No pages modified")
return
}
print("\(generatedPages.count) pages modified")
for page in generatedPages.sorted() {
print(" " + page)
}
}
// MARK: Writing files

View File

@ -29,7 +29,7 @@ struct IndexPageGenerator {
guard factory.page.generate(content, to: pageUrl) else {
return
}
log.add(info: "Page generated", source: path)
files.generated(page: path)
}
private func makeHeader(page: Element, metadata: Element.LocalizedMetadata, language: String) -> String {

View File

@ -29,7 +29,7 @@ struct OverviewPageGenerator {
guard factory.page.generate(content, to: url) else {
return
}
log.add(info: "Page generated", source: path)
files.generated(page: path)
}
private func makeContent(section: Element, language: String) -> String {

View File

@ -57,7 +57,7 @@ struct PageGenerator {
guard factory.page.generate(content, to: url) else {
return
}
log.add(info: "Page generated", source: path)
files.generated(page: path)
}
private func makeContent(page: Element, language: String, path: String) -> (content: String, includesCode: Bool)? {

View File

@ -22,11 +22,11 @@ do {
private let siteGenerator = try SiteGenerator()
try siteGenerator.generate(site: siteData)
print("Pages generated\n")
files.createImages()
files.printGeneratedPages()
files.printEmptyPages()
files.printDraftPages()
files.createImages()
print("Images generated")
files.copyRequiredFiles()
print("Required files copied")
files.writeHashes()