mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Fix name and longname for file doclets.
This commit is contained in:
parent
43efe8048b
commit
1d18f3950d
7
main.js
7
main.js
@ -106,8 +106,9 @@ function main() {
|
|||||||
docs,
|
docs,
|
||||||
jsdoc = {
|
jsdoc = {
|
||||||
opts: {
|
opts: {
|
||||||
parser: require('jsdoc/opts/parser')
|
parser: require('jsdoc/opts/parser'),
|
||||||
}
|
},
|
||||||
|
docset: require('jsdoc/docset')
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -163,7 +164,7 @@ function main() {
|
|||||||
|
|
||||||
if (typeof publish === 'function') {
|
if (typeof publish === 'function') {
|
||||||
publish(
|
publish(
|
||||||
docs,
|
new jsdoc.docset.DocSet(docs),
|
||||||
{ destination: env.opts.destination }
|
{ destination: env.opts.destination }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.Doclet.prototype.postProcess = function() {
|
exports.Doclet.prototype.postProcess = function() {
|
||||||
jsdoc.name.resolve(this);
|
if (!this.preserveName) { jsdoc.name.resolve(this); }
|
||||||
|
if (this.name && !this.longname) { this.longname = this.name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Doclet.prototype.addTag = function(title, text) {
|
exports.Doclet.prototype.addTag = function(title, text) {
|
||||||
|
|||||||
@ -73,6 +73,8 @@
|
|||||||
setDocletKindToTitle(doclet, tag);
|
setDocletKindToTitle(doclet, tag);
|
||||||
applyNamespace(doclet, tag);
|
applyNamespace(doclet, tag);
|
||||||
|
|
||||||
|
doclet.preserveName = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
include('templates/lib/janl/mustache.js');
|
include('templates/lib/janl/mustache.js');
|
||||||
|
|
||||||
publish = function(docs, opts) {
|
publish = function(docSet, opts) {
|
||||||
var out = '',
|
var out = '',
|
||||||
templates = {
|
templates = {
|
||||||
index: readFile(BASEDIR + 'templates/default/tmpl/index.html')
|
index: readFile(BASEDIR + 'templates/default/tmpl/index.html')
|
||||||
@ -24,15 +24,16 @@
|
|||||||
return text.replace(/^\s+|\s+$/g, '');
|
return text.replace(/^\s+|\s+$/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove undocumented symbols from the output
|
||||||
docs = docs.filter(function(doc) {
|
docSet.doclets = docSet.doclets.filter(function(doclet) {
|
||||||
return !doc.undocumented;
|
return !doclet.undocumented;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// apply template
|
||||||
out = Mustache.to_html(
|
out = Mustache.to_html(
|
||||||
templates.index,
|
templates.index,
|
||||||
{
|
{
|
||||||
docs: docs,
|
docs: docSet.doclets,
|
||||||
summarize: summarize
|
summarize: summarize
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
6
test/cases/file.js
Normal file
6
test/cases/file.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* @overview This is a file doclet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function ignoreMe() {
|
||||||
|
}
|
||||||
@ -50,6 +50,8 @@ testFile('test/t/common/dumper.js');
|
|||||||
testFile('test/t/jsdoc/opts/parser.js');
|
testFile('test/t/jsdoc/opts/parser.js');
|
||||||
testFile('test/t/jsdoc/src/parser.js');
|
testFile('test/t/jsdoc/src/parser.js');
|
||||||
|
|
||||||
|
testFile('test/t/cases/file.js');
|
||||||
|
|
||||||
testFile('test/t/cases/virtual.js');
|
testFile('test/t/cases/virtual.js');
|
||||||
|
|
||||||
testFile('test/t/cases/objectlit.js');
|
testFile('test/t/cases/objectlit.js');
|
||||||
|
|||||||
19
test/t/cases/file.js
Normal file
19
test/t/cases/file.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
(function() {
|
||||||
|
var srcParser = require('jsdoc/src/parser'),
|
||||||
|
doclets;
|
||||||
|
|
||||||
|
/**global*/ app = {jsdoc: {parser: new srcParser.Parser()} };
|
||||||
|
|
||||||
|
require('jsdoc/src/handlers');
|
||||||
|
|
||||||
|
doclets = app.jsdoc.parser.parse(BASEDIR + 'test/cases/file.js')
|
||||||
|
|
||||||
|
//dump(doclets);
|
||||||
|
|
||||||
|
test('When a file overview tag appears in a doclet.', function() {
|
||||||
|
var m = /(^file:).*([\/\\]cases[\/\\]file\.js)$/.exec(doclets[0].name);
|
||||||
|
assert.equal(m.length, 3, 'The name of the doclet should start with file: and should end with the path to the file.');
|
||||||
|
assert.equal(doclets[0].name, doclets[0].longname, 'The name and longname should be equal.');
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
||||||
Loading…
x
Reference in New Issue
Block a user