compilers.rst 3.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
.. _ref-compilers:

=========
Compilers
=========


Coffee Script compiler
======================

11
The Coffee Script compiler uses `Coffee Script <http://jashkenas.github.com/coffee-script/>`_
12 13
to compile your javascripts.

14
To use it add this to your ``PIPELINE_COMPILERS`` ::
15

16 17
  PIPELINE_COMPILERS = (
    'pipeline.compilers.coffee.CoffeeScriptCompiler',
18 19
  )

20
``PIPELINE_COFFEE_SCRIPT_BINARY``
21 22 23 24 25
---------------------------------

  Command line to execute for coffee program.
  You will most likely change this to the location of coffee on your system.

26
  Defaults to ``'/usr/bin/env coffee'``.
27

28
``PIPELINE_COFFEE_SCRIPT_ARGUMENTS``
29
------------------------------------
30

31
  Additional arguments to use when coffee is called.
32

33 34 35 36 37
  Defaults to ``''``.

LESS compiler
=============

38
The LESS compiler uses `LESS <http://lesscss.org/>`_
39 40
to compile your stylesheets.

41
To use it add this to your ``PIPELINE_COMPILERS`` ::
42

43 44
  PIPELINE_COMPILERS = (
    'pipeline.compilers.less.LessCompiler',
45 46
  )

47
``PIPELINE_LESS_BINARY``
48 49 50 51 52
------------------------

  Command line to execute for lessc program.
  You will most likely change this to the location of lessc on your system.

53
  Defaults to ``'/usr/bin/env lessc'``.
54

55
``PIPELINE_LESS_ARGUMENTS``
56 57 58 59 60 61 62 63 64
---------------------------

  Additional arguments to use when lessc is called.

  Defaults to ``''``.

SASS compiler
=============

65
The SASS compiler uses `SASS <http://sass-lang.com/>`_
66 67
to compile your stylesheets.

68
To use it add this to your ``PIPELINE_COMPILERS`` ::
69

70 71
  PIPELINE_COMPILERS = (
    'pipeline.compilers.sass.SASSCompiler',
72 73 74
  )


75
``PIPELINE_SASS_BINARY``
76
------------------------
77

78 79 80
  Command line to execute for sass program.
  You will most likely change this to the location of sass on your system.

81
  Defaults to ``'/usr/bin/env sass'``.
82

83
``PIPELINE_SASS_ARGUMENTS``
84
---------------------------
85

86 87 88 89 90
  Additional arguments to use when sass is called.

  Defaults to ``''``.


David Charbonnier committed
91 92 93
Stylus compiler
===============

94
The Stylus compiler uses `Stylus <http://learnboost.github.com/stylus/>`
David Charbonnier committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108
to compile your stylesheets.

To use it add this to your ``PIPELINE_COMPILERS`` ::

  PIPELINE_COMPILERS = (
      'pipeline.compilers.stylus.StylusCompiler',
  )


``PIPELINE_STYLUS_BINARY``
--------------------------

  Command line to execute for stylus program.
  You will most likely change this to the location of stylus on your system.
109 110

  Defaults to ``'/usr/bin/env stylus'``.
David Charbonnier committed
111 112 113 114 115

``PIPELINE_STYLUS_ARGUMENTS``
-----------------------------

  Additional arguments to use when stylus is called.
116

David Charbonnier committed
117 118 119 120
  Defaults to ``''``.



121 122 123
Write your own compiler class
=============================

124
You can write your own compiler class, for example if you want to implement other types
125 126
of compilers.

127
To do so, you just have to create a class that inherits from ``pipeline.compilers.CompilerBase``
128 129
and implements ``match_file`` and ``compile_file`` when needed.

130
Finally, specify it in the tuple of compilers ``PIPELINE_COMPILERS`` in the settings.
131 132 133 134

Example
-------

135
A custom compiler for an imaginary compiler called jam ::
136

137
  from pipeline.compilers import CompilerBase
138

139 140
  class JamCompiler(CompilerBase):
    output_extension = 'js'
141

142
    def match_file(self, filename):
143
      return filename.endswith('.jam')
144

145 146 147 148
    def compile_file(self, infile, outfile, outdated=False, force=False):
      if not outdated and not force:
        return  # No need to recompiled file
      return jam.compile(infile, outfile)
149