diff --git a/Library/Sources/Internal/Enumerations/StaticFile.swift b/Library/Sources/Internal/Enumerations/StaticFile.swift index 4bae878..70903af 100644 --- a/Library/Sources/Internal/Enumerations/StaticFile.swift +++ b/Library/Sources/Internal/Enumerations/StaticFile.swift @@ -1,7 +1,12 @@ +/// An enumeration that represents basic configuration static files which will be created by the `DocC` building process. enum StaticFile: String, CaseIterable { + /// A file defining the root of the articles' folder, which will be used to redirect to the root of the archives' root article. case documentation = "documentation.json" + /// A file containing the icon in `.ico` format for the documentation generated by the `DocC` building process. case faviconICO = "favicon.ico" + /// A file containing the icon in `.svg` format for the documentation generated by the `DocC` building process. case faviconSVG = "favicon.svg" + /// A file containing the theme settings for the documentation generated by the `DocC` building process. case themeSettings = "theme-settings.json" } @@ -13,8 +18,8 @@ extension StaticFile: Pathable { var path: String { switch self { - case .documentation: "/data/" + rawValue - default: .init(format: .Format.pathRoot, rawValue) + case .documentation: .init(format: .Format.Path.data, rawValue) + default: .init(format: .Format.Path.root, rawValue) } } diff --git a/Library/Sources/Internal/Extensions/String+Constants.swift b/Library/Sources/Internal/Extensions/String+Constants.swift index 6568d86..7e38bef 100644 --- a/Library/Sources/Internal/Extensions/String+Constants.swift +++ b/Library/Sources/Internal/Extensions/String+Constants.swift @@ -1,6 +1,7 @@ extension String { enum Format { enum Path { + static let data = "/data/%@" static let docs = "/docs/%@" static let root = "/%@" } diff --git a/Test/Sources/Cases/Internal/Enumerations/StaticFileTests.swift b/Test/Sources/Cases/Internal/Enumerations/StaticFileTests.swift new file mode 100644 index 0000000..6669cce --- /dev/null +++ b/Test/Sources/Cases/Internal/Enumerations/StaticFileTests.swift @@ -0,0 +1,36 @@ +import Testing + +@testable import AppLibrary + +@Suite("StaticFile") +struct StaticFileTests { + + @Test(arguments: zip(StaticFile.allCases, [String].paths)) + func path( + for prefix: StaticFile, + expects pathExpected: String + ) async throws { + // GIVEN + // WHEN + let path = prefix.path + + // THEN + #expect(path == pathExpected) + } + +} + +// MARK: - Collection+Strings + +private extension Collection where Element == String { + + // MARK: Properties + + static var paths: [Element] {[ + "/data/documentation.json", + "/favicon.ico", + "/favicon.svg", + "/theme-settings.json" + ]} + +}