@@ -8,6 +8,7 @@ import java.io.{ File => JFile, OutputStreamWriter, BufferedWriter, ByteArrayInp
88import java .util .{ List => JList , Arrays }
99import java .nio .file .Path
1010import java .nio .charset .StandardCharsets
11+ import java .io .File .{ separator => sep }
1112
1213import com .vladsch .flexmark .parser .ParserEmulationProfile
1314import com .vladsch .flexmark .parser .Parser
@@ -127,7 +128,9 @@ case class Site(
127128 }
128129
129130 /** 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 =
131134 createOutput (outDir) {
132135 // Copy user-defined static assets
133136 staticAssets.foreach { asset =>
@@ -164,8 +167,8 @@ case class Site(
164167 private def defaultParams (pageLocation : JFile , additionalDepth : Int = 0 ): DefaultParams = {
165168 val pathFromRoot = stripRoot(pageLocation)
166169 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
169172 " ../" * (assetLen - rootLen - 1 + additionalDepth) + " ."
170173 }
171174
@@ -188,19 +191,23 @@ case class Site(
188191 }
189192
190193 /** 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 =
192195 createOutput(outDir) {
193196 def genDoc (e : model.Entity ): Unit = {
194197 ctx.docbase.echo(s " Generating doc page for: ${e.path.mkString(" ." )}" )
195198 // Suffix is index.html for packages and therefore the additional depth
196199 // is increased by 1
197200 val (suffix, offset) =
198- if (e.kind == " package" ) (" / index.html" , - 1 )
201+ if (e.kind == " package" ) (sep + " index.html" , - 1 )
199202 else (" .html" , 0 )
200203
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))
202209 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)
204211
205212 render(page).foreach { rendered =>
206213 val source = new ByteArrayInputStream (rendered.getBytes(StandardCharsets .UTF_8 ))
@@ -217,9 +224,9 @@ case class Site(
217224 }
218225
219226 // 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" ))
221228 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)
223230 render(searchPage).foreach { rendered =>
224231 Files .copy(
225232 new ByteArrayInputStream (rendered.getBytes(StandardCharsets .UTF_8 )),
@@ -230,7 +237,7 @@ case class Site(
230237 }
231238
232239 /** 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 =
234241 createOutput(outDir) {
235242 compilableFiles.foreach { asset =>
236243 val pathFromRoot = stripRoot(asset)
@@ -250,7 +257,7 @@ case class Site(
250257 }
251258
252259 /** 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 =
254261 createOutput(outDir) {
255262 blogposts.foreach { file =>
256263 val BlogPost .extract(year, month, day, name, ext) = file.getName
0 commit comments