Skip to content
This repository was archived by the owner on Jul 18, 2022. It is now read-only.

Commit de79d06

Browse files
author
Florent Biville
committed
[#26] Document approach to copyright in README
1 parent 0b0c0f7 commit de79d06

File tree

1 file changed

+50
-24
lines changed

1 file changed

+50
-24
lines changed

README.md

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ It is biased towards Golang but should work on any other language (provided a co
77

88
[![Build Status](https://travis-ci.org/fbiville/headache.svg?branch=master)](https://travis-ci.org/fbiville/headache)
99

10-
## Example
10+
## Quick start
1111

12-
By default, `headache` looks for a file named `headache.json` in the current directory:
12+
By default, `headache` looks for a configuration file named `headache.json` in the directory in which it is invoked:
1313

1414
```json
1515
{
@@ -23,7 +23,7 @@ By default, `headache` looks for a file named `headache.json` in the current dir
2323
}
2424
```
2525

26-
`license-header.txt`:
26+
`license-header.txt` (note the absence of `Year` parameter in the configuration file):
2727
```
2828
Copyright {{.Year}} {{.Owner}}
2929
@@ -40,26 +40,7 @@ See the License for the specific language governing permissions and
4040
limitations under the License.
4141
```
4242

43-
44-
## Settings
45-
46-
`headache` relies on the emerging [JSON Schema standard](https://json-schema.org/) to validate its configuration.
47-
`headache` schema is defined [here](https://fbiville.github.io/headache/schema.json).
48-
49-
In layman's terms, here are all the possible settings:
50-
51-
Setting | Type | Definition |
52-
| ---------------- |:----------------------: | -----------------------------------------------------: |
53-
| `headerFile` | string | **[required]** Path to the parameterized license header. Parameters are referenced with the following syntax: {{.PARAMETER-NAME}} |
54-
| `style` | string | **[required]** One of: `SlashStar` (`/* ... */`), `SlashSlash` (`// ...`) |
55-
| `includes` | array of strings | **[required, min size=1]** File globs to include (`*` and `**` are supported) |
56-
| `excludes` | array of strings | File globs to exclude (`*` and `**` are supported) |
57-
| `data` | map of string to string | Key-value pairs, matching the parameters used in `headerFile`.<br>Please note that `{{.Year}}` is a reserved parameter and will automatically be computed based on the files versioning information. |
58-
59-
60-
## Run
61-
62-
By default, a file named `headache.json` must be present in the current directory.
43+
### Run
6344

6445
All you have to do then is:
6546
```shell
@@ -70,11 +51,56 @@ All you have to do then is:
7051
As a result, source files will be changed and `.headache-run` will be generated to keep track of `headache` last execution.
7152
This file must be versioned along with the source file changes.
7253

73-
## Run with custom configuration
54+
### Run with custom configuration
7455

7556
Alternatively, the configuration file can be explicitly provided:
7657
```shell
7758
$ go get -u github.com/fbiville/headache
7859
$ $(GOBIN)/headache --configuration /path/to/configuration.json
7960
```
8061

62+
## Reference documentation
63+
64+
### Approach
65+
66+
`headache` approach to copyright is well explained in [this stackoverflow answer](https://stackoverflow.com/a/2391555/277128),
67+
read it first!
68+
69+
Now that you read this, here are two important points:
70+
71+
- Copyright years have to be updated when a significant change occurs.
72+
73+
There is, to the author knowledge, no automatic solution to distinguish a trivial
74+
change from a significant one.
75+
76+
Based on this premise, `headache` will process all files matching the configuration
77+
and that have been changed since its last execution.
78+
`headache` will then compute the copyright year, file by file, from their available versioning information (typically
79+
by retrieving the relevant dates from Git commits).
80+
81+
**It is up to the project maintainer to discard the generated changes if they are not relevant.**
82+
83+
- > The [first] date on the [copyright] notice establishes how far back the claim is made.
84+
85+
This claim could predate any commit associated to the file (imagine a file copied from project
86+
to project for years).
87+
88+
`headache` will never overwrite the start date of the copyright year if it finds one.
89+
90+
### Configuration
91+
92+
`headache` relies on the emerging [JSON Schema standard](https://json-schema.org/) to validate its configuration.
93+
`headache` schema is defined [here](https://fbiville.github.io/headache/schema.json).
94+
95+
In layman's terms, here are all the possible settings:
96+
97+
Setting | Type | Definition |
98+
| ---------------- |:----------------------: | -----------------------------------------------------: |
99+
| `headerFile` | string | **[required]** Path to the parameterized license header. Parameters are referenced with the following syntax: {{.PARAMETER-NAME}} |
100+
| `style` | string | **[required]** One of: `SlashStar` (`/* ... */`), `SlashSlash` (`// ...`) |
101+
| `includes` | array of strings | **[required, min size=1]** File globs to include (`*` and `**` are supported) |
102+
| `excludes` | array of strings | File globs to exclude (`*` and `**` are supported) |
103+
| `data` | map of string to string | Key-value pairs, matching the parameters used in `headerFile`.<br>Please note that `{{.Year}}` is a reserved parameter and will automatically be computed based on the files versioning information. |
104+
105+
106+

0 commit comments

Comments
 (0)