@@ -53,6 +53,7 @@ public final class PreviewAction: Action, RecreatingContext {
53
53
54
54
var logHandle = LogHandle . standardOutput
55
55
56
+ let host : String
56
57
let port : Int
57
58
58
59
var convertAction : ConvertAction
@@ -75,6 +76,7 @@ public final class PreviewAction: Action, RecreatingContext {
75
76
/// Creates a new preview action from the given parameters.
76
77
///
77
78
/// - Parameters:
79
+ /// - host: The host name used by the preview server.
78
80
/// - port: The port number used by the preview server.
79
81
/// - convertAction: The action used to convert the documentation bundle before preview.
80
82
/// On macOS, this action will be reused to convert documentation each time the source is modified.
@@ -84,6 +86,7 @@ public final class PreviewAction: Action, RecreatingContext {
84
86
/// is performed.
85
87
/// - Throws: If an error is encountered while initializing the documentation context.
86
88
public init (
89
+ host: String ,
87
90
port: Int ,
88
91
createConvertAction: @escaping ( ) throws -> ConvertAction ,
89
92
workspace: DocumentationWorkspace = DocumentationWorkspace ( ) ,
@@ -95,6 +98,7 @@ public final class PreviewAction: Action, RecreatingContext {
95
98
}
96
99
97
100
// Initialize the action context.
101
+ self . host = host
98
102
self . port = port
99
103
self . createConvertAction = createConvertAction
100
104
self . convertAction = try createConvertAction ( )
@@ -108,13 +112,14 @@ public final class PreviewAction: Action, RecreatingContext {
108
112
@available ( * , deprecated, message: " TLS support has been removed. " )
109
113
public convenience init (
110
114
tlsCertificateKey: URL ? , tlsCertificateChain: URL ? , serverUsername: String ? ,
111
- serverPassword: String ? , port: Int ,
115
+ serverPassword: String ? , host : String , port: Int ,
112
116
createConvertAction: @escaping ( ) throws -> ConvertAction ,
113
117
workspace: DocumentationWorkspace = DocumentationWorkspace ( ) ,
114
118
context: DocumentationContext ? = nil ,
115
119
printTemplatePath: Bool = true ) throws
116
120
{
117
121
try self . init (
122
+ host: host,
118
123
port: port,
119
124
createConvertAction: createConvertAction,
120
125
workspace: workspace,
@@ -165,15 +170,15 @@ public final class PreviewAction: Action, RecreatingContext {
165
170
print ( String ( repeating: " = " , count: 40 ) , to: & logHandle)
166
171
var components = URLComponents ( )
167
172
components. scheme = " http "
168
- components. host = " localhost "
173
+ components. host = host
169
174
components. port = port
170
175
if let previewURL = components. url {
171
176
print ( " Starting Local Preview Server " , to: & logHandle)
172
177
printPreviewAddresses ( base: previewURL)
173
178
print ( String ( repeating: " = " , count: 40 ) , to: & logHandle)
174
179
}
175
180
176
- let to : PreviewServer . Bind = bindServerToSocketPath. map { . socket( path: $0) } ?? . localhost( host: " localhost " , port: port)
181
+ let to : PreviewServer . Bind = bindServerToSocketPath. map { . socket( path: $0) } ?? . localhost( host: host , port: port)
177
182
servers [ serverIdentifier] = try PreviewServer ( contentURL: convertAction. targetDirectory, bindTo: to, logHandle: & logHandle)
178
183
179
184
// When the user stops docc - stop the preview server first before exiting.
0 commit comments