styledocco
Advanced tools
Comparing version 0.6.1 to 0.6.2
45
cli.js
@@ -27,2 +27,7 @@ 'use strict'; | ||
}; | ||
var isType = function(o, type) { | ||
return Object.prototype.toString.call(o) === '[object ' + type + ']'; | ||
} | ||
var flatten = function(arr) { | ||
@@ -34,6 +39,24 @@ return arr.reduce(function(tot, cur) { | ||
var inArray = function(arr, str) { return arr.indexOf(str) !== -1; }; | ||
var isArray = function(obj) { | ||
return Object.prototype.toString.call(obj) === '[object Array]'; | ||
var isArray = function(obj) { return isType(obj, 'Array'); }; | ||
var isString = function(obj) { return isType(obj, 'String'); }; | ||
var urlsRelative = function(css, path) { | ||
if (isString(css) && isString(path)) { | ||
path = path.indexOf('/', path.length -1) > -1? path : path + '/'; | ||
var regex = /(url\(["']?)([^/'"][\w/.]*)/gm; | ||
return css.replace(regex, "$1" + path + "$2"); | ||
} else { | ||
throw new Error('1st and 2nd args must be strings.'); | ||
} | ||
}; | ||
var dirUp = function(steps) { | ||
if ( ! steps) return ''; | ||
var str = ''; | ||
for (var i = 0; i < steps; ++i) { | ||
str += '../'; | ||
} | ||
return str; | ||
} | ||
// Get a filename without the extension | ||
@@ -127,2 +150,3 @@ var baseFilename = function(str) { | ||
var errorMessages = { noFiles: 'No css files found' }; | ||
var resourcesDir = __dirname + '/share/'; | ||
@@ -212,3 +236,3 @@ | ||
}).sort(); | ||
if (!files.length) cb(new Error('Failed to process files.')); | ||
if (!files.length) cb(new Error(errorMessages.noFiles + ' in path "' + options['in'] + '"')); | ||
cb(null, files); | ||
@@ -234,3 +258,10 @@ }); | ||
}, function(err, resources) { | ||
if (err != null) throw new SDError('Could not process files.', err); | ||
if (err != null) { | ||
if (err.message.indexOf(errorMessages.noFiles) > -1) { | ||
console.error(err); | ||
return; | ||
} else { | ||
throw new SDError('Could not process files.', err); | ||
} | ||
} | ||
var menu = menuLinks(resources.files, options.basePath); | ||
@@ -273,2 +304,5 @@ // Run files through preprocessor and StyleDocco parser. | ||
var htmlFiles = files.map(function(file) { | ||
var relativePath = file.path.split('/'); | ||
relativePath.pop(); | ||
relativePath = dirUp(options.out.split('/').length) + relativePath.join('/'); | ||
return { | ||
@@ -282,3 +316,3 @@ path: file.path, | ||
docs: { js: minjs(docsScript), css: mincss(resources.docs.css) }, | ||
previews: { js: minjs(resources.previews.js), css: mincss(previewStyles) } | ||
previews: { js: minjs(resources.previews.js), css: mincss(urlsRelative(previewStyles, relativePath)) } | ||
} | ||
@@ -313,1 +347,2 @@ }) | ||
module.exports.menuLinks = menuLinks; | ||
module.exports.urlsRelative = urlsRelative; |
@@ -6,3 +6,4 @@ { | ||
"author": "Jacob Rask <jacob@jacobrask.net>", | ||
"version": "0.6.1", | ||
"contributors": ["David Marrs <david@marrsbytes.com>"], | ||
"version": "0.6.2", | ||
"homepage": "http://jacobrask.github.com/styledocco/", | ||
@@ -17,3 +18,3 @@ "licenses": [ { "type": "MIT", "url": "http://github.com/jacobrask/styledocco/raw/master/LICENSE" } ], | ||
"clean-css": "0.4.x", | ||
"findit": "0.x.x", | ||
"findit": "git://github.com/marrs/node-findit.git", | ||
"jade": "0.23.x", | ||
@@ -27,3 +28,5 @@ "marked": "0.2.x", | ||
"jshint": "0.7.x", | ||
"nodeunit": "0.7.x" | ||
"nodeunit": "0.7.x", | ||
"chai": "latest", | ||
"mocha": "latest" | ||
}, | ||
@@ -33,4 +36,4 @@ "main": "./styledocco", | ||
"scripts": { | ||
"test": "nodeunit test" | ||
"test": "nodeunit test; mocha test" | ||
} | ||
} |
@@ -76,5 +76,39 @@ StyleDocco | ||
Change Log | ||
========== | ||
v0.6.2 - June 30, 2013 | ||
---------------------- | ||
* Find assets recursively in Windows | ||
* Fail gracefully on no files error | ||
* Relative url() paths are now preserved | ||
v0.6.1 - August 20, 2012 | ||
------------------------ | ||
* Mute all preprocessor errors unless using verbose option | ||
* Don't try to preprocess SASS partials | ||
* Design tweaks | ||
v0.6.0 - August 15, 2012 | ||
------------------------ | ||
* Remove custom resources option, as client side scripts/styles are vital to the functionality | ||
* Editable, auto-updating code examples | ||
* Documentation-wide search | ||
* Page specific Table of Contents | ||
v0.5.0 - July 23, 2012 | ||
------------------------ | ||
* Render previews in sandboxed iframes | ||
* Resizing of iframes for responsive debugging | ||
* All processed CSS is included in all previews | ||
* Allow custom JavaScript and CSS files to be included in previews | ||
* Updated design with topbar instead of sidebar and new colors | ||
Acknowledgements | ||
---------------- | ||
================ | ||
A lot of the heavy lifting in StyleDocco is done by the excellent [Marked](https://github.com/chjj/marked) module by Christopher Jeffrey. The original [Docco](https://github.com/jashkenas/docco) by Jeremy Ashkenas and [Knyle Style Sheets](https://github.com/kneath/kss) have also been sources of inspiration for StyleDocco. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58253
17
1361
114
5
1
2
- Removedchainsaw@0.0.9(transitive)
- Removedfindit@0.1.2(transitive)
- Removedhashish@0.0.4(transitive)
- Removedseq@0.3.5(transitive)
- Removedtraverse@0.3.9(transitive)