Variable Substitution
Often it is necessary to transport values from the build into the documentation, like the current version of the project. This can be done with properties. Properties can be defined with sbt settings and can then be accessed in documentation Markdown files.
Defining Properties
With Sbt Settings
To define properties add a key / value tuple to the paradoxProperties
setting. For example, to make the Scala version of the build available to the documentation you can use this (in fact, this property is already predefined):
paradoxProperties += ("scala.version" -> scalaVersion.value)
With Front-Matter
You can set or override property values with “front-matter” on pages. At the beginning of a Markdown file, add a block
---
key: This is my key value
---
to change a property value just for this page.
Referencing Properties From Markdown
In Markdown you can either directly reference properties using dollar notation $property$
.
For example, this snippet:
The scala version is "$scala.version$".
renders as:
The scala version is “2.12.20”.
Alternatively, you can also use the @var
or @@@vars
directives to insert property values depending on the context.
Predefined Properties
project.name
: Name of the projectproject.version
: Project versionproject.version.short
: Project version with-SNAPSHOT
replaced by*
project.description
: Project descriptionproject.license
: Project licensescala.version
: Project Scala Versionscala.binary.version
: Project Scala binary compatible version (e.g. “2.12”)date
: Generation date in the formMMM DD, YYYY
date.day
: Generation day of the monthdate.month
: Generation monthdate.year
: Generation year
Special Properties
Some properties have special meaning for the generation engine. See the Templating section for more information.