=== SCons ===

[#17867] Adds option to SCONS to generate Python API documentation

Added patch from Brandano with some small improvements (BF_DOCDIR, clean) by yours truly.

To use make sure you have epydoc installed. Enable with WITH_BF_BPYDOC=1.
This commit is contained in:
Nathan Letwory 2008-10-19 22:01:46 +00:00
parent 3544a4bd36
commit f1f27c0350
11 changed files with 59 additions and 6 deletions

@ -277,15 +277,15 @@ if 'blenderlite' in B.targets:
env['WITH_BF_BINRELOC'] = False env['WITH_BF_BINRELOC'] = False
env['BF_BUILDINFO'] = False env['BF_BUILDINFO'] = False
env['BF_NO_ELBEEM'] = True env['BF_NO_ELBEEM'] = True
# lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
#B.root_build_dir = B.arguments.get('BF_BUILDDIR', '..'+os.sep+'build'+os.sep+platform+os.sep) #B.root_build_dir = B.arguments.get('BF_BUILDDIR', '..'+os.sep+'build'+os.sep+platform+os.sep)
B.root_build_dir = env['BF_BUILDDIR'] B.root_build_dir = env['BF_BUILDDIR']
env['BUILDDIR'] = B.root_build_dir B.doc_build_dir = env['BF_DOCDIR']
if not B.root_build_dir[-1]==os.sep: if not B.root_build_dir[-1]==os.sep:
B.root_build_dir += os.sep B.root_build_dir += os.sep
if not B.doc_build_dir[-1]==os.sep:
B.doc_build_dir += os.sep
# We do a shortcut for clean when no quicklist is given: just delete # We do a shortcut for clean when no quicklist is given: just delete
# builddir without reading in SConscripts # builddir without reading in SConscripts
@ -294,8 +294,18 @@ if 'clean' in B.targets:
do_clean = True do_clean = True
if not quickie and do_clean: if not quickie and do_clean:
if os.path.exists(B.doc_build_dir):
print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
dirs = os.listdir(B.doc_build_dir)
for entry in dirs:
if os.path.isdir(B.doc_build_dir + entry) == 1:
print "clean dir %s"%(B.doc_build_dir+entry)
shutil.rmtree(B.doc_build_dir+entry)
else: # remove file
print "remove file %s"%(B.doc_build_dir+entry)
os.remove(B.root_build_dir+entry)
if os.path.exists(B.root_build_dir): if os.path.exists(B.root_build_dir):
print B.bc.HEADER+'Cleaning...'+B.bc.ENDC print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
dirs = os.listdir(B.root_build_dir) dirs = os.listdir(B.root_build_dir)
for entry in dirs: for entry in dirs:
if os.path.isdir(B.root_build_dir + entry) == 1: if os.path.isdir(B.root_build_dir + entry) == 1:
@ -321,6 +331,8 @@ if not os.path.isdir ( B.root_build_dir):
os.makedirs ( B.root_build_dir + 'extern' ) os.makedirs ( B.root_build_dir + 'extern' )
os.makedirs ( B.root_build_dir + 'lib' ) os.makedirs ( B.root_build_dir + 'lib' )
os.makedirs ( B.root_build_dir + 'bin' ) os.makedirs ( B.root_build_dir + 'bin' )
if not os.path.isdir(B.doc_build_dir):
os.makedirs ( B.doc_build_dir )
Help(opts.GenerateHelpText(env)) Help(opts.GenerateHelpText(env))
@ -565,5 +577,6 @@ if not env['WITHOUT_BF_INSTALL']:
# TODO: build stubs and link into blenderplayer # TODO: build stubs and link into blenderplayer
#------------ EPYDOC #------------ EPYDOC
# TODO: run epydoc if env['WITH_BF_BPYDOC']:
SConscript(['source/blender/python/api2_2x/doc/SConscript'])

@ -268,3 +268,4 @@ BF_DEBUG_FLAGS = '-g'
BF_BUILDDIR='../build/darwin' BF_BUILDDIR='../build/darwin'
BF_INSTALLDIR='../install/darwin' BF_INSTALLDIR='../install/darwin'
BF_DOCDIR='../install/doc'

@ -205,6 +205,7 @@ BF_DEBUG_FLAGS = '-g'
BF_BUILDDIR = '../build/linux2' BF_BUILDDIR = '../build/linux2'
BF_INSTALLDIR='../install/linux2' BF_INSTALLDIR='../install/linux2'
BF_DOCDIR='../install/doc'
#Link against pthread #Link against pthread

@ -148,3 +148,4 @@ BF_DEBUG_FLAGS= ''
BF_BUILDDIR = '../build/linuxcross' BF_BUILDDIR = '../build/linuxcross'
BF_INSTALLDIR='../install/linuxcross' BF_INSTALLDIR='../install/linuxcross'
BF_DOCDIR='../install/doc'

@ -163,3 +163,4 @@ BF_DEBUG_FLAGS = '-g'
BF_BUILDDIR='../build/openbsd3' BF_BUILDDIR='../build/openbsd3'
BF_INSTALLDIR='../install/openbsd3' BF_INSTALLDIR='../install/openbsd3'
BF_DOCDIR='../install/doc'

@ -177,6 +177,7 @@ BF_DEBUG_FLAGS = ''
BF_BUILDDIR = '../build/sunos5' BF_BUILDDIR = '../build/sunos5'
BF_INSTALLDIR='../install/sunos5' BF_INSTALLDIR='../install/sunos5'
BF_DOCDIR='../install/doc'
PLATFORM_LINKFLAGS = [''] PLATFORM_LINKFLAGS = ['']

@ -167,3 +167,4 @@ BF_PROFILE = 'false'
BF_BUILDDIR = '..\\build\\win32-mingw' BF_BUILDDIR = '..\\build\\win32-mingw'
BF_INSTALLDIR='..\\install\\win32-mingw' BF_INSTALLDIR='..\\install\\win32-mingw'
BF_DOCDIR = '..\\install\\doc'

@ -187,3 +187,4 @@ PLATFORM_LINKFLAGS = '''
BF_BUILDDIR = '..\\build\\win32-vc' BF_BUILDDIR = '..\\build\\win32-vc'
BF_INSTALLDIR='..\\install\\win32-vc' BF_INSTALLDIR='..\\install\\win32-vc'
BF_DOCDIR='..\\install\\doc'

@ -0,0 +1,28 @@
#!/usr/bin/python
Import ('env')
from optparse import OptionParser
try:
import epydoc
except ImportError:
print "No epydoc install detected, Python API Docs will not be generated "
if epydoc:
from epydoc.docbuilder import build_doc_index
from epydoc import cli
names = env.Glob("source/blender/python/api2_2x/doc/[A-Z]*.py")
docindex = build_doc_index(names)
optvalues = cli.OPTION_DEFAULTS
optvalues["verbose"] = 1
optvalues["target"] = env["BF_DOCDIR"]+"/BPY_API/"
optvalues["url"] = "http://www.blender.org"
optvalues["top"] = "API_intro"
optvalues["name"] = "Blender"
optvalues["noprivate"] = 1
optvalues["noframes"] = 1
optvalues["names"] = names
optparser = OptionParser()
optparser.set_defaults(**optvalues)
(options, args) = optparser.parse_args()
cli.write_html(docindex, options)

@ -35,6 +35,7 @@ GetBuildPath = SConsEnvironment.GetBuildPath
# a few globals # a few globals
root_build_dir = '' root_build_dir = ''
doc_build_dir = ''
quickie = None # Anything else than None if BF_QUICK has been passed quickie = None # Anything else than None if BF_QUICK has been passed
quicklist = [] # The list of libraries/programs to compile during a quickie quicklist = [] # The list of libraries/programs to compile during a quickie
program_list = [] # A list holding Nodes to final binaries, used to create installs program_list = [] # A list holding Nodes to final binaries, used to create installs

@ -68,6 +68,7 @@ def validate_arguments(args, bc):
'BF_FANCY', 'BF_QUIET', 'BF_FANCY', 'BF_QUIET',
'BF_X264_CONFIG', 'BF_X264_CONFIG',
'BF_XVIDCORE_CONFIG', 'BF_XVIDCORE_CONFIG',
'WITH_BF_BPYDOC',
] ]
arg_list = ['BF_DEBUG', 'BF_QUIET', 'BF_CROSS', 'BF_UPDATE', arg_list = ['BF_DEBUG', 'BF_QUIET', 'BF_CROSS', 'BF_UPDATE',
@ -75,7 +76,8 @@ def validate_arguments(args, bc):
'BF_BUILDDIR', 'BF_FANCY', 'BF_QUICK', 'BF_PROFILE', 'BF_BUILDDIR', 'BF_FANCY', 'BF_QUICK', 'BF_PROFILE',
'BF_DEBUG_FLAGS', 'BF_BSC', 'BF_CONFIG', 'BF_DEBUG_FLAGS', 'BF_BSC', 'BF_CONFIG',
'BF_PRIORITYLIST', 'BF_BUILDINFO','CC', 'CXX', 'BF_QUICKDEBUG', 'BF_PRIORITYLIST', 'BF_BUILDINFO','CC', 'CXX', 'BF_QUICKDEBUG',
'BF_LISTDEBUG', 'LCGDIR', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG'] 'BF_LISTDEBUG', 'LCGDIR', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG',
'BF_DOCDIR']
all_list = opts_list + arg_list all_list = opts_list + arg_list
okdict = {} okdict = {}
@ -335,6 +337,7 @@ def read_opts(cfg, args):
('BF_BUILDDIR', 'Build dir', ''), ('BF_BUILDDIR', 'Build dir', ''),
('BF_INSTALLDIR', 'Installation dir', ''), ('BF_INSTALLDIR', 'Installation dir', ''),
('BF_DOCDIR', 'Dir where BPy documentation will be created', ''),
('CC', 'C compiler to use', ''), ('CC', 'C compiler to use', ''),
('CXX', 'C++ compiler to use', ''), ('CXX', 'C++ compiler to use', ''),
@ -350,6 +353,7 @@ def read_opts(cfg, args):
('BF_X264_CONFIG', 'configuration flags for x264', ''), ('BF_X264_CONFIG', 'configuration flags for x264', ''),
('BF_XVIDCORE_CONFIG', 'configuration flags for xvidcore', ''), ('BF_XVIDCORE_CONFIG', 'configuration flags for xvidcore', ''),
(BoolOption('WITH_BF_BPYDOC', 'Generate BPY API documentation', 'false')),
('BF_CONFIG', 'SCons python config file used to set default options', 'user_config.py'), ('BF_CONFIG', 'SCons python config file used to set default options', 'user_config.py'),