summaryrefslogtreecommitdiffstats
path: root/o3d/documentation
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-20 19:21:35 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-20 19:21:35 +0000
commit756ac71a81a5be5e4e1b23c2734b5631848fe0fc (patch)
tree68fbc1816ae4233f2258edc08ae3a0588393a477 /o3d/documentation
parentd900c2c753c9eb478a0229a21b31983ce00cc5d7 (diff)
downloadchromium_src-756ac71a81a5be5e4e1b23c2734b5631848fe0fc.zip
chromium_src-756ac71a81a5be5e4e1b23c2734b5631848fe0fc.tar.gz
chromium_src-756ac71a81a5be5e4e1b23c2734b5631848fe0fc.tar.bz2
The compiled version of the o3djs libs WORK!
Sadly there is some really strange voodoo to make it work. util.js was using document.getElementsByTagName('script') and it was not returning all the scripts. Lots of dump() lines later the voodoo of calling document.getElementsByTagName('script').length (the length is important) in some place earlier in the code fixes the issue. Also, added the copyright to the compiled file Added parameter docs Review URL: http://codereview.chromium.org/159049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/documentation')
-rwxr-xr-xo3d/documentation/build_docs.py72
-rw-r--r--o3d/documentation/jsdoc-toolkit-templates/class.tmpl47
-rw-r--r--o3d/documentation/jsdoc-toolkit-templates/publish.js37
3 files changed, 133 insertions, 23 deletions
diff --git a/o3d/documentation/build_docs.py b/o3d/documentation/build_docs.py
index dd995de..cc531a6 100755
--- a/o3d/documentation/build_docs.py
+++ b/o3d/documentation/build_docs.py
@@ -45,6 +45,38 @@ import re
_java_exe = ''
_script_path = os.path.dirname(os.path.realpath(__file__))
+_js_copyright = """
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+"""
GlobalsDict = { }
@@ -202,9 +234,23 @@ def BuildO3DExternsFile(js_files_dir, extra_externs_file, externs_file):
filenames = (glob.glob(os.path.join(js_files_dir, '*.js')) +
[extra_externs_file])
for filename in filenames:
+ print "-----", filename
infile = open(filename, 'r')
- outfile.write(infile.read())
+ lines = infile.readlines()
infile.close()
+ filtered = []
+ skipping = False
+ # strip out @o3dparameter stuff
+ for line in lines:
+ if skipping:
+ if line.startswith('* @') or line.startswith(' */'):
+ skipping = False
+ if not skipping:
+ if line.startswith(' * @o3dparameter'):
+ skipping = True
+ if not skipping:
+ filtered.append(line)
+ outfile.write(''.join(filtered))
outfile.close()
@@ -218,36 +264,24 @@ def BuildCompiledO3DJS(o3djs_files,
MakePath('../../o3d-internal/jscomp/JSCompiler_deploy.jar'),
'--property_renaming', 'OFF',
'--variable_renaming', 'LOCAL',
- '--remove_dead_assignments', 'false',
- '--remove_dead_code', 'false',
- '--remove_unused_vars', 'false',
- '--remove_unused_prototype_props', 'false',
- #'--check_missing_return', 'true',
- #
- '--collapse_variable_declarations', 'false',
- '--disable_function_inline', 'true',
- '--noextract_prototype_member_decl', 'true',
- #'--disable_convert_to_dotted_properties', 'true',
- #'--inline_functions', 'false',
- # TODO(gman): Remove the flags below once the compiled js actually works.
- '--pretty_print',
- #'--print_input_delimiter', 'true',
- #'--strip_whitespace_and_comments_only', 'true',
- ##'--logging_level', '',
'--strict',
'--externs=%s' % externs_path,
('--externs=%s' % o3d_externs_js_path),
('--js_output_file=%s' % compiled_o3djs_outpath)] +
['-js=%s' % (x, ) for x in o3djs_files]);
- # strip out goog.exportSymbol and o3djs.require stuff
+ # strip out goog.exportSymbol and move o3djs.require to end
file = open(compiled_o3djs_outpath, 'r')
contents = file.read()
file.close()
contents = re.sub(r'goog.exportSymbol\([^\)]*\);\n', '', contents)
- contents = re.sub(r'o3djs.require\([^\)]*\);\n', '', contents)
+ requires = set(re.findall(r'o3djs.require\([^\)]*\);', contents))
+ contents = re.sub(r'o3djs.require\([^\)]*\);', '', contents)
file = open(compiled_o3djs_outpath, 'w')
+ file.write(_js_copyright)
file.write(contents)
+ file.write('\n')
+ file.write('\n'.join(requires))
file.close()
diff --git a/o3d/documentation/jsdoc-toolkit-templates/class.tmpl b/o3d/documentation/jsdoc-toolkit-templates/class.tmpl
index 1f30c40..2ebc03a 100644
--- a/o3d/documentation/jsdoc-toolkit-templates/class.tmpl
+++ b/o3d/documentation/jsdoc-toolkit-templates/class.tmpl
@@ -83,7 +83,6 @@ thisClass = data;
</table>
</if>
-
<!-- ========== METHOD SUMMARY =========== -->
<if test="thisClass.methods.length">
{! var ownMethods = data.methods.sort(makeSortby("name")); !}
@@ -105,7 +104,7 @@ thisClass = data;
</if>
</if>
-<!-- =========== FIELD SUMMARY =========== -->
+<!-- =========== PROPERTY SUMMARY =========== -->
{! var ownProperties = getPublicProperties(data).sort(makeSortby("name")); !}
<if test="ownProperties.length">
<h2>Public Properties</h2>
@@ -123,7 +122,22 @@ thisClass = data;
</table>
</if>
-<!-- =========== END FIELD SUMMARY =========== -->
+<!-- ========== PARAMETER SUMMARY =========== -->
+{! var ownParameters = getParameters(data); !}
+<if test="ownParameters.length">
+ <h2>Parameters</h2>
+ <table class="summary">
+ <for each="param" in="ownParameters">
+ <tr>
+ <td class="type">
+ {+linkifyTypeSpec(makeName('[Param Summary]', thisClass.alias, param.name), param.type)+}
+ </td>
+ <td><a class="el" href="#param_{+param.name+}">{+param.name+}</a></td>
+ <td>{+linkifySingleType(makeName('[Param Summary inherit]'), param.parent)+}</td>
+ </tr>
+ </for>
+ </table>
+</if>
<!-- ========== CONSTRUCTOR DETAIL ============== -->
<if test="shouldWriteConstructor(data)">
@@ -352,6 +366,33 @@ thisClass = data;
</for>
</if>
+<!-- =========== PARAMETER DETAIL ============== -->
+
+<if test="defined(ownParameters) && ownParameters.length">
+ <hr/>
+ <h2>Parameter Documentation</h2>
+ <for each="param" in="ownParameters">
+ <a class="anchor" name="param_{+param.name+}"></a>
+ <div class="memitem">
+ <div class="memproto">
+ <table class="memname">
+ <tr>
+ <td class="memname">{+linkifyTypeSpec(makeName('[Param Detail]', thisClass.alias, param.name), param.type)+} {+param.name+}
+ {+ (param.parent == thisClass.alias) ? "" : ("[[]inherited from " + linkifySingleType(makeName('[Param Details inherit]'), param.parent) + "]") +}
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <div class="memdoc">
+ <p/>
+ {+sanitizeForEZT(param.desc)+}
+ </div>
+
+ </div>
+ </for>
+</if>
+
</div><!-- end contents -->
</div><!-- end doxygen-ref -->
diff --git a/o3d/documentation/jsdoc-toolkit-templates/publish.js b/o3d/documentation/jsdoc-toolkit-templates/publish.js
index 9070a1a..0899958 100644
--- a/o3d/documentation/jsdoc-toolkit-templates/publish.js
+++ b/o3d/documentation/jsdoc-toolkit-templates/publish.js
@@ -57,6 +57,7 @@ var g_outputMode;
var g_baseURL;
var g_topURL;
var g_templates = [];
+var g_o3dPropertyRE = /^(\w+)\s+(\w+)\s+/;
/**
* Called automatically by JsDoc Toolkit.
@@ -501,6 +502,40 @@ function getPropertyType(property) {
}
/**
+ * Gets the parameters for a class.
+ * Parameters are an o3d specific thing. We have to look for tags that
+ * start with @o3dparameter
+ * @param {!Symbol} symbol
+ */
+function getParameters(symbol) {
+ var params = [];
+ if (symbol.inheritsFrom.length) {
+ params = getParameters(getSymbol(symbol.inheritsFrom[0]));
+ }
+
+ var tags = symbol.comment.getTag('o3dparameter');
+ for (var ii = 0; ii < tags.length; ++ii) {
+ var tag = tags[ii];
+ var tagString = tag.toString();
+ var parts = tagString.match(g_o3dPropertyRE);
+ if (!parts) {
+ generateError('Malformed o3dparameter specification for ' + symbol.alias +
+ ' : "' + tag + '"');
+ } else {
+ var descString = tagString.substr(parts[0].length);
+ var param = {
+ name: parts[1],
+ type: 'o3d.' + parts[2],
+ desc: descString,
+ parent: symbol.alias,
+ };
+ params.push(param);
+ }
+ }
+ return params;
+}
+
+/**
* Converts [ to [[] for ezt files.
* Also converts '\n\n' to <br/></br>
* @param {string} str to sanitize.
@@ -906,7 +941,7 @@ function getSourcePath(symbol) {
*/
function getParentName(symbol) {
var parent = getSymbol(symbol.memberOf);
- return parent.isNamespace ? symbol.memberOf : parent.name;
+ return parent.isNamespace ? symbol.memberOf : parent.alias;
}
/**