Reputation: 323
I'm a bit stumped as to how to run scaladoc on a Play! framework project. It seems there are a lot of intricacies to account for, and I'm not having success.
Is there a tutorial I am missing? Do you need to add in sbt or a build tool to make it reasonable?
Upvotes: 2
Views: 1331
Reputation: 382
In a Project with Playframework 2.2.0 just use this commands:
clean
doc
The Answer of doc is (only if you use clean) i.E.
Main Scala API documentation to .../myproject/target/scala-2.10/api... Then open index.html in this folder.
If you search all tasks just type in:
tasks -V
Upvotes: 2
Reputation: 323
I came up with a solution that works, but not perfect. You need to run the app to generate the Scala code for the templates. Then run 'play scaladoc' with the code below.
Add 'play/framework/pym/play/commands/scaladoc.py' with contents:
import os, os.path
import shutil
import subprocess
from play.utils import *
COMMANDS = ['scaladoc', 'sd']
HELP = {
'scaladoc': 'Generate your application scaladoc'
}
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
play_env = kargs.get("env")
app.check()
modules = app.modules()
if not os.environ.has_key('SCALA_HOME'):
scaladoc_path = "scaladoc"
else:
scaladoc_path = os.path.normpath("%s/bin/scaladoc" % os.environ['SCALA_HOME'])
fileList = []
def add_scala_files(app_path):
for root, subFolders, files in os.walk(os.path.join(app_path, 'app')):
for file in files:
if file.endswith(".scala"):
fileList.append(os.path.join(root, file))
for root, subFolders, files in os.walk(os.path.join(app_path,
'tmp/generated')):
for file in files:
if file.endswith(".scala"):
fileList.append(os.path.join(root, file))
add_scala_files(app.path)
for module in modules:
add_scala_files(os.path.normpath(module))
outdir = os.path.join(app.path, 'scaladoc')
sout = open(os.path.join(app.log_path(), 'scaladoc.log'), 'w')
serr = open(os.path.join(app.log_path(), 'scaladoc.err'), 'w')
if (os.path.isdir(outdir)):
shutil.rmtree(outdir)
scaladoc_cmd = [scaladoc_path, '-classpath', app.cp_args(), '-d', outdir] + args + fileList
print "Generating scaladoc in " + outdir + "..."
subprocess.call(scaladoc_cmd, env=os.environ, stdout=sout, stderr=serr)
print "Done! You can open " + os.path.join(outdir, 'overview-tree.html') + " in your browser."
Upvotes: 1