Fixed bug with names["quoted"]. Tweaks to default template.

This commit is contained in:
Michael Mathews 2011-01-03 22:48:04 +00:00
parent 1d18f3950d
commit 6d4c1e61c1
7 changed files with 116 additions and 43 deletions

View File

@ -7,13 +7,25 @@
}
DocSet.prototype.getByLongname = function(longname) {
var found = [];
for (var i = 0, l = this.doclets.length; i < l; i++) {
if (this.doclets[i].longname === longname) {
found.push(this.doclets[i]);
}
}
return found;
return this.doclets.filter(function(doclet) {
return doclet.longname === longname;
});
}
DocSet.prototype.getByMemberof = function(memberof) {
return this.doclets.filter(function(doclet) {
return doclet.memberof === memberof;
});
}
DocSet.prototype.sortByLongname = function() {
this.doclets.sort(function(a, b) {
if(a.longname == b.longname) {
return 0;
}
return (a.longname < b.longname)? -1 : 1;
});
}
})();

View File

@ -93,7 +93,11 @@
exports.shorten = function(longname) {
//// quoted strings in a longname are atomic, convert to tokens
var atoms = [], token;
longname = longname.replace(/(".*?")/g, function($) {
// handle quoted names like foo["bar"]
longname = longname.replace(/(\[?".*?"\]?)/g, function($) {
$ = $.replace(/^\[/g, '.').replace(/\]$/g, '');
token = '@{' + atoms.length + '}@';
atoms.push($);
return token;
@ -107,11 +111,13 @@
//// restore quoted strings back again
var i = atoms.length;
while (i--) {
longname = longname.replace('@{'+i+'}@', atoms[i]);
memberof = memberof.replace('@{'+i+'}@', atoms[i]);
name = name.replace('@{'+i+'}@', atoms[i]);
scope = scope.replace('@{'+i+'}@', atoms[i]);
name = name.replace('@{'+i+'}@', atoms[i]);
}
////
return {longname: longname, memberof: memberof, scope: scope, name: name};
}
})();

View File

@ -66,12 +66,12 @@
});
dictionary.defineTag('file', {
keepsWhitespace: true,
mustHaveValue: true,
onTagged: function(doclet, tag) {
setNameToFile(doclet, tag);
setDocletKindToTitle(doclet, tag);
applyNamespace(doclet, tag);
setDocletDescriptionToValue(doclet, tag);
doclet.preserveName = true;
@ -175,7 +175,12 @@
});
dictionary.defineTag('private', {
mustNotHaveValue: true
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.access = 'private';
return true;
}
});
dictionary.defineTag('property', {
@ -224,6 +229,12 @@
}
}
function setDocletDescriptionToValue(doclet, tag) {
if (tag.value) {
doclet.addTag( 'description', tag.value );
}
}
function setNameToFile(doclet, tag) {
if (doclet.meta.filename) { doclet.addTag( 'name', 'file:'+doclet.meta.filename ); }
}

View File

