diff --git a/Sources/DocCMiddleware/Internal/Enumerations/DocumentationFolder.swift b/Sources/DocCMiddleware/Internal/Enumerations/DocumentationFolder.swift new file mode 100644 index 0000000..403d585 --- /dev/null +++ b/Sources/DocCMiddleware/Internal/Enumerations/DocumentationFolder.swift @@ -0,0 +1,31 @@ +// ===----------------------------------------------------------------------=== +// +// This source file is part of the Hummingbird DocC Middleware open source project +// +// Copyright (c) 2025 Röck+Cöde VoF. and the Hummingbird DocC Middleware project authors +// Licensed under the EUPL 1.2 or later. +// +// See LICENSE for license information +// See CONTRIBUTORS for the list of Hummingbird DocC Middleware project authors +// +// ===----------------------------------------------------------------------=== + +/// An enumeration that represents the documentation folders that could be generated by the `DocC` building process. +enum DocumentationFolder: String, CaseIterable { + /// An article document, which can also be used for (source code generated) technical documentation as well. + case article = "documentation" + /// A tutorial document. + case tutorial = "tutorials" +} + +// MARK: - Pathable + +extension DocumentationFolder: Pathable { + + // MARK: Computed + + var path: String { + .init(format: .Format.Path.root, rawValue) + } + +} diff --git a/Tests/DocCMiddleware/Tests/Internal/Enumerations/DocumentationFolderTests.swift b/Tests/DocCMiddleware/Tests/Internal/Enumerations/DocumentationFolderTests.swift new file mode 100644 index 0000000..fc2cc6d --- /dev/null +++ b/Tests/DocCMiddleware/Tests/Internal/Enumerations/DocumentationFolderTests.swift @@ -0,0 +1,77 @@ +// ===----------------------------------------------------------------------=== +// +// This source file is part of the Hummingbird DocC Middleware open source project +// +// Copyright (c) 2025 Röck+Cöde VoF. and the Hummingbird DocC Middleware project authors +// Licensed under the EUPL 1.2 or later. +// +// See LICENSE for license information +// See CONTRIBUTORS for the list of Hummingbird DocC Middleware project authors +// +// ===----------------------------------------------------------------------=== + +import Testing + +@testable import enum DocCMiddleware.DocumentationFolder + +@Suite("Documentation Type", .tags(.enumeration)) +struct DocumentationTypeTests { + + // MARK: Properties tests + +#if swift(>=6.2) + @Test(arguments: zip( + DocumentationFolder.allCases, + Output.documentationFolderPaths + )) + func `path`( + `case`: DocumentationFolder, + expects result: String + ) { + assertPath(`case`, expects: result) + } +#else + @Test("path", arguments: zip( + DocumentationType.allCases, + Output.documentationTypePaths + )) + func path( + `case`: DocumentationType, + expects result: String + ) { + assertPath(`case`, expects: result) + } +#endif + +} + +// MARK: - Assertions + +private extension DocumentationTypeTests { + + // MARK: Functions + + /// Asserts the path property based on a given ``DocumentationFolder`` enumeration case and an expected result. + /// - Parameters: + /// - case: A representation of the ``DocumentationFolder`` enumeration + /// - result: An expected result coming out of the property. + func assertPath( + _ case: DocumentationFolder, + expects result: String + ) { + // GIVEN + // WHEN + let output = `case`.path + + // THEN + #expect(output == result) + } + +} + +// MARK: - Constants + +extension Output { + /// A list of expected outputs for the paths of the ``DocumentationFolder`` enumeration cases. + static let documentationFolderPaths: [String] = ["/documentation", "/tutorials"] +}