@@ -53,6 +53,7 @@ public final class PreviewAction: Action, RecreatingContext {
5353
5454 var logHandle = LogHandle . standardOutput
5555
56+ let host : String
5657 let port : Int
5758
5859 var convertAction : ConvertAction
@@ -75,6 +76,7 @@ public final class PreviewAction: Action, RecreatingContext {
7576 /// Creates a new preview action from the given parameters.
7677 ///
7778 /// - Parameters:
79+ /// - host: The host name used by the preview server.
7880 /// - port: The port number used by the preview server.
7981 /// - convertAction: The action used to convert the documentation bundle before preview.
8082 /// 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 {
8486 /// is performed.
8587 /// - Throws: If an error is encountered while initializing the documentation context.
8688 public init (
89+ host: String ,
8790 port: Int ,
8891 createConvertAction: @escaping ( ) throws -> ConvertAction ,
8992 workspace: DocumentationWorkspace = DocumentationWorkspace ( ) ,
@@ -95,6 +98,7 @@ public final class PreviewAction: Action, RecreatingContext {
9598 }
9699
97100 // Initialize the action context.
101+ self . host = host
98102 self . port = port
99103 self . createConvertAction = createConvertAction
100104 self . convertAction = try createConvertAction ( )
@@ -108,13 +112,14 @@ public final class PreviewAction: Action, RecreatingContext {
108112 @available ( * , deprecated, message: " TLS support has been removed. " )
109113 public convenience init (
110114 tlsCertificateKey: URL ? , tlsCertificateChain: URL ? , serverUsername: String ? ,
111- serverPassword: String ? , port: Int ,
115+ serverPassword: String ? , host : String , port: Int ,
112116 createConvertAction: @escaping ( ) throws -> ConvertAction ,
113117 workspace: DocumentationWorkspace = DocumentationWorkspace ( ) ,
114118 context: DocumentationContext ? = nil ,
115119 printTemplatePath: Bool = true ) throws
116120 {
117121 try self . init (
122+ host: host,
118123 port: port,
119124 createConvertAction: createConvertAction,
120125 workspace: workspace,
@@ -165,15 +170,15 @@ public final class PreviewAction: Action, RecreatingContext {
165170 print ( String ( repeating: " = " , count: 40 ) , to: & logHandle)
166171 var components = URLComponents ( )
167172 components. scheme = " http "
168- components. host = " localhost "
173+ components. host = host
169174 components. port = port
170175 if let previewURL = components. url {
171176 print ( " Starting Local Preview Server " , to: & logHandle)
172177 printPreviewAddresses ( base: previewURL)
173178 print ( String ( repeating: " = " , count: 40 ) , to: & logHandle)
174179 }
175180
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)
177182 servers [ serverIdentifier] = try PreviewServer ( contentURL: convertAction. targetDirectory, bindTo: to, logHandle: & logHandle)
178183
179184 // When the user stops docc - stop the preview server first before exiting.
0 commit comments