@ -29,6 +29,8 @@
return !doclet.undocumented;
});
docSet.sortByLongname();
// apply template
out = Mustache.to_html(
templates.index,

View File

@ -3,19 +3,45 @@
<head>
<meta charset="utf-8">
<title>JSDoc Index</title>
<style type="text/css">
.kind { font-style: italic; }
.constructor
{
font-weight: bold;
color: #780000;
}
.namespace { color: #780000; }
.property { color: #999; }
.function { color: #999; }
.access { color: #999; }
dt
{
margin-top: 8px;
margin-bottom: 4px;
border-top: 1px solid #ccc;
font-size: 110%;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Tahoma, sans-serif;
}
</style>
</head>
<body>
<h1>All Symbols</h1>
<ul>
<dl>
{{#docs}}
<li class="symbol">
<i>{{kind}}</i> {{longname}}{{#description}} - {{#summarize}}{{{description}}}{{/summarize}}{{/description}}
</li>
<dt class="symbol">
{{#kind}}<span class="kind {{kind}}">{{kind}}</span> {{/kind}}{{#access}}<span class="access {{access}}">&lt;{{access}}></span> {{/access}}{{longname}}
</dt>
{{#description}}<dd>
{{#summarize}}{{{description}}}{{/summarize}}
</dd>{{/description}}
{{/docs}}
</ul>
</dl>
</body>
</html>

17
test/cases/quotename.js Normal file
View File

@ -0,0 +1,17 @@
/**
@namespace
@name chat."#channel"
*/
chat["#channel"] = {};
/**
@property
@type {boolean}
@name chat."#channel".open
*/
chat["#channel"].open = true;
/**
@event chat."#channel"."op:announce-motd"
*/

View File

@ -1,5 +1,5 @@
/**
* @fileoverview This file is to be used for testing the JSDoc parser
* @fileoverview This file is to be used for testing the JSDoc parser.
* It is not intended to be an example of good JavaScript OO-programming,
* nor is it intended to fulfill any specific purpose apart from
* demonstrating the functionality of the
@ -58,8 +58,8 @@ geometry.util.ShapeFactory.prototype = {
geometry.Shape = function(template){
/**
* This is an example of a function that is not given as a property
* of a prototype, but instead it is assigned within a constructor.
* This is an example of a function that is a `this` property.
* Not of a prototype, instead it is assigned within a constructor.
* For inner functions like this to be picked up by the parser, the
* function that acts as a constructor *must* be denoted with
* the `@constructor` tag in its comment.
@ -71,7 +71,7 @@ geometry.Shape = function(template){
}
/**
* This is an inner method, just used here as an example
* This is an inner method, just used here as an example.
* @private
* @since version 0.5
* @author Sue Smart
@ -102,7 +102,7 @@ geometry.Hexagon = function(sideLength) {
/**
* This is an unattached (static) function that adds two integers together using {@link geometry.Shape#getClassName}.
* This is a global function that adds two integers together using {@link geometry.Shape#getClassName}.
* @function
* @param {int} One The first number to add
* @param {int} Two The second number to add
@ -115,7 +115,7 @@ function Add(One, Two){
/**
* The color of this shape
* The color of this shape.
* @property
* @type {string|Color}
*/
@ -179,7 +179,7 @@ geometry.Shape.prototype.setColor = function(color){
}
/**
* Clone this shape
* Clone this shape.
* @method
* @returns A copy of this shape
* @type geometry.Shape
@ -222,14 +222,14 @@ geometry.Rectangle.prototype = new geometry.Shape();
* @private
* @type int
*/
geometry.Rectangle.prototype.width = 0;
geometry.Rectangle.prototype._width = 0;
/**
* Value to represent the height of the Rectangle
* Value to represent the height of the Rectangle.
* @private
* @type int
*/
geometry.Rectangle.prototype.height = 0;
geometry.Rectangle.prototype._height = 0;
/**
* Get the type of this object.
@ -240,7 +240,7 @@ geometry.Rectangle.prototype.getClassName= function(){
}
/**
* Get the value of the width for the Rectangle
* Get the value of the width for the Rectangle.
* @type int
* @see geometry.Rectangle#setWidth
*/
@ -279,7 +279,7 @@ geometry.Rectangle.prototype.setHeight = function(height){
}
/**
* Get the value for the total area of this Rectangle
* Get the value for the total area of this Rectangle.
* @return total area of this Rectangle
* @type int
*/
@ -318,7 +318,7 @@ geometry.Square.prototype.setWidth = function(width){
}
/**
* Set the height value for this Shape
* Set the height value for this Shape.
* Sets the {@link geometry.Rectangle#height} attribute in the Rectangle.
* @param {int} height The height value to be set
*/
@ -349,21 +349,21 @@ geometry.Circle = function(radius){
geometry.Circle.prototype = new geometry.Shape();
/**
* The radius value for this Circle
* The radius value for this Circle.
* @private
* @type int
*/
geometry.Circle.prototype.radius = 0;
/**
* A very simple class (static) field that is also a constant
* A field that is also a constant.
* @const
* @type float
*/
geometry.Circle.PI = 3.14;
/**
* Get the radius value for this Circle
* Get the radius value for this Circle.
* @type int
* @see #setRadius
*/
@ -372,7 +372,7 @@ geometry.Circle.prototype.getRadius = function(){
}
/**
* Set the radius value for this Circle
* Set the radius value for this Circle.
* @param {int} radius The {@link geometry.Circle#radius} value to set
* @see #getRadius
*/
@ -386,8 +386,8 @@ geometry.Circle.prototype.setRadius = function(radius){
geometry.Circle.prototype.setDiameter = geometry.Square.prototype.setWidth;
/**
* An example of a class (static) method that acts as a factory for Circle
* objects. Given a radius value, this method creates a new Circle.
* An example of a class (static) method that acts as a factory for Circle objects.
* Given a radius value, this method creates a new Circle.
* @param {int} radius The radius value to use for the new Circle.
* @type geometry.Circle
*/
@ -412,7 +412,7 @@ geometry.Coordinate = function(x, y){
}
/**
* The x portion of the Coordinate
* The x portion of the Coordinate.
* @type {int}
* @see #getX
* @see #setX
@ -420,7 +420,7 @@ geometry.Coordinate = function(x, y){
geometry.Coordinate.prototype.x = 0;
/**
* The y portion of the Coordinate
* The y portion of the Coordinate.
* @type int
* @see #getY
* @see #setY
@ -464,14 +464,14 @@ geometry.Coordinate.prototype.setY = function(y){
}
/**
* An example of a singleton class
* An example of a singleton class.
* @param ... Arguments represent {@link coordinate}s in the shape.
* @constructor
*/
MySingletonShapeFactory = function(){
/**
* Get the next {@link geometry.Shape}
* Get the next {@link geometry.Shape}.
* @type geometry.Shape
* @return A new {@link geometry.Shape}
*/
@ -490,8 +490,7 @@ MySingletonShapeFactory = function(){
function Foo(){}
/**
* Nested class
* @public
* Nested class.
* @constructor
*/
Foo.Bar = function(){
@ -507,7 +506,7 @@ Foo.Bar.prototype.y = '3';
* @private
* @this {geometry.Circle}
*/
function getArea() {
function _getArea() {
}
// see http://www.integralist.co.uk/javascript/implementing-interfaces-in-javascript/