答案 0 :(得分:1)
您可以使用Command() builder代替创建自己的构建器。
例如,您可以按如下方式执行epydoc:
# SCons will substitute $SOURCE and $TARGET accordingly
# add any extra cmd line args you need to the cmd string
cmd = 'epydoc $SOURCE $TARGET'
env.Command(target = yourTarget, source = yourSourceFile_s, action = cmd)
答案 1 :(得分:0)
## Create epydoc!
import os.path
if os.path.isfile('/usr/bin/epydoc'):
sources = Split("__init__.py ook/ eek/ fubar/")
cmd = "epydoc -q --name 'Isotek Python Module collection' " + \
"--html --inheritance listed --graph all -o docs --css white " + \
"--parse-only --debug $SOURCES"
env.Command(target = Dir('docs'), source = sources, action = cmd)
else:
print "WARNING -- Cannot run epydoc so documentation will not be generated."
print "WARNING -- To install epydoc run 'sudo yum -y install epydoc'."
请注意,我在Fedora上运行,不需要担心其他地方运行的代码,因此我可以假设路径以及如何安装epydoc。欢迎进行更一般的编辑。
答案 2 :(得分:0)
这是另一种方法,可能更适合大型项目。
首先,在epydoc.py
中定义site_scons/site_tools
(或者你有的地方):
# -*- coding: utf-8 -*-
import SCons.Builder
import SCons.Action
def complain_epydoc(target, source, env):
print 'INFORMATION: epydoc binary was not found (see above). Documentation has not been built.'
def generate(env):
env['EPYDOC'] = find_epydoc(env)
if env['EPYDOC'] != None:
opts = '--quiet --html --inheritance listed --graph all --css white --parse-only '
env['EPYDOCCOM'] = '$EPYDOC ' + opts + '-o $TARGET $SOURCES'
env['BUILDERS']['epydoc'] = SCons.Builder.Builder(action=env['EPYDOCCOM'])
else:
env['BUILDERS']['epydoc'] = SCons.Builder.Builder(action=env.Action(complain_epydoc))
def find_epydoc(env):
b=env.WhereIs('epydoc')
if b == None:
print 'Searching for epydoc: not found. Documentation will not be built'
else:
print 'Searching for epydoc: ', b
return b
def exists(env):
if find_epydoc(env) == None:
return 0
return 1
在主SConstruct
文件中,添加:
import epdoc
env.Tool("epydoc")
然后,在您的SConstruct
文件或SConscript
文件中,您可以构建如下文档:
Alias('epydoc', env.epydoc(source=python_code_files, target=Dir('docs')))
注意:你可以为ctags和pylint做同样的事情,仅举几例。