Skip to content

Commit

Permalink
Make folders
Browse files Browse the repository at this point in the history
  • Loading branch information
ianoc committed Apr 16, 2020
1 parent 3538106 commit 4ca0929
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/scala/io/bazeltools/proto3docgen/Rendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.bazeltools.proto3docgen

import io.bazeltools.proto3docgen.repr.{ProtoPackage, ProtoContext}
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.{Path, Paths}

object Rendering {
trait Engine {
Expand Down Expand Up @@ -55,8 +55,23 @@ title: ${pkg.name}

${pkg.toSection(this).toMarkdown(1).render(0)}
"""

val outputP = pkgToUrl(pkg.name)
val outputFolder = Paths.get(outputP).getParent
if(!outputFolder.toFile.exists) {
Files.createDirectories(outputFolder)
layoutMode match {
case LayoutMode.Nested =>
Files.write(outputFolder.resolve("_index.md"), s"""
|---
|title: "${outputP.split('/').last}"
|---
|""".stripMargin.getBytes)
case _ => ()
}
}
Files.write(
outputRoot.resolve(s"${pkgToUrl(pkg.name)}.md"),
outputRoot.resolve(s"${outputP}.md"),
contents.getBytes
)
}
Expand Down

0 comments on commit 4ca0929

Please sign in to comment.