This repository was archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Bugfix/relative links #127
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b9b37e4
Fix relative link generation.
mattpolzin 32124df
Expose base-url argument for GitHub action.
mattpolzin 17edb2c
fix #134: crash for operator functions when no baseURL.
kareman 223fc7e
Merge branch 'master' into bugfix/relative-links
mattpolzin c4b54e3
Merge branch 'master' into bugfix/relative-links
mattt 1688dde
Merge branch 'master' into bugfix/relative-links
mattpolzin 528b0ac
Merged w/ preferable fix for path building from base URL and path com…
mattpolzin 33d0628
swap out path for absoluteString to ensure that both relative and abs…
mattpolzin 219572c
Merge branch 'master' into bugfix/relative-links
mattt 58086d4
Move path helper functions to SwiftDoc module
mattt f6b1e74
Add PathTests
mattt 4f7bf94
Add assertions for function identifiers
mattt f8cc4e3
Add changelog entry for #127
mattt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Foundation | ||
|
||
public func route(for symbol: Symbol) -> String { | ||
return route(for: symbol.id) | ||
} | ||
|
||
public func route(for name: CustomStringConvertible) -> String { | ||
return name.description.replacingOccurrences(of: ".", with: "_") | ||
} | ||
|
||
public func path(for symbol: Symbol, with baseURL: String) -> String { | ||
return path(for: route(for: symbol), with: baseURL) | ||
} | ||
|
||
public func path(for identifier: CustomStringConvertible, with baseURL: String) -> String { | ||
let url = URL(string: baseURL)?.appendingPathComponent("\(identifier)") ?? URL(string: "\(identifier)") | ||
guard let string = url?.absoluteString else { | ||
fatalError("Unable to construct path for \(identifier) with baseURL \(baseURL)") | ||
} | ||
|
||
return string | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import SwiftDoc | ||
import HypertextLiteral | ||
import Foundation | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import XCTest | ||
|
||
import SwiftDoc | ||
|
||
final class PathTests: XCTestCase { | ||
func testEmptyBaseURL() { | ||
XCTAssertEqual(path(for: "Class", with: ""), "Class") | ||
|
||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: ""), "(lhs:rhs:)") | ||
} | ||
|
||
func testRootDirectoryBaseURL() { | ||
XCTAssertEqual(path(for: "Class", with: "/"), "/Class") | ||
|
||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: "/"), "/(lhs:rhs:)") | ||
} | ||
|
||
func testCurrentDirectoryBaseURL() { | ||
XCTAssertEqual(path(for: "Class", with: "./"), "./Class") | ||
|
||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: "./"), "./(lhs:rhs:)") | ||
} | ||
|
||
func testNestedSubdirectoryBaseURL() { | ||
XCTAssertEqual(path(for: "Class", with: "/path/to/directory"), "/path/to/directory/Class") | ||
XCTAssertEqual(path(for: "Class", with: "/path/to/directory/"), "/path/to/directory/Class") | ||
|
||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: "/path/to/directory"), "/path/to/directory/(lhs:rhs:)") | ||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: "/path/to/directory/"), "/path/to/directory/(lhs:rhs:)") | ||
} | ||
|
||
func testDomainBaseURL() { | ||
XCTAssertEqual(path(for: "Class", with: "https://example.com"), "https://example.com/Class") | ||
XCTAssertEqual(path(for: "Class", with: "https://example.com/"), "https://example.com/Class") | ||
|
||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: "https://example.com"), "https://example.com/(lhs:rhs:)") | ||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: "https://example.com/"), "https://example.com/(lhs:rhs:)") | ||
} | ||
|
||
func testDomainSubdirectoryBaseURL() { | ||
XCTAssertEqual(path(for: "Class", with: "https://example.com/docs"), "https://example.com/docs/Class") | ||
XCTAssertEqual(path(for: "Class", with: "https://example.com/docs/"), "https://example.com/docs/Class") | ||
|
||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: "https://example.com/docs"), "https://example.com/docs/(lhs:rhs:)") | ||
XCTAssertEqual(path(for: "(lhs:rhs:)", with: "https://example.com/docs/"), "https://example.com/docs/(lhs:rhs:)") | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.