Skip to content

Commit 24a2798

Browse files
authored
Merge pull request #5561 from michelou/doc-tool
replace illegal chars in entity path (Windows)
2 parents e1ba839 + 2069331 commit 24a2798

File tree

1 file changed

+11
-5
lines changed
  • doc-tool/src/dotty/tools/dottydoc/staticsite

1 file changed

+11
-5
lines changed

doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ case class Site(
127127
}
128128

129129
/** Copy static files to `outDir` */
130-
def copyStaticFiles(outDir: JFile = new JFile(root.getAbsolutePath + "/_site"))(implicit ctx: Context): this.type =
130+
private[this] val defaultOutDir = new JFile(root.getAbsolutePath + JFile.separator + "_site")
131+
132+
def copyStaticFiles(outDir: JFile = defaultOutDir)(implicit ctx: Context): this.type =
131133
createOutput (outDir) {
132134
// Copy user-defined static assets
133135
staticAssets.foreach { asset =>
@@ -188,7 +190,7 @@ case class Site(
188190
}
189191

190192
/** Generate HTML for the API documentation */
191-
def generateApiDocs(outDir: JFile = new JFile(root.getAbsolutePath + "/_site"))(implicit ctx: Context): this.type =
193+
def generateApiDocs(outDir: JFile = defaultOutDir)(implicit ctx: Context): this.type =
192194
createOutput(outDir) {
193195
def genDoc(e: model.Entity): Unit = {
194196
ctx.docbase.echo(s"Generating doc page for: ${e.path.mkString(".")}")
@@ -198,7 +200,11 @@ case class Site(
198200
if (e.kind == "package") ("/index.html", -1)
199201
else (".html", 0)
200202

201-
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + e.path.mkString("/") + suffix))
203+
val path = if (scala.util.Properties.isWin)
204+
e.path.map(_.replace("<", "_").replace(">", "_"))
205+
else
206+
e.path
207+
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + path.mkString("/") + suffix))
202208
val params = defaultParams(target.toFile, -1).withPosts(blogInfo).withEntity(Some(e)).toMap
203209
val page = new HtmlPage("_layouts/api-page.html", layouts("api-page").content, params, includes)
204210

@@ -230,7 +236,7 @@ case class Site(
230236
}
231237

232238
/** Generate HTML files from markdown and .html sources */
233-
def generateHtmlFiles(outDir: JFile = new JFile(root.getAbsolutePath + "/_site"))(implicit ctx: Context): this.type =
239+
def generateHtmlFiles(outDir: JFile = defaultOutDir)(implicit ctx: Context): this.type =
234240
createOutput(outDir) {
235241
compilableFiles.foreach { asset =>
236242
val pathFromRoot = stripRoot(asset)
@@ -250,7 +256,7 @@ case class Site(
250256
}
251257

252258
/** 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 =
259+
def generateBlog(outDir: JFile = defaultOutDir)(implicit ctx: Context): this.type =
254260
createOutput(outDir) {
255261
blogposts.foreach { file =>
256262
val BlogPost.extract(year, month, day, name, ext) = file.getName

0 commit comments

Comments
 (0)