@@ -8,6 +8,7 @@ import java.io.{ File => JFile, OutputStreamWriter, BufferedWriter, ByteArrayInp
8
8
import java .util .{ List => JList , Arrays }
9
9
import java .nio .file .Path
10
10
import java .nio .charset .StandardCharsets
11
+ import java .io .File .{ separator => sep }
11
12
12
13
import com .vladsch .flexmark .parser .ParserEmulationProfile
13
14
import com .vladsch .flexmark .parser .Parser
@@ -127,7 +128,9 @@ case class Site(
127
128
}
128
129
129
130
/** Copy static files to `outDir` */
130
- def copyStaticFiles (outDir : JFile = new JFile (root.getAbsolutePath + " /_site" ))(implicit ctx : Context ): this .type =
131
+ private [this ] val defaultOutDir = new JFile (root.getAbsolutePath + JFile .separator + " _site" )
132
+
133
+ def copyStaticFiles (outDir : JFile = defaultOutDir)(implicit ctx : Context ): this .type =
131
134
createOutput (outDir) {
132
135
// Copy user-defined static assets
133
136
staticAssets.foreach { asset =>
@@ -164,8 +167,8 @@ case class Site(
164
167
private def defaultParams (pageLocation : JFile , additionalDepth : Int = 0 ): DefaultParams = {
165
168
val pathFromRoot = stripRoot(pageLocation)
166
169
val baseUrl : String = {
167
- val rootLen = root.getAbsolutePath.split('/' ).length
168
- val assetLen = pageLocation.getAbsolutePath.split('/' ).length
170
+ val rootLen = root.getAbsolutePath.split(sep ).length
171
+ val assetLen = pageLocation.getAbsolutePath.split(sep ).length
169
172
" ../" * (assetLen - rootLen - 1 + additionalDepth) + " ."
170
173
}
171
174
@@ -188,19 +191,23 @@ case class Site(
188
191
}
189
192
190
193
/** Generate HTML for the API documentation */
191
- def generateApiDocs (outDir : JFile = new JFile (root.getAbsolutePath + " /_site " ) )(implicit ctx : Context ): this .type =
194
+ def generateApiDocs (outDir : JFile = defaultOutDir )(implicit ctx : Context ): this .type =
192
195
createOutput(outDir) {
193
196
def genDoc (e : model.Entity ): Unit = {
194
197
ctx.docbase.echo(s " Generating doc page for: ${e.path.mkString(" ." )}" )
195
198
// Suffix is index.html for packages and therefore the additional depth
196
199
// is increased by 1
197
200
val (suffix, offset) =
198
- if (e.kind == " package" ) (" / index.html" , - 1 )
201
+ if (e.kind == " package" ) (sep + " index.html" , - 1 )
199
202
else (" .html" , 0 )
200
203
201
- val target = mkdirs(fs.getPath(outDir.getAbsolutePath + " /api/" + e.path.mkString(" /" ) + suffix))
204
+ val path = if (scala.util.Properties .isWin)
205
+ e.path.map(_.replace(" <" , " _" ).replace(" >" , " _" ))
206
+ else
207
+ e.path
208
+ val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + " api" + sep + path.mkString(sep) + suffix))
202
209
val params = defaultParams(target.toFile, - 1 ).withPosts(blogInfo).withEntity(Some (e)).toMap
203
- val page = new HtmlPage (" _layouts/ api-page.html" , layouts(" api-page" ).content, params, includes)
210
+ val page = new HtmlPage (" _layouts" + sep + " api-page.html" , layouts(" api-page" ).content, params, includes)
204
211
205
212
render(page).foreach { rendered =>
206
213
val source = new ByteArrayInputStream (rendered.getBytes(StandardCharsets .UTF_8 ))
@@ -217,9 +224,9 @@ case class Site(
217
224
}
218
225
219
226
// generate search page:
220
- val target = mkdirs(fs.getPath(outDir.getAbsolutePath + " / api/ search.html" ))
227
+ val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + " api" + sep + " search.html" ))
221
228
val searchPageParams = defaultParams(target.toFile, - 1 ).withPosts(blogInfo).toMap
222
- val searchPage = new HtmlPage (" _layouts/ search.html" , layouts(" search" ).content, searchPageParams, includes)
229
+ val searchPage = new HtmlPage (" _layouts" + sep + " search.html" , layouts(" search" ).content, searchPageParams, includes)
223
230
render(searchPage).foreach { rendered =>
224
231
Files .copy(
225
232
new ByteArrayInputStream (rendered.getBytes(StandardCharsets .UTF_8 )),
@@ -230,7 +237,7 @@ case class Site(
230
237
}
231
238
232
239
/** Generate HTML files from markdown and .html sources */
233
- def generateHtmlFiles (outDir : JFile = new JFile (root.getAbsolutePath + " /_site " ) )(implicit ctx : Context ): this .type =
240
+ def generateHtmlFiles (outDir : JFile = defaultOutDir )(implicit ctx : Context ): this .type =
234
241
createOutput(outDir) {
235
242
compilableFiles.foreach { asset =>
236
243
val pathFromRoot = stripRoot(asset)
@@ -250,7 +257,7 @@ case class Site(
250
257
}
251
258
252
259
/** Generate blog from files in `blog/_posts` and output in `outDir` */
253
- def generateBlog (outDir : JFile = new JFile (root.getAbsolutePath + " /_site " ) )(implicit ctx : Context ): this .type =
260
+ def generateBlog (outDir : JFile = defaultOutDir )(implicit ctx : Context ): this .type =
254
261
createOutput(outDir) {
255
262
blogposts.foreach { file =>
256
263
val BlogPost .extract(year, month, day, name, ext) = file.getName
0 commit comments