diff --git a/Changelog.md b/Changelog.md index a19d42e7..cbb2c655 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added `--base-url` option. + #65 by @kean. + ## [1.0.0-beta.2] - 2020-04-08 ### Changed diff --git a/Sources/swift-doc/Subcommands/Generate.swift b/Sources/swift-doc/Subcommands/Generate.swift index 9f91ef34..707cb9ba 100644 --- a/Sources/swift-doc/Subcommands/Generate.swift +++ b/Sources/swift-doc/Subcommands/Generate.swift @@ -29,6 +29,11 @@ extension SwiftDoc { default: .commonmark, help: "The output format") var format: Format + + @Option(name: .customLong("base-url"), + default: "/", + help: "The base URL used for all relative URLs in generated documents.") + var baseURL: String } static var configuration = CommandConfiguration(abstract: "Generates Swift documentation") @@ -79,7 +84,7 @@ extension SwiftDoc { } let url = outputDirectoryURL.appendingPathComponent(filename) - try page.write(to: url, format: format) + try page.write(to: url, format: format, baseURL: options.baseURL) } else { switch format { case .commonmark: @@ -102,7 +107,7 @@ extension SwiftDoc { } let url = outputDirectoryURL.appendingPathComponent(filename) - try $0.value.write(to: url, format: format) + try $0.value.write(to: url, format: format, baseURL: options.baseURL) } } } catch { diff --git a/Sources/swift-doc/Supporting Types/Components/Relationships.swift b/Sources/swift-doc/Supporting Types/Components/Relationships.swift index 5ef8f7cf..c442b414 100644 --- a/Sources/swift-doc/Supporting Types/Components/Relationships.swift +++ b/Sources/swift-doc/Supporting Types/Components/Relationships.swift @@ -113,7 +113,7 @@ struct Relationships: Component { """# } else { return #""" -
\#(symbol.id)
\#(symbol.id)