Skip to content

Commit

Permalink
[#66] Microsite documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavsvejcar committed Apr 19, 2021
1 parent 3022903 commit 85d9d92
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file.

## 0.4.2.0 (in development)
- [#66] Allow loading templates from HTTP(S) resource
- Bump _LTS Haskell_ to `17.9`

## 0.4.1.0 (released 2021-03-14)
Expand Down
2 changes: 1 addition & 1 deletion doc/microsite/docs/documentation/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Before continuing to next chapters, here's the overview of key parts of _Headroo

- __Source Code Files__ - Those are the files in which the license headers should be managed by _Headroom_. You can specify multiple different locations and also paths that should be excluded.

- __License Templates__ - _Headroom_ uses [Mustache][web:mustache] templates to define the license headers. These templates are then compiled, variables are filled with actual and such rendered license headers are put into source code files.
- __Header Templates__ - _Headroom_ uses [Mustache][web:mustache] templates to define the license headers. These templates are then compiled, variables are filled with actual and such rendered license headers are put into source code files. At this moment _Headroom_ allows to define 3 different template sources: built-in templates (for popular _OSS_ licenses), templates stored on local file system and URL-based templates.

- __Variables__ - Changing parts of license headers (such as year, author, e-mail, etc.) can be represented by variables and the actual values are then loaded from either `.headroom.yaml` or command line arguments and filled in during template rendering.

Expand Down
2 changes: 1 addition & 1 deletion doc/microsite/docs/documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ excluded-paths:
Defines list of paths to source code files to process. Note that given path, if directory, is __recursively__ traversed for all types of source code files knowh to _Headroom_.

### `template-paths` key
Defined list of paths to _template files_, which defines how your _license headers_ will look like.
Defines list of _template_ paths. Path can be either relative or absolute path of template stored on local file system, or _URL_ pointing to template stored on Internet (note that only `HTTP` or `HTTPS` protocols are supported).

### `variables` key
This is the main point where you define values for variables present in template files. Variables in _Headroom_ can be split into two main categories:
Expand Down
10 changes: 6 additions & 4 deletions doc/microsite/docs/documentation/running-headroom.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Below is the overview of command line interface of `run` command:
```
$ headroom run --help
Usage: headroom run [-s|--source-path PATH] [-e|--excluded-path REGEX]
[--builtin-templates TYPE | (-t|--template-path PATH)]
[--builtin-templates licenseType] [-t|--template-path PATH]
[-v|--variable KEY=VALUE]
[(-a|--add-headers) | (-c|--check-headers) |
(-r|--replace-headers) | (-d|--drop-headers)] [--debug]
Expand All @@ -31,9 +31,10 @@ Usage: headroom run [-s|--source-path PATH] [-e|--excluded-path REGEX]
Available options:
-s,--source-path PATH path to source code file/directory
-e,--excluded-path REGEX path to exclude from source code file paths
--builtin-templates TYPE use built-in templates for license type, available
options: apache2, bsd3, gpl2, gpl3, mit, mpl2
-t,--template-path PATH path to license template file/directory
--builtin-templates licenseType
use built-in templates of selected license type
-t,--template-path PATH path to template, can be either local file or
directory or URL
-v,--variable KEY=VALUE value for template variable
-a,--add-headers only adds missing license headers
-c,--check-headers check whether existing headers are up-to-date
Expand All @@ -47,6 +48,7 @@ Available options:
This command requires you to specify three key parameters, either using command line option, or in `.headroom.yaml` file:

1. __paths to source code files__ - this needs to be specified either by using the `-s|--source-path PATH` option (can be repeated) or using the `source-paths` option in `.headroom.yaml`.
1. __paths to templates__ - you can freely combine all three supported sources of templates: First are built-in templates for one of supported _OSS_ licenses, which can be enabled by `--builtin-templates TYPE`. Second option is to use either templates stored on local file system or URI-based template. For local stored template, if path to directory is provided, _Headroom_ will recursively search for all suitable templates in all subdirectories.
1. __paths to template files__ - you have two options here. Either specify path(s) to template files using `-t|--template-path PATH` (can be repeated) or `template-paths` option in `.headroom.yaml`, __or__ use the built-in templates using the `--builtin-templates TYPE`, where `TYPE` is one of the supported _OSS_ license types.
1. __variables__ - if your templates use any variables, you need to specify their values using the `-v|--variable "KEY=VALUE"` option (can be repeated) or using the `variable` option in `.headroom.yaml`.
1. __run mode__ _(optional)_ - if you don't specify this, the _add mode_ will be used as default, but you can set the run mode using one of the `-a,--add-headers`, `-c,--check-headers`, `-r,--replace-headers` or `-d,--drop-headers` options, or using the `run-mode` option in `.headroom.yaml`.
Expand Down
33 changes: 31 additions & 2 deletions doc/microsite/docs/whats-new.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
Version `0.4.1.0` is minor release that brings some improvements and bugfixes, without any breaking changes.
Version `0.4.2.0` is minor release that brings some improvements and bugfixes, without any breaking changes in _CLI_ interface or configuration.

## New & Noteworthy

TODO
### Support for URL-based templates
Until now, _Headroom_ allowed to use only either _built-in_ templates or templates loaded from local file system. This version adds option to load templates from URL (at this moment only _HTTP_ and _HTTPS_ protocols are allowed). To use URL templates, just put the _HTTP(S)_ address where you normally put path to local template, i.e.:

```
-t|--template-file https://example.com/path/haskell.mustache
```

For command line or

```yaml
template-paths:
/some/local/haskell.mustache
https://example.com/path/rust.mustache
```
for _YAML_ configuration.
Note that you can freely combine all template types (i.e. _built-in templates_, _local templates_ and _URL templates_), but in case that same template will be define from multiple sources, following order will be applied to select one (left to right from least to most preferred):
```
built-in template > URL template > local template
```

Also note that naming convention is the same as for local templates, i.e.

```
http(s)://path/to/<FILE_TYPE>.<TEMPLATE_TYPE>
```

See [configuration chapter][doc:configuration] for more details.

## Other bugfixes and improvements
TODO
Expand Down
2 changes: 1 addition & 1 deletion src/Headroom/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ runOptions =
(option
templateRefReader
(long "template-path" <> short 't' <> metavar "PATH" <> help
"path to template"
"path to template, can be either local file or directory or URL"
)
)
<*> many
Expand Down

0 comments on commit 85d9d92

Please sign in to comment.