Defined the DocumentrationFolder enumeration type in. the library target and also, conformed it to the Pathable protocol.

This commit is contained in:
2025-09-22 20:56:50 +02:00
parent 9b908515d9
commit dfec69d1bd
2 changed files with 108 additions and 0 deletions
@@ -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)
}
}
@@ -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"]
}