<commit_before>
/*!
 * Stylus - Renderer
 * Copyright(c) 2010 LearnBoost <<EMAIL>>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var Parser = require('./parser')
  , Compiler = require('./visitor/compiler')
  , Evaluator = require('./visitor/evaluator')
  , utils = require('./utils')
  , nodes = require('./nodes');

/**
 * Initialize a new `Renderer` with the given `str` and `options`.
 *
 * @param {String} str
 * @param {Object} options
 * @api public
 */

var Renderer = module.exports = function Renderer(str, options) {
  options = options || {};
  options.functions = {};
  options.imports = [__dirname + '/functions'];
  options.filename = options.filename || 'stylus';
  options.paths = [];
  this.str = str;
  this.options = options;
  this.parser = new Parser(str, options);
};

/**
 * Parse and evaluate AST, then callback `fn(err, css)`.
 *
 * @param {Function} fn
 * @api public
 */

Renderer.prototype.render = function(fn){
  try {
    var ast = this.parser.parse()
      , expr;
    this.evaluator = new Evaluator(ast, this.options);
    ast = this.evaluator.evaluate();
    fn(null, new Compiler(ast, this.options).compile());
  } catch (err) {
    fn(utils.formatException(
        this
      , err
      , this.options));
  }
  nodes.source = null;
};

/**
 * Set option `key` to `val`.
 *
 * @param {String} key
 * @param {Mixed} val
 * @return {Renderer} for chaining
 * @api public
 */

Renderer.prototype.set = function(key, val){
  this.options[key] = val;
  return this;
};

/**
 * Include the given `path` to the lookup paths array.
 *
 * @param {String} path
 * @return {Renderer} for chaining
 * @api public
 */

Renderer.prototype.include = function(path){
  this.paths.push(path);
  return this;
};

/**
 * Define function with the given `name`. Optionally
 * the function may accept full expressions, by setting `raw`
 * to `true`.
 *
 * @param {String} name
 * @param {Function} fn
 * @return {Renderer} for chaining
 * @api public
 */

Renderer.prototype.define = function(name, fn, raw){
  this.options.functions[name] = fn;
  if (undefined != raw) fn.raw = raw;
  return this;
};

/**
 * Import the given `file`.
 *
 * @param {String} file
 * @return {Renderer} for chaining
 * @api public
 */

Renderer.prototype.import = function(file){
  this.options.imports.push(file);
  return this;
};


<commit_msg>don't clobber the paths passed<commit_after>
/*!
 * Stylus - Renderer
 * Copyright(c) 2010 LearnBoost <<EMAIL>>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var Parser = require('./parser')
  , Compiler = require('./visitor/compiler')
  , Evaluator = require('./visitor/evaluator')
  , utils = require('./utils')
  , nodes = require('./nodes');

/**
 * Initialize a new `Renderer` with the given `str` and `options`.
 *
 * @param {String} str
 * @param {Object} options
 * @api public
 */

var Renderer = module.exports = function Renderer(str, options) {
  options = options || {};
  options.functions = {};
  options.imports = [__dirname + '/functions'];
  options.filename = options.filename || 'stylus';
  options.paths = options.paths || [];
  this.str = str;
  this.options = options;
  this.parser = new Parser(str, options);
};

/**
 * Parse and evaluate AST, then callback `fn(err, css)`.
 *
 * @param {Function} fn
 * @api public
 */

Renderer.prototype.render = function(fn){
  try {
    var ast = this.parser.parse()
      , expr;
    this.evaluator = new Evaluator(ast, this.options);
    ast = this.evaluator.evaluate();
    fn(null, new Compiler(ast, this.options).compile());
  } catch (err) {
    fn(utils.formatException(
        this
      , err
      , this.options));
  }
  nodes.source = null;
};

/**
 * Set option `key` to `val`.
 *
 * @param {String} key
 * @param {Mixed} val
 * @return {Renderer} for chaining
 * @api public
 */

Renderer.prototype.set = function(key, val){
  this.options[key] = val;
  return this;
};

/**
 * Include the given `path` to the lookup paths array.
 *
 * @param {String} path
 * @return {Renderer} for chaining
 * @api public
 */

Renderer.prototype.include = function(path){
  this.paths.push(path);
  return this;
};

/**
 * Define function with the given `name`. Optionally
 * the function may accept full expressions, by setting `raw`
 * to `true`.
 *
 * @param {String} name
 * @param {Function} fn
 * @return {Renderer} for chaining
 * @api public
 */

Renderer.prototype.define = function(name, fn, raw){
  this.options.functions[name] = fn;
  if (undefined != raw) fn.raw = raw;
  return this;
};

/**
 * Import the given `file`.
 *
 * @param {String} file
 * @return {Renderer} for chaining
 * @api public
 */

Renderer.prototype.import = function(file){
  this.options.imports.push(file);
  return this;
};



{'fraction_non_alphanumeric': 0.16462642465175178, 'fraction_numerical': 0.0016884761502743773, 'mean_word_length': 3.277075812274368, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6151167', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1534, 'n_words': 425}