Run Epydoc And/or Pylint Builders From Scons File
How would I create builders that runs epydoc or/and pylint from a scons built?
Solution 1:
You can use the Command() builder instead of creating your own builder.
For instance, you could execute epydoc as follows:
# 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)
Solution 2:
Here is what I ended up using, based on Brady's answer.
## Create epydoc!
import os.pathifos.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'."
Note that I am running on fedora and do not need to worry about the code running elsewhere thus I can assume the path and how to install epydoc. A more general edit is welcome.
Solution 3:
Here is another method, probably more portable to large projects.
First, define epydoc.py
in site_scons/site_tools
(or where ever you have those) to be:
# -*- coding: utf-8 -*-import SCons.Builder
import SCons.Action
defcomplain_epydoc(target, source, env):
print'INFORMATION: epydoc binary was not found (see above). Documentation has not been built.'defgenerate(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))
deffind_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
defexists(env):
if find_epydoc(env) == None:
return0return1
In the main SConstruct
file, add:
import epdoc
env.Tool("epydoc")
Then, in your SConstruct
file or SConscript
files, you can build documentation like so:
Alias('epydoc', env.epydoc(source=python_code_files, target=Dir('docs')))
Note: you could do the same thing for ctags and pylint, just to name a few.
Post a Comment for "Run Epydoc And/or Pylint Builders From Scons File"