Skip to content

Commit

Permalink
Fixed but that affected @memberof where the parent ended in # or ~.
Browse files Browse the repository at this point in the history
  • Loading branch information
micmath committed Jul 27, 2010
1 parent b60a316 commit ce34d93
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>

<project name="JSDoc-3" default="about">
<project name="JSDoc-3" default="jar-install">
<property file="build/build.properties" />
<property name="build.templates" location="build/templates" />

Expand Down
2 changes: 1 addition & 1 deletion build/templates/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@app.name@",
"version": "@app.version@",
"timestamp": "@timestamp@",
"revision": "@timestamp@",
"description": "An automatic documentation generator for javascript",
"keywords": [ "documentation", "javascript" ],
"licenses": [
Expand Down
7 changes: 5 additions & 2 deletions modules/jsdoc/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
path = name = name? (''+name).replace(/\.prototype\.?/g, '#') : '';

if (memberof) { // @memberof tag given
memberof = memberof.replace(/\.prototype\.?/g, '#');

// like @name foo.bar, @memberof foo
if (name.indexOf(memberof) === 0) {
[prefix, scope, name] = exports.shorten(name);
Expand All @@ -55,7 +57,9 @@
if ( /([.~#])$/.test(memberof) ) { // like @memberof foo# or @memberof foo~
path = memberof + name;
scope = RegExp.$1;
if (name) { doclet.addTag('scope', puncToScope[scope]); }
doclet.setTag('scope', puncToScope[scope]);
memberof = memberof.slice(0, -1);
doclet.setTag('memberof', memberof);
}
else {
scope = doclet.tagValue('scope');
Expand Down Expand Up @@ -211,7 +215,6 @@
exports.resolveInner = function(name, node, doclet) {
var enclosing = node.getEnclosingFunction(),
enclosingDoc = exports.docFromNode(enclosing);

if (enclosingDoc) {
memberof = enclosingDoc.tagValue('path');
}
Expand Down
9 changes: 4 additions & 5 deletions modules/jsdoc/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@

if (commentSrc) {
thisDoclet = jsdoc.doclet.makeDoclet(commentSrc, node, currentSourceName);
thisDocletName = thisDoclet.tagValue('path');

thisDocletName = thisDoclet.tagValue('name');
if (!thisDoclet.hasTag('kind')) { // guess kind from the source code
thisDoclet.addTag('kind', 'method')
}

if (!thisDocletName) { // guess name from the source code
thisDocletName = jsdoc.name.resolveInner(node.name, node, thisDoclet);
thisDoclet.setName(thisDocletName);

nodeName = jsdoc.name.resolveInner(node.name, node, thisDoclet);
thisDoclet.setName(nodeName);
jsdoc.doclets.addDoclet(thisDoclet);
}
jsdoc.name.refs.push([node, thisDoclet]);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "jsdoc-3",
"version": "0.0.0",
"timestamp": "2010-07-16-1013",
"description": "An automatic documentation generator for javascript.",
"revision": "2010-07-28-0024",
"description": "An automatic documentation generator for javascript",
"keywords": [ "documentation", "javascript" ],
"licenses": [
{
Expand Down
1 change: 1 addition & 0 deletions test/samples/jsdoc_resolvefunc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// undocumented
ShapeFactory.prototype = {
// undocumented
Expand Down
9 changes: 7 additions & 2 deletions test/samples/tag_member.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
@method fah
@memberof foo#
@memberof foo.prototype
*/

/**
Expand Down Expand Up @@ -41,4 +41,9 @@
var baz = 1;
(function(v) {
foz = function() {var baz = v; };
})(baz);
})(baz);

/**
@memberof foo~
*/
function innie() {}
30 changes: 28 additions & 2 deletions test/tests/14_tag_member.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

});

describe('A doclet with a method tag and a memberof tag', function() {
describe('A doclet with a method tag and a memberof tag that ends in "prototype"', function() {
it('should have an `kind` property set to "method"', function() {
var doclet = doclets[2];
expect(doclet).to(have_property, 'kind');
Expand All @@ -31,7 +31,13 @@
it('should have a `memberof` property set to the given member name', function() {
var doclet = doclets[2];
expect(doclet).to(have_property, 'memberof');
expect(doclet.memberof).to(eql, 'foo#');
expect(doclet.memberof).to(eql, 'foo');
});

it('should have a `scope` property set to "instance"', function() {
var doclet = doclets[2];
expect(doclet).to(have_property, 'scope');
expect(doclet.scope).to(eql, 'instance');
});

it('should have a `path` property set to the parent+member names', function() {
Expand Down Expand Up @@ -119,5 +125,25 @@
});
});

describe('A doclet with a property tag and a member tag and an instance access tag', function() {
it('should have a `name` property set to the given name"', function() {
var doclet = doclets[8];
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'innie');
});

it('should have a `memberof` property set to the given member name', function() {
var doclet = doclets[8];
expect(doclet).to(have_property, 'memberof');
expect(doclet.memberof).to(eql, 'foo');
});

it('should have a `path` property set to the memberof~name', function() {
var doclet = doclets[8];
expect(doclet).to(have_property, 'path');
expect(doclet.path).to(eql, 'foo~innie');
});
});

});
})();

0 comments on commit ce34d93

Please sign in to comment.