Files
sbt/src/sphinx/Detailed-Topics/Compiler-Plugins.rst
T
Mark Harrah c14179c358 Docs: custom role 'codeliteral' to allow substitutions in inline code
The built-in 'literal' role implements ``.  It tokenizes the
literal string to attempt some particular wrapping behavior.
This puts parts of the string in different spans, each with
class='pre' and the previous docs.css had a padding for that
class.  This led to excessive space within the literal string.

The custom role does no do this tokenization, but nested
inline parsing can result in multiple nodes, repeating the
problem.  So, the padding for class='pre' is dropped.  Ideally,
the sequence of nodes would simply be wrapped in an inline element
with class='pre' or some other proper solution that avoids having
multiple nodes.

To avoid wrapping in the middle of a literal, the 'pre' class
now has the style `white-space: pre;`.

The default role is now 'codeliteral' and the previous
uses of the built-in `` are converted to `.  Some incorrectly
converted code blocks were fixed in the process.

Finally, the Global-Settings page is updated with the new location
for the global sbt directory.  Due to the above changes, this could
be done without hardcoding the version.
2013-07-29 07:27:17 -04:00

65 lines
1.8 KiB
ReStructuredText

=======================
Compiler Plugin Support
=======================
There is some special support for using compiler plugins. You can set
`autoCompilerPlugins` to `true` to enable this functionality.
::
autoCompilerPlugins := true
To use a compiler plugin, you either put it in your unmanaged library
directory (`lib/` by default) or add it as managed dependency in the
`plugin` configuration. `addCompilerPlugin` is a convenience method
for specifying `plugin` as the configuration for a dependency:
::
addCompilerPlugin("org.scala-tools.sxr" %% "sxr" % "0.2.7")
The `compile` and `testCompile` actions will use any compiler
plugins found in the `lib` directory or in the `plugin`
configuration. You are responsible for configuring the plugins as
necessary. For example, Scala X-Ray requires the extra option:
::
// declare the main Scala source directory as the base directory
scalacOptions :=
scalacOptions.value :+ ("-Psxr:base-directory:" + (scalaSource in Compile).value.getAbsolutePath)
You can still specify compiler plugins manually. For example:
::
scalacOptions += "-Xplugin:<path-to-sxr>/sxr-0.2.7.jar"
Continuations Plugin Example
============================
Support for continuations in Scala 2.8 is implemented as a compiler
plugin. You can use the compiler plugin support for this, as shown here.
::
autoCompilerPlugins := true
addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.8.1")
scalacOptions += "-P:continuations:enable"
Version-specific Compiler Plugin Example
========================================
Adding a version-specific compiler plugin can be done as follows:
::
autoCompilerPlugins := true
libraryDependencies +=
compilerPlugin("org.scala-lang.plugins" % "continuations" % scalaVersion.value)
scalacOptions += "-P:continuations:enable"