Skip to content

Commit

Permalink
Minor fixes of the behavior:
Browse files Browse the repository at this point in the history
* added command line arguments check
* fixed generation, when given only one file (not a directory)
  • Loading branch information
laughedelic committed Jul 21, 2013
1 parent bf01413 commit 7b94112
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ temp*
dist
test-output
build.log
docs

# other scm
.svn
Expand Down
20 changes: 16 additions & 4 deletions src/main/scala/me/grison/scalocco/Scalocco.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,28 @@ object Scalocco extends Markdown {
def generateDoc(path: String, destPath: String) = {
val files = scalaFiles(path)
sources = files.toList
if (!new File(destPath).exists())
new File(destPath).mkdirs()
files.foreach(documentFile(_, path, destPath))

// if the given path is just a file, split the base part of it
val pathFile = new File(path)
val basePath = if (pathFile.isDirectory) path else pathFile.getParent

// create destination path, if it doesn't exist
val dest = new File(destPath)
if (!dest.exists()) dest.mkdirs()

files.foreach(documentFile(_, basePath, destPath))
}

/**
* Simply run **`scalocco`**.
* @param args the arguments to the program
*/
def main(args: Array[String]) {
generateDoc(args(0), Option(args(1)).getOrElse("./docs/"))
if(args.length == 0) println("Need an argument: path with sources")
else {
val path = args(0)
val destPath = if (args.length > 1) args(1) else "./docs/"
generateDoc(path, destPath)
}
}
}

0 comments on commit 7b94112

Please sign in to comment.