mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
reformat function
This commit is contained in:
parent
957d94d215
commit
fee5d7f303
@ -85,21 +85,17 @@ exports.commonPrefix = function(paths) {
|
||||
/**
|
||||
* Retrieve the fully qualified path to the requested resource.
|
||||
*
|
||||
* Plugins and templates will be found somewhat similar to how
|
||||
* require() works, except that the directory in which the JSDoc
|
||||
* configuration file is will be considered, too, the JSDoc package
|
||||
* directory will be considered as a fallback, and a globally
|
||||
* installed resource won't be found unless it comes with JSDoc.
|
||||
* Plugins and templates will be found somewhat similar to how `require()` works, except that the
|
||||
* directory in which the JSDoc configuration file is will be considered, too, the JSDoc package
|
||||
* directory will be considered as a fallback, and a globally installed resource won't be found
|
||||
* unless it comes with JSDoc.
|
||||
*
|
||||
* If the resource path is specified as a path relative to module or
|
||||
* package (starting with "`.`" or "`..`") JSDoc searches for the path
|
||||
* first in the current working directory, then where the JSDoc
|
||||
* configuration file is located, and finally as a fall-back under the
|
||||
* JSDoc directory. Otherwise, if the resource path is relative (not
|
||||
* starting with a path separator), JSDoc searches first under the
|
||||
* `node_modules` directory in the current working directory and where
|
||||
* the JSDoc configuration file is located, and then where JSDoc is
|
||||
* installed.
|
||||
* If the resource path is specified as a path relative to module or package (starting with `.` or
|
||||
* `..``), JSDoc searches for the path first in the current working directory, then where the JSDoc
|
||||
* configuration file is located, and finally as a fall-back under the JSDoc directory. Otherwise,
|
||||
* if the resource path is relative (not starting with a path separator), JSDoc searches first under
|
||||
* the `node_modules` directory in the current working directory and where the JSDoc configuration
|
||||
* file is located, and then where JSDoc is installed.
|
||||
*
|
||||
* If the resource path is specified as a fully qualified path, JSDoc uses the path as-is.
|
||||
*
|
||||
@ -110,7 +106,9 @@ exports.commonPrefix = function(paths) {
|
||||
* Includes the filename if one was provided.
|
||||
*/
|
||||
exports.getResourcePath = function(filepath, filename) {
|
||||
var pathElems;
|
||||
var result = null;
|
||||
var searchDirs = [];
|
||||
|
||||
function pathExists(_path) {
|
||||
try {
|
||||
@ -123,31 +121,28 @@ exports.getResourcePath = function(filepath, filename) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var searchDirs = [];
|
||||
|
||||
// resources that are installed modules may not have been
|
||||
// specified with a filepath
|
||||
// resources that are installed modules may not have been specified with a filepath
|
||||
if (!filepath) {
|
||||
filepath = filename;
|
||||
filename = undefined;
|
||||
}
|
||||
var pathElems = filepath.split(path.sep);
|
||||
pathElems = filepath.split(path.sep);
|
||||
|
||||
// Special case 'node_modules/foo', to accommodate this legacy
|
||||
// workaround advertised by 3rd party plugin and template authors
|
||||
// Special case `node_modules/foo`, to accommodate this legacy workaround advertised by
|
||||
// third-party plugin and template authors
|
||||
if (pathElems[0] === 'node_modules') {
|
||||
pathElems.unshift('.');
|
||||
filepath = pathElems.join(path.sep);
|
||||
}
|
||||
|
||||
// search in different sets of directories depending on whether
|
||||
// filepath is expressly relative to "current" directory or not
|
||||
// search in different sets of directories depending on whether filepath is expressly relative
|
||||
// to "current" directory or not
|
||||
searchDirs = pathElems[0].indexOf('.') === 0 ?
|
||||
// look first in "current" (where jsdoc was executed), then in
|
||||
// directory of config, and _only then_ in jsdoc's directory
|
||||
// look first in "current" (where JSDoc was executed), then in directory of config, and
|
||||
// _only then_ in JSDoc's directory
|
||||
[env.pwd, path.dirname(env.opts.configure || ''), env.dirname] :
|
||||
// otherwise, treat as relative to where plugins/templates are
|
||||
// found, either as a dependency, or under jsdoc itself
|
||||
// otherwise, treat as relative to where plugins/templates are found, either as a
|
||||
// dependency, or under JSDoc itself
|
||||
[path.join(env.pwd, 'node_modules'),
|
||||
path.join(path.dirname(env.opts.configure || ''), 'node_modules'),
|
||||
env.dirname];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user