0

How would I create builders that runs epydoc or/and pylint from a scons built?

Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156

3 Answers3

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)
Ishq
  • 47
  • 1
  • 6
Brady
  • 10,207
  • 2
  • 20
  • 59
0

Here is what I ended up using, based on Brady's answer.

## 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'."

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.

Community
  • 1
  • 1
Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156
  • Why do you have the target = 'dummy' ? If you're not using a real target, that could be problematic as SCons will run epydoc everytime, even though it doesnt need to. You should be able to specify the target as the actual files generated by epydoc, then SCons will only execute it when it needs to. – Brady Aug 03 '12 at 10:41
  • @Brady: Indeed. It was sub optimal. I ended up using something utterly different. – Sardathrion - against SE abuse Aug 03 '12 at 12:54
0

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

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

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.

Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156