scaladoc for Play! Scala模块的框架

时间:2011-12-10 00:24:27

标签: scala playframework sbt scaladoc

我对如何在Play上运行scaladoc感到有点难过!框架项目。似乎有很多错综复杂的问题需要考虑,而且我没有成功。

我缺少一个教程吗?您是否需要添加sbt或构建工具才能使其合理?

2 个答案:

答案 0 :(得分:2)

在使用Playframework 2.2.0的项目中,只需使用以下命令:

clean
doc

doc的答案是(只有你使用干净)i.E。

主要的Scala API文档... / myproject / target / scala-2.10 / api ... 然后在此文件夹中打开index.html。

如果您搜索所有任务,只需输入:

tasks -V

答案 1 :(得分:1)

我想出了一个有效的解决方案,但并不完美。您需要运行该应用程序以生成模板的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."