Show empty pages

This commit is contained in:
Christoph Hagen 2022-08-29 19:20:13 +02:00
parent 3f1971c5bd
commit 5ec283e4d4
4 changed files with 28 additions and 2 deletions

View File

@ -52,6 +52,11 @@ final class FileSystem {
*/
private var expectedFiles: [String : String] = [:]
/**
All pages without content which have been created
*/
private var emptyPages: Set<String> = []
/**
The image creation tasks.
@ -402,6 +407,23 @@ final class FileSystem {
return result.joined(separator: "/")
}
// MARK: Pages
func isEmpty(page: String) {
emptyPages.insert(page)
}
func printEmptyPages() {
guard !emptyPages.isEmpty else {
return
}
log.add(info: "\(emptyPages.count) empty pages:", source: "FileSystem")
for page in emptyPages.sorted() {
log.add(info: "Empty page generated", source: page)
}
}
// MARK: Writing files
@discardableResult

View File

@ -19,7 +19,7 @@ final class ValidationLog {
} else {
errorText = ""
}
print("[\(type.rawValue)] \(item.reason), Source: \(item.source)\(errorText)")
print("[\(type.rawValue)][\(item.source)] \(item.reason)\(errorText)")
}
func add(error: ContentError) {

View File

@ -49,10 +49,13 @@ struct PageGenerator {
}
let url = files.urlInOutputFolder(path)
if pageContent == nil {
files.isEmpty(page: path)
}
guard factory.page.generate(content, to: url) else {
return
}
log.add(info: "Generated \(pageContent == nil ? "empty page " : "")\(path)", source: page.path)
log.add(info: "Page generated", source: path)
}
private func makeContent(page: Element, language: String, path: String) -> (content: String, includesCode: Bool)? {

View File

@ -24,6 +24,7 @@ try siteGenerator.generate(site: siteData)
print("Pages generated")
files.createImages()
files.printEmptyPages()
print("Images generated")
files.copyRequiredFiles()
print("Required files copied")