Skip to content

replace illegal chars in entity path (Windows) #5561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ case class Site(
}

/** Copy static files to `outDir` */
def copyStaticFiles(outDir: JFile = new JFile(root.getAbsolutePath + "/_site"))(implicit ctx: Context): this.type =
private[this] val defaultOutDir = new JFile(root.getAbsolutePath + JFile.separator + "_site")

def copyStaticFiles(outDir: JFile = defaultOutDir)(implicit ctx: Context): this.type =
createOutput (outDir) {
// Copy user-defined static assets
staticAssets.foreach { asset =>
Expand Down Expand Up @@ -188,7 +190,7 @@ case class Site(
}

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

val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + e.path.mkString("/") + suffix))
val path = if (scala.util.Properties.isWin)
e.path.map(_.replace("<", "_").replace(">", "_"))
else
e.path
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + path.mkString("/") + suffix))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to change "/" as well?

Copy link
Contributor Author

@michelou michelou Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check if mkdirs() (and other functions used in doc-tool) do support both kinds of file separator. If yes, we can save time and extra work (besides keeping the code shorter) !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if necessary we can do in another PR.

val params = defaultParams(target.toFile, -1).withPosts(blogInfo).withEntity(Some(e)).toMap
val page = new HtmlPage("_layouts/api-page.html", layouts("api-page").content, params, includes)

Expand Down Expand Up @@ -230,7 +236,7 @@ case class Site(
}

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

/** Generate blog from files in `blog/_posts` and output in `outDir` */
def generateBlog(outDir: JFile = new JFile(root.getAbsolutePath + "/_site"))(implicit ctx: Context): this.type =
def generateBlog(outDir: JFile = defaultOutDir)(implicit ctx: Context): this.type =
createOutput(outDir) {
blogposts.foreach { file =>
val BlogPost.extract(year, month, day, name, ext) = file.getName
Expand Down