node-query/node_modules/jsdoc/templates/default/tmpl/properties.tmpl

109 lines
2.8 KiB
Cheetah
Raw Normal View History

2014-10-20 16:56:45 -04:00
<?js
2015-01-28 15:33:44 -05:00
var data = obj;
var props = data.subprops || data.properties;
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
/* sort subprops under their parent props (like opts.classname) */
var parentProp = null;
props.forEach(function(prop, i) {
if (!prop) { return; }
if ( parentProp && prop.name && prop.name.indexOf(parentProp.name + '.') === 0 ) {
prop.name = prop.name.substr(parentProp.name.length+1);
parentProp.subprops = parentProp.subprops || [];
parentProp.subprops.push(prop);
props[i] = null;
}
else {
parentProp = prop;
}
});
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
/* determine if we need extra columns, "attributes" and "default" */
props.hasAttributes = false;
props.hasDefault = false;
props.hasName = false;
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
props.forEach(function(prop) {
if (!prop) { return; }
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
if (prop.optional || prop.nullable) {
props.hasAttributes = true;
}
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
if (prop.name) {
props.hasName = true;
}
2014-10-22 10:11:40 -04:00
2015-01-28 15:33:44 -05:00
if (typeof prop.defaultvalue !== 'undefined' && !data.isEnum) {
2014-10-20 16:56:45 -04:00
props.hasDefault = true;
}
});
?>
<table class="props">
<thead>
2014-10-22 10:11:40 -04:00
<tr>
<?js if (props.hasName) {?>
<th>Name</th>
<?js } ?>
<th>Type</th>
<?js if (props.hasAttributes) {?>
<th>Attributes</th>
<?js } ?>
<?js if (props.hasDefault) {?>
<th>Default</th>
<?js } ?>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<?js
2014-10-20 16:56:45 -04:00
var self = this;
2014-10-22 10:11:40 -04:00
props.forEach(function(prop) {
if (!prop) { return; }
?>
2014-10-20 16:56:45 -04:00
<tr>
<?js if (props.hasName) {?>
<td class="name"><code><?js= prop.name ?></code></td>
<?js } ?>
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
<td class="type">
<?js if (prop.type && prop.type.names) {?>
<?js= self.partial('type.tmpl', prop.type.names) ?>
<?js } ?>
</td>
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
<?js if (props.hasAttributes) {?>
<td class="attributes">
<?js if (prop.optional) { ?>
&lt;optional><br>
<?js } ?>
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
<?js if (prop.nullable) { ?>
&lt;nullable><br>
<?js } ?>
</td>
<?js } ?>
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
<?js if (props.hasDefault) {?>
<td class="default">
<?js if (typeof prop.defaultvalue !== 'undefined') { ?>
<?js= self.htmlsafe(prop.defaultvalue) ?>
<?js } ?>
</td>
<?js } ?>
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
<td class="description last"><?js= prop.description ?><?js if (prop.subprops) { ?>
2015-01-28 15:33:44 -05:00
<h6>Properties</h6><?js= self.partial('properties.tmpl', prop) ?>
2014-10-20 16:56:45 -04:00
<?js } ?></td>
</tr>
2014-10-22 10:11:40 -04:00
<?js }); ?>
</tbody>
2015-01-28 15:33:44 -05:00
</table>