diff --git a/jsdoc.js b/jsdoc.js index daf644d1..41d9ba28 100644 --- a/jsdoc.js +++ b/jsdoc.js @@ -41,6 +41,7 @@ env = { /** The absolute path to the base directory of the jsdoc application. + @deprecated Use `__dirname` instead. @type string */ dirname: '.', @@ -86,7 +87,7 @@ function include(filepath) { load(filepath); } catch (e) { - console.log('Cannot include "' + env.dirname + '/' + filepath + '": '+e); + console.log('Cannot include "' + __dirname + '/' + filepath + '": '+e); } } include.resolve = function(filepath) { @@ -94,7 +95,7 @@ include.resolve = function(filepath) { return filepath; } - return env.dirname + '/' + filepath; + return __dirname + '/' + filepath; }; /** Print string/s out to the console. @@ -272,7 +273,7 @@ function main() { result = path.resolve(template); if ( !pathExists(result) ) { // next, try resolving it relative to the JSDoc directory - result = path.resolve(env.dirname, template); + result = path.resolve(__dirname, template); if ( !pathExists(result) ) { result = null; } @@ -295,12 +296,12 @@ function main() { env.opts = jsdoc.opts.args.parse(env.args); try { - env.conf = new Config( fs.readFileSync( env.opts.configure || path.join(env.dirname, 'conf.json') ) ).get(); + env.conf = new Config( fs.readFileSync( env.opts.configure || path.join(__dirname, 'conf.json') ) ).get(); } catch (e) { try { // Use the example file if possible - var example = fs.readFileSync(path.join(env.dirname, 'conf.json.EXAMPLE'), 'utf8'); + var example = fs.readFileSync(path.join(__dirname, 'conf.json.EXAMPLE'), 'utf8'); env.conf = JSON.parse(example); } catch(e) { diff --git a/lib/rhino-shim.js b/lib/rhino-shim.js index b7dfb685..a0196dff 100644 --- a/lib/rhino-shim.js +++ b/lib/rhino-shim.js @@ -92,7 +92,7 @@ console = { * @see http://nodejs.org/api/process.html */ process = { - argv: [env.dirname + '/jsdoc.js'].concat(Array.prototype.slice.call(arguments, 0)), + argv: [__dirname + '/jsdoc.js'].concat(Array.prototype.slice.call(arguments, 0)), cwd: function() { return new Packages.java.io.File('.').getCanonicalPath() + ''; }, diff --git a/plugins/test/specs/railsTemplate.js b/plugins/test/specs/railsTemplate.js index 00a649fc..aed9e127 100644 --- a/plugins/test/specs/railsTemplate.js +++ b/plugins/test/specs/railsTemplate.js @@ -1,3 +1,4 @@ +/*global describe: true, expect: true, installPlugins: true, it: true */ describe("railsTemplate plugin", function() { var parser = new (require("jsdoc/src/parser")).Parser(), plugin = require('plugins/railsTemplate'); @@ -8,7 +9,7 @@ describe("railsTemplate plugin", function() { it("should remove <% %> rails template tags from the source of *.erb files", function() { var path = require("path"), - docSet = parser.parse([path.join(env.dirname, "plugins/test/fixtures/railsTemplate.js.erb")]); + docSet = parser.parse([path.join(__dirname, "plugins/test/fixtures/railsTemplate.js.erb")]); expect(docSet[2].description).toEqual("Remove rails tags from the source input (e.g. )"); }); diff --git a/rhino_modules/jsdoc/opts/args.js b/rhino_modules/jsdoc/opts/args.js index c06f8122..a1bce509 100644 --- a/rhino_modules/jsdoc/opts/args.js +++ b/rhino_modules/jsdoc/opts/args.js @@ -68,7 +68,7 @@ function parseQuery(str) { } argParser.addOption('t', 'template', true, 'The name of the template to use. Default: the "default" template'); -argParser.addOption('c', 'configure', true, 'The path to the configuration file. Default: jsdoc env.dirname + /conf.json'); +argParser.addOption('c', 'configure', true, 'The path to the configuration file. Default: jsdoc __dirname + /conf.json'); argParser.addOption('e', 'encoding', true, 'Assume this encoding when reading all source files. Default: utf-8'); argParser.addOption('T', 'test', false, 'Run all tests and quit.'); argParser.addOption('d', 'destination', true, 'The path to the output folder. Use "console" to dump data to the console. Default: ./out/'); diff --git a/templates/prettyPrintSource/publish.js b/templates/prettyPrintSource/publish.js index ce813171..2caff43e 100644 --- a/templates/prettyPrintSource/publish.js +++ b/templates/prettyPrintSource/publish.js @@ -20,10 +20,10 @@ exports.publish = function(outputDirectory, outputFileName, sourceCode) { outputDirectory = path.resolve(outputDirectory); - var staticFilesDirectory = path.resolve(env.dirname + '/templates/prettyPrintSource/static'); + var staticFilesDirectory = path.resolve(__dirname + '/templates/prettyPrintSource/static'); var outputFile = path.join(outputDirectory, outputFileName + '.html'); var templateName = 'layout.tmpl'; - var templatePath = path.resolve(env.dirname + '/templates/prettyPrintSource'); + var templatePath = path.resolve(__dirname + '/templates/prettyPrintSource'); var temmplateFilesDirectory= path.join(templatePath, '/tmpl'); var templateData = {}; diff --git a/test/fixtures/typekind.js b/test/fixtures/typekind.js index aacfcc70..46d6c1eb 100644 --- a/test/fixtures/typekind.js +++ b/test/fixtures/typekind.js @@ -1,5 +1,5 @@ /** - @module {ConnectServer} blog/server + @module {ConnectServer} blog/server */ module.exports = require('connect').createServer( @@ -8,7 +8,7 @@ module.exports = require('connect').createServer( Connect.favicon(), Connect.cache(), Connect.gzip(), - require('wheat')(env.dirname) + require('wheat')(__dirname) ); /** diff --git a/test/jasmine-jsdoc.js b/test/jasmine-jsdoc.js index 230aa244..f3048303 100644 --- a/test/jasmine-jsdoc.js +++ b/test/jasmine-jsdoc.js @@ -10,7 +10,7 @@ var jasmineAll = require('test/lib/jasmine'); var jasmine = jasmineAll.jasmine; // due to scoping issues, requiring this file doesn't work -eval( fs.readFileSync(env.dirname + '/test/async-callback.js') ); +eval( fs.readFileSync(__dirname + '/test/async-callback.js') ); var jasmineNode = require('test/reporter').jasmineNode; @@ -32,7 +32,7 @@ jasmine.loadHelpersInFolder = function(folder, matcher) { for ( var i = 0, len = helpers.length; i < len; ++i) { var file = helpers[i].path(); var helper = require(file.replace(/\\/g, '/'). - replace(new RegExp('^' + env.dirname + '/'), ""). + replace(new RegExp('^' + __dirname + '/'), ""). replace(/\.*$/, "")); for (var key in helper) { @@ -96,7 +96,7 @@ jasmine.executeSpecsInFolder = function(folder, done, opts) { for (var i = 0, len = specsList.length; i < len; ++i) { filename = specsList[i]; require(filename.path().replace(/\\/g, '/'). - replace(new RegExp('^' + env.dirname + '/'), ""). + replace(new RegExp('^' + __dirname + '/'), ""). replace(/\.\w+$/, "")); } diff --git a/test/spec-collection.js b/test/spec-collection.js index 0ac1df42..12756b56 100644 --- a/test/spec-collection.js +++ b/test/spec-collection.js @@ -37,7 +37,7 @@ exports.load = function(loadpath, matcher, clear) { var wannaBeSpecs = wrench.readdirSyncRecursive(loadpath); for (var i = 0; i < wannaBeSpecs.length; i++) { - var file = path.join(env.dirname, loadpath, wannaBeSpecs[i]); + var file = path.join(__dirname, loadpath, wannaBeSpecs[i]); try { if (fs.statSync(file).isFile()) { if (matcher.test(path.basename(file))) { diff --git a/test/specs/documentation/modules.js b/test/specs/documentation/modules.js index c3b7debd..52481150 100644 --- a/test/specs/documentation/modules.js +++ b/test/specs/documentation/modules.js @@ -1,21 +1,22 @@ +/*global beforeEach: true, describe: true, env: true, expect: true, it: true */ describe("module names", function() { var parser = require('jsdoc/src/parser'), srcParser = null, doclets; beforeEach(function() { - env.opts._ = [env.dirname + '/test/fixtures/modules/']; + env.opts._ = [__dirname + '/test/fixtures/modules/']; srcParser = new parser.Parser(); require('jsdoc/src/handlers').attachTo(srcParser); }); it("should create a name from the file path when no documented module name exists", function() { - doclets = srcParser.parse(env.dirname + '/test/fixtures/modules/data/mod-1.js'); + doclets = srcParser.parse(__dirname + '/test/fixtures/modules/data/mod-1.js'); expect(doclets.length).toBeGreaterThan(1); expect(doclets[0].longname).toEqual('module:data/mod-1'); }); it("should use the documented module name if available", function() { - doclets = srcParser.parse(env.dirname + '/test/fixtures/modules/data/mod-2.js'); + doclets = srcParser.parse(__dirname + '/test/fixtures/modules/data/mod-2.js'); expect(doclets.length).toBeGreaterThan(1); expect(doclets[0].longname).toEqual('module:my/module/name'); }); diff --git a/test/specs/helpers.js b/test/specs/helpers.js index 91af9678..284fda42 100644 --- a/test/specs/helpers.js +++ b/test/specs/helpers.js @@ -1,7 +1,7 @@ -var hasOwnProperty = Object.prototype.hasOwnProperty; +var hasOwnProp = Object.prototype.hasOwnProperty; exports.getDocSetFromFile = function(filename, parser) { - var sourceCode = readFile(env.dirname + '/' + filename), + var sourceCode = readFile(__dirname + '/' + filename), testParser = parser || new (require('jsdoc/src/parser')).Parser(), doclets; @@ -28,7 +28,7 @@ exports.getDocSetFromFile = function(filename, parser) { exports.indexAll = function(docs) { var index = {}; docs.forEach(function(doc) { - if (!hasOwnProperty.call(index, doc.longname)){index[doc.longname] = [];} + if (!hasOwnProp.call(index, doc.longname)){index[doc.longname] = [];} index[doc.longname].push(doc); }); docs.index = index; diff --git a/test/specs/jsdoc/functions/include.js b/test/specs/jsdoc/functions/include.js index 29d07a6e..c7d12dbe 100644 --- a/test/specs/jsdoc/functions/include.js +++ b/test/specs/jsdoc/functions/include.js @@ -1,4 +1,4 @@ - +/*global describe: true, env: true, expect: true, include: true, it: true */ describe("include", function() { it("should be a function", function() { @@ -15,8 +15,8 @@ describe("include", function() { expect( include.resolve('/a/b/c.js') ).toEqual('/a/b/c.js'); }); - it("should resolve relative filepaths relative to the env.dirname", function() { - expect( include.resolve('a/b/c') ).toEqual(env.dirname+'/'+'a/b/c'); + it("should resolve relative filepaths relative to the __dirname", function() { + expect( include.resolve('a/b/c') ).toEqual(__dirname + '/' + 'a/b/c'); }); }); \ No newline at end of file diff --git a/test/specs/jsdoc/src/parser.js b/test/specs/jsdoc/src/parser.js index 2162583e..f07e7351 100644 --- a/test/specs/jsdoc/src/parser.js +++ b/test/specs/jsdoc/src/parser.js @@ -1,3 +1,4 @@ +/*global describe: true, expect: true, it: true, jasmine: true */ describe("jsdoc/src/parser", function() { var jsdoc = {src: { parser: require('jsdoc/src/parser')}}; @@ -43,7 +44,7 @@ describe("jsdoc/src/parser", function() { it("should be able to parse its own source file", function() { var fs = require("fs"), path = require("path"), - parserSrc = "javascript:" + fs.readFileSync( path.join(env.dirname, + parserSrc = "javascript:" + fs.readFileSync( path.join(__dirname, "rhino_modules", "jsdoc", "src", "parser.js") ), parse = function() { parser.parse(parserSrc); diff --git a/test/specs/jsdoc/src/scanner.js b/test/specs/jsdoc/src/scanner.js index 602cf4cc..3203c2aa 100644 --- a/test/specs/jsdoc/src/scanner.js +++ b/test/specs/jsdoc/src/scanner.js @@ -6,10 +6,10 @@ describe("jsdoc/src/scanner", function() { excludePattern: new RegExp("(^|\\/|\\\\)_") }), path = require('path'), - sourceFiles = scanner.scan([path.join(env.dirname, 'test', 'fixtures', 'src')], 3, filter); + sourceFiles = scanner.scan([path.join(__dirname, 'test', 'fixtures', 'src')], 3, filter); sourceFiles = sourceFiles.map(function($) { - return path.relative(env.dirname, $); + return path.relative(__dirname, $); }); it("should return the correct source files", function() { diff --git a/test/specs/jsdoc/tutorial/resolver.js b/test/specs/jsdoc/tutorial/resolver.js index 9892350e..0322ad4d 100644 --- a/test/specs/jsdoc/tutorial/resolver.js +++ b/test/specs/jsdoc/tutorial/resolver.js @@ -1,4 +1,4 @@ -/*global describe: true, env: true, it: true */ +/*global afterEach: true, describe: true, env: true, expect: true, it: true */ describe("jsdoc/tutorial/resolver", function() { /*jshint evil: true */ @@ -9,8 +9,8 @@ describe("jsdoc/tutorial/resolver", function() { log = eval(console.log); function missingTutorial() { - resolver.load(env.dirname + "/test/tutorials/incomplete"); - resolver.resolve(); + resolver.load(__dirname + "/test/tutorials/incomplete"); + resolver.resolve(); } afterEach(function() { diff --git a/test/specs/jshint/jshint-clean.js b/test/specs/jshint/jshint-clean.js index 55868ea3..542acbf9 100644 --- a/test/specs/jshint/jshint-clean.js +++ b/test/specs/jshint/jshint-clean.js @@ -3,7 +3,7 @@ var async = require('async'), fs = require('fs'), path = require('path'); -var config = JSON.parse( fs.readFileSync( path.join(env.dirname, '.jshintrc'), 'utf-8' ) ); +var config = JSON.parse( fs.readFileSync( path.join(__dirname, '.jshintrc'), 'utf-8' ) ); function jsHintCheck(filename, callback) { var JSHINT = require('jshint').JSHINT; @@ -25,7 +25,7 @@ function jsHintCheck(filename, callback) { describe('jshint-clean', function() { it('should generate JSHint errors for bad code', function(done) { - var file = path.join(env.dirname, 'test', 'fixtures', 'jshint', 'badfile.js'); + var file = path.join(__dirname, 'test', 'fixtures', 'jshint', 'badfile.js'); jsHintCheck(file, function(err, jsHintErrors) { expect(err).toBeFalsy(); @@ -35,7 +35,7 @@ describe('jshint-clean', function() { }); it('should not generate JSHint errors for good code', function(done) { - var file = path.join(env.dirname, 'test', 'fixtures', 'jshint', 'goodfile.js'); + var file = path.join(__dirname, 'test', 'fixtures', 'jshint', 'goodfile.js'); jsHintCheck(file, function(err, jsHintErrors) { expect(err).toBeFalsy(); @@ -57,7 +57,7 @@ describe('jshint-clean', function() { }; filter = new (require('jsdoc/src/filter').Filter)(source); - files = app.jsdoc.scanner.scan([env.dirname], 10, filter); + files = app.jsdoc.scanner.scan([__dirname], 10, filter); async.forEach(files, function(file, cb) { jsHintCheck(file, function(err, jsHintErrors) { diff --git a/test/specs/tags/overviewtag.js b/test/specs/tags/overviewtag.js index 06637c6d..67f09130 100644 --- a/test/specs/tags/overviewtag.js +++ b/test/specs/tags/overviewtag.js @@ -6,7 +6,7 @@ describe("@overview tag", function() { doclets; require('jsdoc/src/handlers').attachTo(srcParser); - doclets = srcParser.parse(env.dirname + '/test/fixtures/file.js'); + doclets = srcParser.parse(__dirname + '/test/fixtures/file.js'); it('When a file overview tag appears in a doclet, the name of the doclet should contain the path to the file.', function() { expect(doclets[0].name).toMatch(/^(fixtures[\/\\]file\.js)$/);