From f1f27c0350bbff1aa7f444f75eab294dd6b78e16 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 19 Oct 2008 22:01:46 +0000 Subject: [PATCH] === 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. --- SConstruct | 23 ++++++++++++---- config/darwin-config.py | 1 + config/linux2-config.py | 1 + config/linuxcross-config.py | 1 + config/openbsd3-config.py | 1 + config/sunos5-config.py | 1 + config/win32-mingw-config.py | 1 + config/win32-vc-config.py | 1 + source/blender/python/api2_2x/doc/SConscript | 28 ++++++++++++++++++++ tools/Blender.py | 1 + tools/btools.py | 6 ++++- 11 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 source/blender/python/api2_2x/doc/SConscript diff --git a/SConstruct b/SConstruct index e7d4a4e77bd..f15aa8bfa22 100644 --- a/SConstruct +++ b/SConstruct @@ -277,15 +277,15 @@ if 'blenderlite' in B.targets: env['WITH_BF_BINRELOC'] = False env['BF_BUILDINFO'] = False env['BF_NO_ELBEEM'] = True - - # 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 = 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: 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 # builddir without reading in SConscripts @@ -294,8 +294,18 @@ if 'clean' in B.targets: do_clean = True 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): - 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) for entry in dirs: 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 + 'lib' ) 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)) @@ -565,5 +577,6 @@ if not env['WITHOUT_BF_INSTALL']: # TODO: build stubs and link into blenderplayer #------------ EPYDOC -# TODO: run epydoc +if env['WITH_BF_BPYDOC']: + SConscript(['source/blender/python/api2_2x/doc/SConscript']) diff --git a/config/darwin-config.py b/config/darwin-config.py index 0eb275dcaf4..cc6c6ef76af 100644 --- a/config/darwin-config.py +++ b/config/darwin-config.py @@ -268,3 +268,4 @@ BF_DEBUG_FLAGS = '-g' BF_BUILDDIR='../build/darwin' BF_INSTALLDIR='../install/darwin' +BF_DOCDIR='../install/doc' diff --git a/config/linux2-config.py b/config/linux2-config.py index 2b7bf074f83..74853de70b6 100644 --- a/config/linux2-config.py +++ b/config/linux2-config.py @@ -205,6 +205,7 @@ BF_DEBUG_FLAGS = '-g' BF_BUILDDIR = '../build/linux2' BF_INSTALLDIR='../install/linux2' +BF_DOCDIR='../install/doc' #Link against pthread diff --git a/config/linuxcross-config.py b/config/linuxcross-config.py index 9d58512151b..13f477d21f3 100644 --- a/config/linuxcross-config.py +++ b/config/linuxcross-config.py @@ -148,3 +148,4 @@ BF_DEBUG_FLAGS= '' BF_BUILDDIR = '../build/linuxcross' BF_INSTALLDIR='../install/linuxcross' +BF_DOCDIR='../install/doc' diff --git a/config/openbsd3-config.py b/config/openbsd3-config.py index 5ef3d90f168..1cd93008561 100644 --- a/config/openbsd3-config.py +++ b/config/openbsd3-config.py @@ -163,3 +163,4 @@ BF_DEBUG_FLAGS = '-g' BF_BUILDDIR='../build/openbsd3' BF_INSTALLDIR='../install/openbsd3' +BF_DOCDIR='../install/doc' diff --git a/config/sunos5-config.py b/config/sunos5-config.py index bfb1513ca3f..a5ba33e44cd 100644 --- a/config/sunos5-config.py +++ b/config/sunos5-config.py @@ -177,6 +177,7 @@ BF_DEBUG_FLAGS = '' BF_BUILDDIR = '../build/sunos5' BF_INSTALLDIR='../install/sunos5' +BF_DOCDIR='../install/doc' PLATFORM_LINKFLAGS = [''] diff --git a/config/win32-mingw-config.py b/config/win32-mingw-config.py index 4ff93bf7078..65b7beb79ad 100644 --- a/config/win32-mingw-config.py +++ b/config/win32-mingw-config.py @@ -167,3 +167,4 @@ BF_PROFILE = 'false' BF_BUILDDIR = '..\\build\\win32-mingw' BF_INSTALLDIR='..\\install\\win32-mingw' +BF_DOCDIR = '..\\install\\doc' \ No newline at end of file diff --git a/config/win32-vc-config.py b/config/win32-vc-config.py index 1b7737ed004..14fd8b3aac7 100644 --- a/config/win32-vc-config.py +++ b/config/win32-vc-config.py @@ -187,3 +187,4 @@ PLATFORM_LINKFLAGS = ''' BF_BUILDDIR = '..\\build\\win32-vc' BF_INSTALLDIR='..\\install\\win32-vc' +BF_DOCDIR='..\\install\\doc' diff --git a/source/blender/python/api2_2x/doc/SConscript b/source/blender/python/api2_2x/doc/SConscript new file mode 100644 index 00000000000..49d20894c58 --- /dev/null +++ b/source/blender/python/api2_2x/doc/SConscript @@ -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) + diff --git a/tools/Blender.py b/tools/Blender.py index 330a3713817..9baeb374af8 100644 --- a/tools/Blender.py +++ b/tools/Blender.py @@ -35,6 +35,7 @@ GetBuildPath = SConsEnvironment.GetBuildPath # a few globals root_build_dir = '' +doc_build_dir = '' quickie = None # Anything else than None if BF_QUICK has been passed quicklist = [] # The list of libraries/programs to compile during a quickie program_list = [] # A list holding Nodes to final binaries, used to create installs diff --git a/tools/btools.py b/tools/btools.py index 04ff9bcd914..9db7d48cc98 100755 --- a/tools/btools.py +++ b/tools/btools.py @@ -68,6 +68,7 @@ def validate_arguments(args, bc): 'BF_FANCY', 'BF_QUIET', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG', + 'WITH_BF_BPYDOC', ] 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_DEBUG_FLAGS', 'BF_BSC', 'BF_CONFIG', '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 okdict = {} @@ -335,6 +337,7 @@ def read_opts(cfg, args): ('BF_BUILDDIR', 'Build dir', ''), ('BF_INSTALLDIR', 'Installation dir', ''), + ('BF_DOCDIR', 'Dir where BPy documentation will be created', ''), ('CC', '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_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'),