我对如何在 Play 上运行 scaladoc 感到有点困惑!框架项目。似乎有很多错综复杂的问题需要解释,而我没有成功。
有我缺少的教程吗?您是否需要添加 sbt 或构建工具以使其合理?
我对如何在 Play 上运行 scaladoc 感到有点困惑!框架项目。似乎有很多错综复杂的问题需要解释,而我没有成功。
有我缺少的教程吗?您是否需要添加 sbt 或构建工具以使其合理?
在具有 Playframework 2.2.0 的项目中,只需使用以下命令:
clean
doc
doc 的答案是(仅当您使用 clean 时)iE
主要的 Scala API 文档到 .../myproject/target/scala-2.10/api... 然后在这个文件夹中打开 index.html。
如果您搜索所有任务,只需输入:
tasks -V
我想出了一个可行的解决方案,但并不完美。您需要运行应用程序来为模板生成 Scala 代码。然后使用下面的代码运行“play scaladoc”。
添加 'play/framework/pym/play/commands/scaladoc.py' 的内容:
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."