Skip to content

Commit

Permalink
Merge upstream tag '0.48.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Chan committed Sep 4, 2014
2 parents 152d345 + 6bcf9f3 commit adf1643
Show file tree
Hide file tree
Showing 87 changed files with 1,058 additions and 195 deletions.
31 changes: 29 additions & 2 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
0.48.1 / 2014-08-21
===================

* Fixed sourcemap paths when `--out` flag is present, #1668.
* Fixed the naming convention for maps: `.styl.map` => `.css.map`, #1668.

0.48.0 / 2014-08-20
===================

* Added basic sourcemaps support, #1655.
* Added info on columns for sourcemaps and better error reporting.
* Added `globals` and `functions` keys to options object in JS API, #1653.
* Added `rebeccapurple` named color.
* Added `unicode-range` support (#1648).
* Changed the behaviour of adding percents together to the more sane one, #1664.
* Fixed bug with property lookup inside mixin block (#1645).
* Fixed a bug with nested media queries inside mixins (#1643).
* Fixed an `@extend` inside `@media` queries with multi-level selectors (#1658).
* Fixed bug with cloning of an interpolated selector with comma (#1660).
* Fixed bug with nested media queries in conditionals.
* Fixed a bug with cached imports (#1641).
* Fixed `@css` literal that generated `u+0085` characters instead of newlines (#1663).
* Fixed escaped comma (`\,`) inside hashes (#1666).
* Fixed a string representation of HSLA node to preserve `%` (#1439).
* Fixed incorrect position of inline comments (#1597).
* Fixed a bug with an apostrophe and a colon in a single-line comment (#1647).

0.47.3 / 2014-07-22
===================

Expand Down Expand Up @@ -58,7 +85,7 @@
===================

* Added support for nested media queries, #1540.
* Added `convert` built-in funciton, #1545.
* Added `convert` built-in function, #1545.
* Added negative index values support for subscripts, #1564.
* Add short-circuit evaluation for logical operators, #1532.
* Fixed the dropped commas in splat arguments, #1525.
Expand Down Expand Up @@ -977,7 +1004,7 @@ Closes #401
* Added `avg(nums)` built-in function
* Added `join(delim, vals)` built-in function
* Added `Evaluator#{currentScope,currentBlock}`
* Added multi-line function paramter definition support
* Added multi-line function parameter definition support
* Changed: `0` is falsey, `0%`, `0em`, `0px` etc truthy. Closes #160
* Fixed `for` implicit __return__ value
* Fixed `for` explicit __return__ value
Expand Down
58 changes: 57 additions & 1 deletion bin/stylus
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ var print = false;

var firebug = false;

/**
* Sourcemap flag
*/

var sourcemap = false;

/**
* Files to processes.
*/
Expand Down Expand Up @@ -161,6 +167,10 @@ var usage = [
, ' can be used by the FireStylus Firebug plugin'
, ' -l, --line-numbers Emits comments in the generated CSS'
, ' indicating the corresponding Stylus line'
, ' -m, --sourcemap Generates a sourcemap in sourcemaps v3 format'
, ' --sourcemap-inline Inlines sourcemap with full source text in base64 format'
, ' --sourcemap-root <url> "sourceRoot" property of the generated sourcemap'
, ' --sourcemap-base <path> Base <path> from which sourcemap and all sources are relative'
, ' -P, --prefix [prefix] prefix all css classes'
, ' -p, --print Print out the compiled CSS'
, ' --import <file> Import stylus <file>'
Expand Down Expand Up @@ -205,6 +215,26 @@ while (args.length) {
case '--line-numbers':
linenos = true;
break;
case '-m':
case '--sourcemap':
sourcemap = {};
break;
case '--sourcemap-inline':
sourcemap = sourcemap || {};
sourcemap.inline = true;
break;
case '--sourcemap-root':
var url = args.shift();
if (!url) throw new Error('--sourcemap-root <url> required');
sourcemap = sourcemap || {};
sourcemap.sourceRoot = url;
break;
case '--sourcemap-base':
var path = args.shift();
if (!path) throw new Error('--sourcemap-base <path> required');
sourcemap = sourcemap || {};
sourcemap.basePath = path;
break;
case '-P':
case '--prefix':
prefix = args.shift();
Expand Down Expand Up @@ -312,6 +342,9 @@ if (watchers && !files.length) {
});
}

// --sourcemap flag is not working with stdio
if (sourcemap && !files.length) sourcemap = false;

/**
* Open the default browser to the CSS property `name`.
*
Expand Down Expand Up @@ -366,8 +399,10 @@ var options = {
, compress: compress
, firebug: firebug
, linenos: linenos
, sourcemap: sourcemap
, paths: [process.cwd()].concat(paths)
, prefix: prefix
, dest: dest
};

// Buffer stdin
Expand Down Expand Up @@ -463,7 +498,8 @@ function repl() {
evaluator.return = true;
try {
var expr = parser.parse();
var ret = evaluator.visit(expr);
evaluator.root = expr;
var ret = evaluator.evaluate();
var node;
while (node = ret.nodes.pop()) {
if (!node.suppress) {
Expand Down Expand Up @@ -595,6 +631,7 @@ function compileFile(file) {
if (includeCSS) style.set('include css', true);
if (resolveURL) style.set('resolve url', true);
if (disableCache) style.set('cache', false);
if (sourcemap) style.set('sourcemap', sourcemap);

usePlugins(style);
importFiles(style);
Expand All @@ -608,6 +645,10 @@ function compileFile(file) {
}
} else {
writeFile(file, css);
// write sourcemap
if (sourcemap && !sourcemap.inline) {
writeSourcemap(file, style.sourcemap);
}
}
});
});
Expand Down Expand Up @@ -644,6 +685,21 @@ function writeFile(file, css) {
});
}

/**
* Write the given sourcemap.
*/

function writeSourcemap(file, sourcemap) {
// --out support
var path = dest
? join(dest, basename(file, '.styl') + '.css.map')
: file.replace(/\.styl$/i, '.css.map');
fs.writeFile(path, JSON.stringify(sourcemap), function(err){
if (err) throw err;
console.log(' \033[90mgenerated\033[0m %s', path);
});
}

/**
* Watch the given `file` and recompiling `rootFile` when modified.
*/
Expand Down
2 changes: 1 addition & 1 deletion docs/bifs.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Returns a `Literal` `num` converted to the provided `base`, padded to `width` wi
base-convert(14, 16, 1)
// => e

base-convert(42, 1)
base-convert(42, 2)
// => 101010


Expand Down
4 changes: 4 additions & 0 deletions docs/executable.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Stylus ships with the `stylus` executable for converting Stylus to CSS.
can be used by the FireStylus Firebug plugin
-l, --line-numbers Emits comments in the generated CSS
indicating the corresponding Stylus line
-m, --sourcemap Generates a sourcemap in sourcemaps v3 format
--sourcemap-inline Inlines sourcemap with full source text in base64 format
--sourcemap-root <url> "sourceRoot" property of the generated sourcemap
--sourcemap-base <path> Base <path> from which sourcemap and all sources are relative
-P, --prefix [prefix] Prefix all css classes
-p, --print Print out the compiled CSS
--import <file> Import stylus <file>
Expand Down
1 change: 1 addition & 0 deletions docs/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Return Connect middleware with the given `options`.
be used by the FireStylus Firebug plugin
`linenos` Emits comments in the generated css indicating
the corresponding stylus line
`sourcemap` Generates a sourcemap in sourcemaps v3 format

### Examples

Expand Down
39 changes: 39 additions & 0 deletions docs/sourcemaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
layout: default
permalink: docs/sourcemaps.html
---

# Sourcemaps

Stylus supports basic sourcemaps according to the [Sourcemap v3 spec](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k)

## Create a sourcemap

Pass the `--sourcemap` flag (or `-m`) with a Stylus file. This will create a `style.css` file, and a `style.css.map` file as siblings to your `style.styl` and place a sourcemap link at the bottom of `style.css` to your sourcemap.

`stylus -m style.styl`

You can also run this command while watching a file. For instance: `stylus -w -m style.styl`. This will update your sourcemap everytime you save.

## JavaScript API

Set the `sourcemap` setting with an options object or a boolean value:

var stylus = require('stylus');

var style = stylus(str)
.set('filename', 'file.styl')
.set('sourcemap', options);

style.render(function(err, css) {
// generated sourcemap object
console.log(style.sourcemap);
});

### Options

`comment` Adds a comment with the `sourceMappingURL` to the generated CSS (default: `true`)
`inline` Inlines the sourcemap with full source text in base64 format (default: `false`)
`sourceRoot` "sourceRoot" property of the generated sourcemap
`basePath` Base path from which sourcemap and all sources are relative (default: `.`)

3 changes: 2 additions & 1 deletion lib/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,5 @@ module.exports = {
, whitesmoke: [245, 245, 245]
, yellow: [255, 255, 0]
, yellowgreen: [154, 205, 50]
};
, rebeccapurple: [102, 51, 153]
};
Loading

0 comments on commit adf1643

Please sign in to comment.