Added the "archiveReference" property to the PreparedURIPaths pseudo-type for the PrepareURIPathUseCase use case in the library target.
This commit is contained in:
@@ -18,8 +18,8 @@ struct PrepareURIPathUseCase {
|
|||||||
|
|
||||||
// MARK: Type aliases
|
// MARK: Type aliases
|
||||||
|
|
||||||
/// A pseudo-type that contains the archive name and URI path, plus the resource URI paths used for routing the documentation contents.
|
/// A pseudo-type that contains the archive name, reference and URI path, plus the resource URI and relative paths used for routing the documentation contents.
|
||||||
typealias PreparedURIPaths = (archiveName: String, archivePath: String, resourcePath: String)
|
typealias PreparedURIPaths = (archiveName: String, archiveReference: String, archivePath: String, resourcePath: String)
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
@@ -43,35 +43,41 @@ struct PrepareURIPathUseCase {
|
|||||||
///
|
///
|
||||||
/// The necessary data to extract from a given URI path is:
|
/// The necessary data to extract from a given URI path is:
|
||||||
/// 1. the `DocC` documentation archive name;
|
/// 1. the `DocC` documentation archive name;
|
||||||
/// 2. the `DocC` documentation archive URI path;
|
/// 2. the `DocC` documentation archive reference;
|
||||||
/// 3. the `DocC` documentation resource URI path.
|
/// 3. the `DocC` documentation archive URI path;
|
||||||
|
/// 4. the `DocC` documentation resource URI path.
|
||||||
///
|
///
|
||||||
/// > important: It is assumed that the `uriPath` parameter is a URI path that does not contain any percent encoded strings.
|
/// > important: It is assumed that the `uriPath` parameter is a URI path that does not contain any percent encoded strings.
|
||||||
///
|
///
|
||||||
/// - Parameter uriPath: A URI path to extract the data from.
|
/// - Parameter uriPath: A URI path to extract the data from.
|
||||||
/// - Returns: A pseudo-type that contains the archive' name and URI path, plus the resource URI paths.
|
/// - Returns: A pseudo-type that contains the archive' name, reference and URI path, plus the resource URI paths.
|
||||||
func callAsFunction(_ uriPath: String) -> PreparedURIPaths? {
|
func callAsFunction(_ uriPath: String) -> PreparedURIPaths? {
|
||||||
guard let uriRest = restOfURIPath(from: uriPath) else {
|
guard let uriRest = restOfURIPath(from: uriPath) else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let documentationName = uriRest
|
let archiveName = uriRest
|
||||||
.split(separator: .Path.forwardSlash)
|
.split(separator: .Path.forwardSlash)
|
||||||
.map(String.init)
|
.map(String.init)
|
||||||
.first
|
.first
|
||||||
|
|
||||||
let archiveName: String = if let documentationName {
|
let archiveReference: String = if let archiveName {
|
||||||
documentationName.lowercased()
|
archiveName.lowercased()
|
||||||
} else {
|
} else {
|
||||||
.empty
|
.empty
|
||||||
}
|
}
|
||||||
let archivePath: String = if let documentationName {
|
let archivePath: String = if let archiveName {
|
||||||
.init(format: .Format.Path.archive, documentationName)
|
.init(format: .Format.Path.archive, archiveName)
|
||||||
} else {
|
} else {
|
||||||
.empty
|
.empty
|
||||||
}
|
}
|
||||||
|
|
||||||
return (archiveName, archivePath, uriRest)
|
return (
|
||||||
|
archiveName ?? .empty,
|
||||||
|
archiveReference,
|
||||||
|
archivePath,
|
||||||
|
uriRest
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ private extension Input {
|
|||||||
private extension Output {
|
private extension Output {
|
||||||
/// A list of expected outputs for the URI path samples, regardless their match against suffixed or not suffixed root URI paths.
|
/// A list of expected outputs for the URI path samples, regardless their match against suffixed or not suffixed root URI paths.
|
||||||
static let prepareURIPaths: [PrepareURIPathUseCase.PreparedURIPaths?] = [
|
static let prepareURIPaths: [PrepareURIPathUseCase.PreparedURIPaths?] = [
|
||||||
("somearchive", "/SomeArchive.doccarchive", "/SomeArchive/some/content/path"),
|
("SomeArchive", "somearchive", "/SomeArchive.doccarchive", "/SomeArchive/some/content/path"),
|
||||||
(.empty, .empty, .Path.forwardSlash),
|
(.empty, .empty, .empty, .Path.forwardSlash),
|
||||||
nil
|
nil
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user