123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?js
- var params = obj;
- /* sort subparams under their parent params (like opts.classname) */
- var parentParam = null;
- params.forEach(function(param, i) {
- var paramRegExp;
- if (!param) {
- return;
- }
- if (parentParam && parentParam.name && param.name) {
- try {
- paramRegExp = new RegExp('^(?:' + parentParam.name + '(?:\\[\\])*)\\.(.+)$');
- }
- catch (e) {
- // there's probably a typo in the JSDoc comment that resulted in a weird
- // parameter name
- return;
- }
- if ( paramRegExp.test(param.name) ) {
- param.name = RegExp.$1;
- parentParam.subparams = parentParam.subparams || [];
- parentParam.subparams.push(param);
- params[i] = null;
- }
- else {
- parentParam = param;
- }
- }
- else {
- parentParam = param;
- }
- });
- /* determine if we need extra columns, "attributes" and "default" */
- params.hasAttributes = false;
- params.hasDefault = false;
- params.hasName = false;
- params.forEach(function(param) {
- if (!param) { return; }
- if (param.optional || param.nullable || param.variable) {
- params.hasAttributes = true;
- }
- if (param.name) {
- params.hasName = true;
- }
- if (typeof param.defaultvalue !== 'undefined') {
- params.hasDefault = true;
- }
- });
- ?>
- <table class="params">
- <thead>
- <tr>
- <?js if (params.hasName) {?>
- <th>Name</th>
- <?js } ?>
- <th>Type</th>
- <?js if (params.hasAttributes) {?>
- <th>Attributes</th>
- <?js } ?>
- <?js if (params.hasDefault) {?>
- <th>Default</th>
- <?js } ?>
- <th class="last">Description</th>
- </tr>
- </thead>
- <tbody>
- <?js
- var self = this;
- params.forEach(function(param) {
- if (!param) { return; }
- ?>
- <tr>
- <?js if (params.hasName) {?>
- <td class="name"><code><?js= param.name ?></code></td>
- <?js } ?>
- <td class="type">
- <?js if (param.type && param.type.names) {?>
- <?js= self.partial('type.tmpl', param.type.names) ?>
- <?js } ?>
- </td>
- <?js if (params.hasAttributes) {?>
- <td class="attributes">
- <?js if (param.optional) { ?>
- <optional><br>
- <?js } ?>
- <?js if (param.nullable) { ?>
- <nullable><br>
- <?js } ?>
- <?js if (param.variable) { ?>
- <repeatable><br>
- <?js } ?>
- </td>
- <?js } ?>
- <?js if (params.hasDefault) {?>
- <td class="default">
- <?js if (typeof param.defaultvalue !== 'undefined') { ?>
- <?js= self.htmlsafe(param.defaultvalue) ?>
- <?js } ?>
- </td>
- <?js } ?>
- <td class="description last"><?js= param.description ?><?js if (param.subparams) { ?>
- <h6>Properties</h6>
- <?js= self.partial('params.tmpl', param.subparams) ?>
- <?js } ?></td>
- </tr>
- <?js }); ?>
- </tbody>
- </table>
|