What's new in v0.3.0.0?
New & Noteworthy¶
Support for Dynamic Template Variables¶
Until now, Headroom allowed to use static variables only. Static variables are defined by user either in YAML configuration or as command line argument and their values are same for all processed source code files.
On the other hand, dynamic variables are produced by Headroom during runtime and can be either the same for all processed source code files or may differ file from file. Dynamic variables also stars with underscode symbol, so you can easy tell which one is dynamic and which static. Following global dynamic variables were added as part of this update:
_current_year
- When used in template file, this variable will be always replaced by the value of current year (e.g.2020
).
Template Variables are Templates as well¶
From now, each template variable defined in variables
part of YAML configuration is also considered as template, so you can use variables inside variables, as long as you
- don't call variables recursively
- don't address variables in cyclic dependency
Example of how you can use this is to compose copyright
variable from existing author
static variable and _current_year
dynamic variable:
variables:
author: John Smith
copyright: Copyright (c) {{ _current_year }} {{ author }}
Extracting Dynamic Variables from Existing Haddock Module Headers¶
Let's say you want to use Headroom to manage your license headers that are also Haddock module headers, but you want to reuse values of some fields from already existing Haddock module headers (e.g. Copyright
, Maintainer
, etc). From this release, when Headroom processes Haskell source code files, it will automatically extract value of possibly existing Haddock module header and expose them through dynamic variables. You can then define your template file as following:
{-|
Module : {{{ _haskell_module_name }}}
Description : {{{ _haskell_module_shortdesc }}}
Copyright : {{{ _haskell_module_copyright }}}
License : {{ license }}
Maintainer : {{ email }}
Stability : experimental
Portability : POSIX
{{{ _haskell_module_longdesc }}}
-}
If the processed source file will contain Haddock module header with the Copyright
field, such field value will be exposed as _haskell_module_copyright
. You can also define default values in case that you process new files or files without Haddock module header, as following:
variables:
author: John Smith
_haskell_module_copyright: Copyright (c) {{ _current_year }} {{ author }}
And yes, you can use variables inside variables, isn't that great? :-) See Extended Functionality chapter for more details.
Support for Updating Years in Copyright Statements¶
This version introduces new concept called post-processing functions. These functions allow performing some extra post-processing on rendered license headers. For example, you can use the update-copyright
post-processing function to keep years in your copyright statemets up-to-date. see Post-processing Functions chapter for more details.
Support Workflow without Template and Configuration Files¶
If you plan to use Headroom occasionally or don't like the idea to generate configuration/template file into your project, you can use basic functions of Headroom using only command line options. See Configuration chapter for more details.
Migrating from v0.2.1.0¶
There are no breaking changes in CLI API or YAML configuration from last public release v0.2.1.0
, so upgrading to v0.3.0.0
should be drop-in replacement.