에서 epydoc 또는/및 pylint을 실행하는 빌더는 어떻게 작성합니까?scons 파일에서 epydoc 및/또는 pylint 빌더를 실행하십시오.
0
A
답변
0
큰 프로젝트에서 이식 가능한 다른 방법이 있습니다. 주요 SConstruct
파일에서
# -*- 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
, 추가 :
첫째로 site_scons/site_tools
에서 epydoc.py
(이제까지 당신이 그 있거나)를 정의하여 SConstruct
파일에
import epdoc
env.Tool("epydoc")
다음을하거나, SConscript
개의 파일을 만들면 다음과 같은 문서를 작성할 수 있습니다.
참고 : ctags와 pylint에 대해 동일한 작업을 수행 할 수 있습니다.
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)
0
내가 Brady의 answer을 기반으로 사용하여 종료 것입니다. 내가 페도라에서 실행하고 있고 코드가 이렇게 내가 경로를 가정 할 수 있습니다 다른 곳에서 실행 방법 epydoc를 설치하는 방법에 대해 걱정할 필요가 없습니다
## 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'."
참고. 좀 더 일반적인 편집을 환영합니다.
왜 대상이 '더미'입니까? 실제 타겟을 사용하지 않는다면 SCons가 매번 epydoc을 실행할 때 문제가 될 수 있습니다. epydoc에 의해 생성 된 실제 파일로 대상을 지정할 수 있어야합니다. 그러면 SCons는 필요할 때만 실행합니다. – Brady
@ 브래디 : 그렇습니다. 그것은 최적 이하였다. 나는 전혀 다른 것을 사용하여 끝내었다. – Sardathrion