Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 0ecb3fc

Browse files
authored
Ignore additional top-level directories (#241)
* Ignore additional top-level directories * Incorporate @Lukas-Stuehrk's feedback from review
1 parent b0e3615 commit 0ecb3fc

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Sources/SwiftDoc/Module.swift

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,31 @@ public final class Module {
2222
let fileManager = FileManager.default
2323
for path in paths {
2424
let directory = URL(fileURLWithPath: path)
25-
guard let directoryEnumerator = fileManager.enumerator(at: directory, includingPropertiesForKeys: [.isDirectoryKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else { continue }
25+
guard let directoryEnumerator = fileManager.enumerator(at: directory,
26+
includingPropertiesForKeys: [.isDirectoryKey],
27+
options: [.skipsHiddenFiles, .skipsPackageDescendants])
28+
else { continue }
29+
30+
let ignoredDirectories: Set<URL> = Set([
31+
"node_modules",
32+
"Packages",
33+
"Pods",
34+
"Resources",
35+
"Tests"
36+
].map { directory.appendingPathComponent($0) })
37+
2638
for case let url as URL in directoryEnumerator {
27-
var isDirectory: ObjCBool = false
2839
guard url.pathExtension == "swift",
29-
fileManager.isReadableFile(atPath: url.path),
30-
fileManager.fileExists(atPath: url.path, isDirectory: &isDirectory)
40+
fileManager.isReadableFile(atPath: url.path)
3141
else {
32-
// Skip top-level Tests directory
33-
if isDirectory.boolValue == true,
34-
url.lastPathComponent == "Tests",
35-
directory.appendingPathComponent("Tests").path == url.path
36-
{
42+
if ignoredDirectories.contains(url) {
3743
directoryEnumerator.skipDescendants()
3844
}
3945

4046
continue
4147
}
4248

43-
if isDirectory.boolValue == false {
44-
sources.append((url, directory))
45-
}
49+
sources.append((url, directory))
4650
}
4751
}
4852

0 commit comments

Comments
 (0)