Fixed incorrect intrapage links for events. Closes #38.

This commit is contained in:
Michael Mathews 2011-10-12 22:54:36 +01:00
parent 181a483389
commit a9963a0167
6 changed files with 31 additions and 11 deletions

View File

@ -157,12 +157,11 @@ exports.shorten = function(longname, forcedMemberof) {
variation;
longname = longname.replace( /\.prototype\.?/g, '#' );
//console.log(forcedMemberof);
if (typeof forcedMemberof !== 'undefined') {
//console.log('forcedMemberof');
name = longname.substr(forcedMemberof.length);
var parts = forcedMemberof.match(/^(.*?)([#.~]?)$/);
//console.log(parts);
if (parts[1]) memberof = parts[1] || forcedMemberof;
if (parts[2]) scope = parts[2];
}

View File

@ -171,6 +171,7 @@ exports.defineTags = function(dictionary) {
});
dictionary.defineTag('event', {
isNamespace: true,
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
setDocletNameToValue(doclet, tag);

View File

@ -3,6 +3,8 @@
*/
var hash = require('pajhome/hash');
var dictionary = require('jsdoc/tag/dictionary');
exports.globalName = 'global';
exports.fileExtension = '.html';
@ -39,7 +41,7 @@ exports.createLink = function(doclet) {
var longname = doclet.longname,
filename = strToFilename(doclet.memberof || exports.globalName); // TODO handle name collisions
url = filename + exports.fileExtension + '#' + doclet.name;
url = filename + exports.fileExtension + '#' + getNamespace(doclet.kind) + doclet.name;
}
else {
var longname = doclet.longname,
@ -51,6 +53,13 @@ exports.createLink = function(doclet) {
return url;
}
function getNamespace(kind) {
if (dictionary.isNamespace(kind)) {
return kind+':';
}
return '';
}
function strToFilename(str) {
if ( /[^$a-z0-9._-]/i.test(str) ) {
return hash.hex_md5(str).substr(0, 10);

View File

@ -152,6 +152,9 @@
doclet.see[i] = hashToLink(doclet, seeItem);
});
}
});
data.orderBy(['longname', 'version', 'since']);
@ -191,11 +194,19 @@
helper.registerLink(doclet.longname, url);
});
data.forEach(function(doclet) {
var url = helper.longnameToUrl[doclet.longname];
if (url.indexOf('#') > -1) {
doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
}
else {
doclet.id = doclet.name;
}
})
// do this after the urls have all been generated
data.forEach(function(doclet) {
//if (doclet.classdesc) doclet.classdesc = renderLinks(doclet.classdesc);
//if (doclet.description) doclet.description = renderLinks(doclet.description);
doclet.ancestors = generateAncestry(doclet);
});

View File

@ -1,6 +1,6 @@
<dt id="member:<?js= longname ?>">
<h4 class="name"><?js= this.attribs + name + this.signature ?></h4>
<dt>
<h4 class="name" id="<?js= id ?>"><?js= this.attribs + name + this.signature ?></h4>
<?js if (this.summary) { ?>
<p class="summary"><?js= summary ?></p>

View File

@ -1,5 +1,5 @@
<dt id="<?js= longname ?>">
<h4 class="name" id="<?js= name ?>"><?js= this.attribs + (kind == 'class'? 'new ':'') + name + this.signature ?></h4>
<dt>
<h4 class="name" id="<?js= id ?>"><?js= this.attribs + (kind == 'class'? 'new ':'') + name + this.signature ?></h4>
<?js if (this.summary) { ?>
<p class="summary"><?js= summary ?></p>