diff options
Diffstat (limited to 'o3d/documentation/build_docs.py')
-rwxr-xr-x | o3d/documentation/build_docs.py | 89 |
1 files changed, 53 insertions, 36 deletions
diff --git a/o3d/documentation/build_docs.py b/o3d/documentation/build_docs.py index c309996..3c96852 100755 --- a/o3d/documentation/build_docs.py +++ b/o3d/documentation/build_docs.py @@ -44,6 +44,8 @@ import re _java_exe = ''
+_output_dir = ''
+_third_party_dir = ''
_script_path = os.path.dirname(os.path.realpath(__file__))
_js_copyright = """
/*
@@ -81,9 +83,9 @@ _js_copyright = """ GlobalsDict = { }
-def MakePath(file_path):
- """Makes a path absolute given a path relativel to this script."""
- return os.path.join(_script_path, file_path)
+def MakePath(*file_paths):
+ """Makes a path absolute given a path relative to this script."""
+ return os.path.join(_script_path, *file_paths)
def UpdateGlobals(dict):
@@ -160,11 +162,10 @@ def AppendBasePath(folder, filenames): def RunNixysa(idl_files, generate, output_dir, nixysa_options):
"""Executes Nixysa."""
- python_exe = 'python'
Execute([
- python_exe,
- MakePath('../third_party/nixysa/codegen.py'),
- '--binding-module=o3d:%s' % MakePath('../plugin/o3d_binding.py'),
+ sys.executable,
+ MakePath(_third_party_dir, 'nixysa', 'codegen.py'),
+ '--binding-module=o3d:%s' % MakePath('..', 'plugin', 'o3d_binding.py'),
'--generate=' + generate,
'--force',
'--output-dir=' + output_dir] +
@@ -175,7 +176,7 @@ def RunNixysa(idl_files, generate, output_dir, nixysa_options): def RunJSDocToolkit(js_files, ezt_output_dir, html_output_dir, prefix, mode,
baseURL, topURL, exports_file):
"""Executes the JSDocToolkit."""
- list_filename = MakePath('../scons-out/docs/obj/doclist.conf')
+ list_filename = MakePath(_output_dir, 'doclist.conf')
f = open(list_filename, 'w')
f.write('{\nD:{\n')
f.write('prefix: "%s",\n' % prefix)
@@ -192,21 +193,24 @@ def RunJSDocToolkit(js_files, ezt_output_dir, html_output_dir, prefix, mode, f.write(']\n}\n')
f.close()
+ files_dir = MakePath(_third_party_dir, 'jsdoctoolkit', 'files')
Execute([
_java_exe,
- '-Djsdoc.dir=%s' % MakePath('../third_party/jsdoctoolkit/files'),
+ '-Djsdoc.dir=%s' % files_dir,
'-jar',
- MakePath('../third_party/jsdoctoolkit/files/jsrun.jar'),
- MakePath('../third_party/jsdoctoolkit/files/app/run.js'),
+ MakePath(files_dir, 'jsrun.jar'),
+ MakePath(files_dir, 'app', 'run.js'),
'-v',
- '-t=%s' % MakePath('./jsdoc-toolkit-templates//'),
+ '-t=%s' % MakePath('jsdoc-toolkit-templates'),
'-d=' + ezt_output_dir,
'-c=' + list_filename])
def DeleteOldDocs(docs_js_outpath):
- shutil.rmtree(docs_js_outpath);
-
+ try:
+ shutil.rmtree(docs_js_outpath);
+ except:
+ pass
def BuildJavaScriptForDocsFromIDLs(idl_files, output_dir):
RunNixysa(idl_files, 'jsheader', output_dir, ['--properties-equal-undefined'])
@@ -226,7 +230,7 @@ def BuildO3DDocsFromJavaScript(js_files, ezt_output_dir, html_output_dir): def BuildO3DJSDocs(js_files, ezt_output_dir, html_output_dir, exports_file):
RunJSDocToolkit(js_files, ezt_output_dir, html_output_dir, 'js_0_1_', 'o3djs',
- 'jsdocs/', '../', exports_file)
+ 'jsdocs', '..', exports_file)
def BuildO3DExternsFile(js_files_dir, extra_externs_file, externs_file):
@@ -261,7 +265,7 @@ def BuildCompiledO3DJS(o3djs_files, Execute([
_java_exe,
'-jar',
- MakePath('../../o3d-internal/jscomp/JSCompiler_deploy.jar'),
+ MakePath('..', '..', 'o3d-internal', 'jscomp', 'JSCompiler_deploy.jar'),
'--property_renaming', 'OFF',
'--variable_renaming', 'LOCAL',
'--strict',
@@ -294,35 +298,48 @@ def CopyStaticFiles(o3d_docs_ezt_outpath, o3d_docs_html_outpath): 'tab_r.gif',
'tab_b.gif']
for file in files:
- shutil.copyfile(MakePath('jsdoc-toolkit-templates/static/' + file),
+ shutil.copyfile(MakePath('jsdoc-toolkit-templates', 'static', file),
MakePath(os.path.join(o3d_docs_ezt_outpath, file)))
- shutil.copyfile(MakePath('jsdoc-toolkit-templates/static/' + file),
+ shutil.copyfile(MakePath('jsdoc-toolkit-templates', 'static', file),
MakePath(os.path.join(o3d_docs_html_outpath, file)))
-def main():
+def main(argv):
"""Builds the O3D API docs and externs and the o3djs docs."""
global _java_exe
- _java_exe = sys.argv[1]
+ _java_exe = argv[0]
+ global _third_party_dir
+ _third_party_dir = argv[1]
+
+ # Fix up the python path of subprocesses by setting PYTHONPATH.
+ pythonpath = os.pathsep.join([MakePath(_third_party_dir, 'gflags', 'python'),
+ MakePath(_third_party_dir, 'ply')])
+
+ orig_pythonpath = os.environ.get('PYTHONPATH')
+ if orig_pythonpath:
+ pythonpath = os.pathsep.join([pythonpath, orig_pythonpath])
+
+ os.environ['PYTHONPATH'] = pythonpath
- js_list_filename = MakePath('../samples/o3djs/js_list.scons')
- idl_list_filename = MakePath('../plugin/idl_list.scons')
+ js_list_filename = MakePath('..', 'samples', 'o3djs', 'js_list.scons')
+ idl_list_filename = MakePath('..', 'plugin', 'idl_list.scons')
js_list_basepath = os.path.dirname(js_list_filename)
idl_list_basepath = os.path.dirname(idl_list_filename)
- outpath = '../scons-out/docs/obj/'
- docs_outpath = '../scons-out/docs/obj/documentation/'
- docs_js_outpath = MakePath(docs_outpath + 'apijs')
- externs_js_outpath = MakePath(outpath + '/externs')
- o3d_docs_ezt_outpath = MakePath(docs_outpath + 'reference')
- o3d_docs_html_outpath = MakePath(docs_outpath + 'local_html')
- o3djs_docs_ezt_outpath = MakePath(docs_outpath + 'reference/jsdocs')
- o3djs_docs_html_outpath = MakePath(docs_outpath + 'local_html/jsdocs')
- o3d_externs_path = MakePath(outpath + 'o3d-externs.js')
- o3djs_exports_path = MakePath(outpath + 'o3d-exports.js')
- compiled_o3djs_outpath = MakePath(docs_outpath + 'base.js')
- externs_path = MakePath('externs/externs.js')
- o3d_extra_externs_path = MakePath('externs/o3d-extra-externs.js')
+ global _output_dir
+ _output_dir = argv[2]
+ docs_outpath = os.path.join(_output_dir, 'documentation')
+ docs_js_outpath = MakePath(docs_outpath, 'apijs')
+ externs_js_outpath = MakePath(_output_dir, 'externs')
+ o3d_docs_ezt_outpath = MakePath(docs_outpath, 'reference')
+ o3d_docs_html_outpath = MakePath(docs_outpath, 'local_html')
+ o3djs_docs_ezt_outpath = MakePath(docs_outpath, 'reference', 'jsdocs')
+ o3djs_docs_html_outpath = MakePath(docs_outpath, 'local_html', 'jsdocs')
+ o3d_externs_path = MakePath(_output_dir, 'o3d-externs.js')
+ o3djs_exports_path = MakePath(_output_dir, 'o3d-exports.js')
+ compiled_o3djs_outpath = MakePath(docs_outpath, 'base.js')
+ externs_path = MakePath('externs', 'externs.js')
+ o3d_extra_externs_path = MakePath('externs', 'o3d-extra-externs.js')
Import(js_list_filename)
Import(idl_list_filename)
@@ -358,4 +375,4 @@ def main(): if __name__ == '__main__':
- main()
+ main(sys.argv[1:])
|