Skip to content

Commit

Permalink
basic include functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
TiarkRompf committed Aug 24, 2014
1 parent eb6fb7e commit e5a0fdc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/scala/me/grison/scalocco/Scalocco.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ object Scalocco extends Markdown {
// Reading a comment line `//` or ` * ` if inside `Scaladoc`
//} else if (line.matches("^\\s*//.*") || inScalaDoc) {
} else if (inScalaDoc) {
// if we did had code, store the code and documentation in the resulting section list
// if we had code, store the code and documentation in the resulting section list
if (hasCode) {
val documentation = scaladocIfNeeded(doc)
sections ::= Section(documentation, code.toString)
Expand All @@ -201,7 +201,15 @@ object Scalocco extends Markdown {
code = new StringBuilder
}
val cleaned = line.replaceFirst(if (inScalaDoc) "^\\s*[*]" else "^\\s*//", "")
doc.append(cleaned).append("\n")

val cmd = ".. includecode:: "
if (cleaned.trim.startsWith(cmd)) {
val filename = cleaned.trim.substring(cmd.length)
Source.fromFile(new File(source.getParent,filename)).getLines().foreach { inc =>
doc.append(" ").append(inc).append("\n")
}
} else
doc.append(cleaned).append("\n")
} else {
hasCode = true
if (!code.isEmpty || !line.trim.isEmpty)
Expand Down

0 comments on commit e5a0fdc

Please sign in to comment.