mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
fix Windows path issues and static-file copying (#785)
- In the default template, look for the list of static file paths in the config property `templates.default.staticFiles.include`. (You can still use `paths` instead of `include`.) - Handle path-normalization issues that prevented the default template from copying user-specified static files on Windows. - Normalize paths in `fs.toDir` so that callers get the correct path separator on Windows.
This commit is contained in:
parent
d2e5dd888a
commit
fc2b4ad3d2
@ -58,6 +58,8 @@ function filepathMinusPrefix(filepath) {
|
||||
var commonPrefix = path.commonPrefix(sourcePaths);
|
||||
var result = '';
|
||||
|
||||
filepath = path.normalize(filepath);
|
||||
|
||||
if (filepath) {
|
||||
// always use forward slashes
|
||||
result = (filepath + path.sep).replace(commonPrefix, '')
|
||||
|
||||
@ -8,6 +8,8 @@ var wrench = require('wrench');
|
||||
var toDir = exports.toDir = function(_path) {
|
||||
var isDirectory;
|
||||
|
||||
_path = path.normalize(_path);
|
||||
|
||||
try {
|
||||
isDirectory = fs.statSync(_path).isDirectory();
|
||||
}
|
||||
@ -15,7 +17,7 @@ var toDir = exports.toDir = function(_path) {
|
||||
isDirectory = false;
|
||||
}
|
||||
|
||||
if (isDirectory){
|
||||
if (isDirectory) {
|
||||
return _path;
|
||||
} else {
|
||||
return path.dirname(_path);
|
||||
|
||||
@ -85,7 +85,10 @@ exports.readdir = asyncify(readdirSync);
|
||||
|
||||
// JSDoc extension to `fs` module
|
||||
var toDir = exports.toDir = function toDir(_path) {
|
||||
var f = new java.io.File( path.resolve(global.env.pwd, _path) );
|
||||
var f;
|
||||
|
||||
_path = path.normalize(_path);
|
||||
f = new java.io.File( path.resolve(global.env.pwd, _path) );
|
||||
|
||||
if ( f.isDirectory() ){
|
||||
return _path;
|
||||
|
||||
@ -19,7 +19,7 @@ var hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var data;
|
||||
var view;
|
||||
|
||||
var outdir = env.opts.destination;
|
||||
var outdir = path.normalize(env.opts.destination);
|
||||
|
||||
function find(spec) {
|
||||
return helper.find(data, spec);
|
||||
@ -426,8 +426,8 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
var conf = env.conf.templates || {};
|
||||
conf['default'] = conf['default'] || {};
|
||||
|
||||
var templatePath = opts.template;
|
||||
view = new template.Template(templatePath + '/tmpl');
|
||||
var templatePath = path.normalize(opts.template);
|
||||
view = new template.Template( path.join(templatePath, 'tmpl') );
|
||||
|
||||
// claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
|
||||
// doesn't try to hand them out later
|
||||
@ -512,7 +512,11 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
var staticFileFilter;
|
||||
var staticFileScanner;
|
||||
if (conf['default'].staticFiles) {
|
||||
staticFilePaths = conf['default'].staticFiles.paths || [];
|
||||
// The canonical property name is `include`. We accept `paths` for backwards compatibility
|
||||
// with a bug in JSDoc 3.2.x.
|
||||
staticFilePaths = conf['default'].staticFiles.include ||
|
||||
conf['default'].staticFiles.paths ||
|
||||
[];
|
||||
staticFileFilter = new (require('jsdoc/src/filter')).Filter(conf['default'].staticFiles);
|
||||
staticFileScanner = new (require('jsdoc/src/scanner')).Scanner();
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ describe("@overview tag", function() {
|
||||
it('The name should not include the entire filepath when the source file is outside the ' +
|
||||
'JSDoc directory', function() {
|
||||
var Doclet = require('jsdoc/doclet').Doclet;
|
||||
var os = require('os');
|
||||
|
||||
var doclet;
|
||||
var docletMeta;
|
||||
@ -60,6 +61,12 @@ describe("@overview tag", function() {
|
||||
env.sourceFiles = [];
|
||||
env.opts._ = [fakePath];
|
||||
|
||||
// ensure that paths are resolved consistently on Windows
|
||||
if (os.platform().indexOf('win') === 0) {
|
||||
fakePath = 'c:' + fakePath;
|
||||
env.pwd = 'c:' + env.pwd;
|
||||
}
|
||||
|
||||
// create a doclet with a fake filepath, then add a `@file` tag
|
||||
docletSrc = '/** @class */';
|
||||
docletMeta = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user