keepachangelog 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -14
- data/Gemfile.lock +2 -2
- data/README.md +69 -4
- data/changelog/0.1.0/json.yaml +3 -0
- data/changelog/0.1.0/tool.yaml +3 -0
- data/changelog/0.1.0/yaml.yaml +3 -0
- data/changelog/0.2.0/markdown-output.yaml +3 -0
- data/changelog/0.2.0/yaml-input.yaml +3 -0
- data/changelog/0.2.1/fix-documentation.yaml +3 -0
- data/changelog/0.3.0/2-multiple-changes.yaml +4 -0
- data/changelog/0.3.0/3-anchors-without-url.yaml +4 -0
- data/changelog/0.3.0/4-document-meta.yaml +4 -0
- data/changelog/Unreleased/2-multiple-changes.yaml +4 -0
- data/changelog/Unreleased/3-anchors-without-url.yaml +4 -0
- data/changelog/Unreleased/4-document-meta.yaml +4 -0
- data/changelog/meta.yaml +2 -0
- data/features/yaml.feature +1 -1
- data/lib/keepachangelog/cli.rb +1 -1
- data/lib/keepachangelog/markdown_printer.rb +3 -1
- data/lib/keepachangelog/parser/markdown.rb +7 -4
- data/lib/keepachangelog/parser/yaml.rb +3 -2
- data/package.json +1 -1
- data/spec/parser/markdown_spec.rb +1 -1
- data/spec/parser/yaml_spec.rb +1 -1
- data/spec/parser_spec.rb +8 -0
- metadata +14 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba8c6c289a59b43d4162e7dcbaa0ba5e8aaee9fb
|
4
|
+
data.tar.gz: 717fc1d7b2b6c500b120437e15b629c60091f385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a04b57cf6d2cce3295f14fbbfe0c88753b2aa0c9990d84e0ffa2cd33a1ae8392df08b9a607224e1c420d77936847d388042229e0dfa3f1ef707098f76f6933a
|
7
|
+
data.tar.gz: d5821bf9d3ba88cbafd5d6780ab50be991b982ccae2249ebde9a687388674e978ef7afe80ff038539efb3bc297509d94bdca9d7637d64b0af66296f3794eabe8
|
data/CHANGELOG.md
CHANGED
@@ -1,25 +1,42 @@
|
|
1
|
-
# Change
|
2
|
-
|
1
|
+
# Change log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
### Fixed
|
9
|
+
- YAML parser can now read multiple changes in a version. (#2)
|
10
|
+
- Do not display anchors when URL is missing. (#3)
|
11
|
+
|
12
|
+
### New
|
13
|
+
- Documentation on how to add metadata. (#4)
|
14
|
+
|
15
|
+
## [0.3.0]
|
16
|
+
### Fixed
|
17
|
+
- YAML parser can now read multiple changes in a version. (#2)
|
18
|
+
- Do not display anchors when URL is missing. (#3)
|
19
|
+
|
20
|
+
### New
|
21
|
+
- Documentation on how to add metadata. (#4)
|
6
22
|
|
7
23
|
## [0.2.1] - 2017-03-27
|
8
|
-
###
|
9
|
-
-
|
24
|
+
### Fixed
|
25
|
+
- Fix documentation formatting for YAML parser.
|
10
26
|
|
11
27
|
## [0.2.0] - 2017-03-27
|
12
|
-
###
|
13
|
-
-
|
14
|
-
-
|
28
|
+
### New
|
29
|
+
- Ability to print in Markdown.
|
30
|
+
- Ability to read YAML files.
|
15
31
|
|
16
32
|
## [0.1.0] - 2017-03-27
|
17
|
-
###
|
18
|
-
-
|
19
|
-
-
|
20
|
-
-
|
33
|
+
### New
|
34
|
+
- Ability to convert Changelog to JSON.
|
35
|
+
- Tool for reading Changelog in Markdown format.
|
36
|
+
- Ability to convert Changelog to YAML.
|
21
37
|
|
22
|
-
[Unreleased]: https://git.basalt.se/chbr/keepachangelog/compare/0.
|
38
|
+
[Unreleased]: https://git.basalt.se/chbr/keepachangelog/compare/0.3.0...HEAD
|
39
|
+
[0.3.0]: https://git.basalt.se/chbr/keepachangelog/compare/0.2.1...0.3.0
|
23
40
|
[0.2.1]: https://git.basalt.se/chbr/keepachangelog/compare/0.2.0...0.2.1
|
24
41
|
[0.2.0]: https://git.basalt.se/chbr/keepachangelog/compare/0.1.0...0.2.0
|
25
42
|
[0.1.0]: https://git.basalt.se/chbr/keepachangelog/compare/77986bc...0.1.0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# Changelog parser and transformer
|
2
2
|
|
3
3
|
Ruby gem for parsing Changelogs based on the format described at
|
4
|
-
keepachangelog.com.
|
4
|
+
[keepachangelog.com](http://keepachangelog.com).
|
5
|
+
|
6
|
+
The parser can read either a Markdown file or a folder structure with
|
7
|
+
YAML-files.
|
8
|
+
|
9
|
+
The output can be Markdown, YAML or JSON.
|
5
10
|
|
6
11
|
## Installation
|
7
12
|
|
@@ -21,15 +26,75 @@ Or install it yourself as:
|
|
21
26
|
|
22
27
|
## Usage
|
23
28
|
|
29
|
+
### Command line
|
30
|
+
|
31
|
+
#### Markdown input
|
24
32
|
To dump a Changelog to JSON run the following command:
|
25
33
|
|
26
|
-
keepachangelog --path
|
34
|
+
keepachangelog --path CHANGELOG.md --format json
|
35
|
+
|
36
|
+
#### YAML input
|
37
|
+
You can also express your changelog in YAML files inside a folder structure
|
38
|
+
where each version is its own folder containing each change in a YAML-file.
|
39
|
+
|
40
|
+
Here's an example of a folder structure:
|
41
|
+
```
|
42
|
+
changelog
|
43
|
+
├── 0.1.0
|
44
|
+
│ └── 1-first-merge-request.yaml
|
45
|
+
├── 0.2.0
|
46
|
+
│ └── 3-another-cool-mr.yaml
|
47
|
+
├── 0.3.0
|
48
|
+
│ ├── 8-fixing-some-stuff.yaml
|
49
|
+
│ └── 9-add-new-feature.yaml
|
50
|
+
└── unreleased
|
51
|
+
└── 11-minor-patch.yaml
|
52
|
+
```
|
53
|
+
|
54
|
+
Each YAML-file should be in the following format:
|
55
|
+
|
56
|
+
```yaml
|
57
|
+
---
|
58
|
+
title: The ability to perform Foo while Bar is active
|
59
|
+
merge_request: 11
|
60
|
+
issue: 42
|
61
|
+
author: "@chbr"
|
62
|
+
type: New
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
- `title`: A single sentence without punctiation that describes the change
|
67
|
+
- `merge_request`: The ID of the MR or PR (optional)
|
68
|
+
- `issue`: The ID of the issue (optional)
|
69
|
+
- `author`: The author of the change (optional)
|
70
|
+
- `type`: The type of change, for example *New*, *Changed*, *Fixed*,
|
71
|
+
*Removed* or *Security*.
|
72
|
+
|
73
|
+
To turn this into a Markdown document, simply run `keepachangelog yaml -f md`
|
74
|
+
|
75
|
+
You can add meta data to your changelog in the file `meta.yaml`, placed inside
|
76
|
+
the changelog folder, like so:
|
77
|
+
|
78
|
+
```yaml
|
79
|
+
---
|
80
|
+
title: My Change Log
|
81
|
+
intro: This is my change log and I am using a cool gem to generate it.
|
82
|
+
url: https://git.example.com/group/project
|
83
|
+
```
|
84
|
+
|
85
|
+
The following meta data is read:
|
86
|
+
- `title`: The title at the top of the Change log
|
87
|
+
- `intro`: A text shown directly below the title
|
88
|
+
- `url`: A URL to the git repository, used to generate links for versions
|
89
|
+
that follows the format *<url>/compare/FROM..TO*
|
90
|
+
|
91
|
+
### From Ruby code
|
27
92
|
|
28
93
|
If you want to use the API from your own Ruby code:
|
29
94
|
|
30
95
|
```ruby
|
31
96
|
require 'keepachangelog'
|
32
|
-
parser = Keepachangelog::
|
97
|
+
parser = Keepachangelog::MarkdownParser.load('CHANGELOG.md')
|
33
98
|
puts parser.to_json
|
34
99
|
```
|
35
100
|
|
data/changelog/meta.yaml
ADDED
data/features/yaml.feature
CHANGED
data/lib/keepachangelog/cli.rb
CHANGED
@@ -23,6 +23,7 @@ module Keepachangelog
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def clean_intro(text)
|
26
|
+
return nil unless text
|
26
27
|
text.to_s.strip.gsub("\n", "\n\n")
|
27
28
|
end
|
28
29
|
|
@@ -42,6 +43,7 @@ module Keepachangelog
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def anchors
|
46
|
+
return nil unless options[:url]
|
45
47
|
v = versions.keys.sort.reverse
|
46
48
|
(0..v.length - 1).map { |i| anchor(v, i) }
|
47
49
|
end
|
@@ -49,7 +51,7 @@ module Keepachangelog
|
|
49
51
|
def anchor(v, i)
|
50
52
|
from_v = i == v.length - 1 ? first_commit : v[i + 1]
|
51
53
|
to_v = v[i] == 'Unreleased' ? 'HEAD' : v[i]
|
52
|
-
"[#{v[i]}]: #{options[:url]}/compare/#{from_v}
|
54
|
+
"[#{v[i]}]: #{options[:url]}/compare/#{from_v}...#{to_v}"
|
53
55
|
end
|
54
56
|
|
55
57
|
def change(content)
|
@@ -8,16 +8,19 @@ module Keepachangelog
|
|
8
8
|
|
9
9
|
# Parse a file with markdown content
|
10
10
|
def self.load(filename = 'CHANGELOG.md')
|
11
|
-
|
11
|
+
p = new
|
12
|
+
p.parse File.open(filename, &:read)
|
13
|
+
p
|
12
14
|
end
|
13
15
|
|
14
16
|
def parse(content)
|
15
17
|
content = "\n" + clean(content).strip + "\n"
|
16
18
|
anchors = extract_anchors! content
|
17
19
|
versions = content.split(/\n\s*## /)[1..-1]
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
parsed_content['versions'] = versions.map do |v|
|
21
|
+
parse_version v, anchors
|
22
|
+
end.to_h
|
23
|
+
parsed_content
|
21
24
|
end
|
22
25
|
|
23
26
|
private
|
@@ -22,7 +22,7 @@ module Keepachangelog
|
|
22
22
|
# title: The ability to perform Foo while Bar is active
|
23
23
|
# merge_request: 11
|
24
24
|
# issue: 42
|
25
|
-
# author: @chbr
|
25
|
+
# author: "@chbr"
|
26
26
|
# type: New
|
27
27
|
#
|
28
28
|
# - `title` is a single sentence without punctiation that describes the
|
@@ -92,7 +92,7 @@ module Keepachangelog
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def generate_line(yaml)
|
95
|
-
line = yaml['title']
|
95
|
+
line = yaml['title'] + '.'
|
96
96
|
line += " (!#{yaml['merge_request']})" if yaml['merge_request']
|
97
97
|
line += " (##{yaml['issue']})" if yaml['issue']
|
98
98
|
line += " (#{yaml['author']})" if yaml['author']
|
@@ -100,6 +100,7 @@ module Keepachangelog
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def initialize_version(version)
|
103
|
+
return if parsed_content['versions'][version]
|
103
104
|
parsed_content['versions'][version] = { 'changes' => {} }
|
104
105
|
end
|
105
106
|
end
|
data/package.json
CHANGED
@@ -92,7 +92,7 @@ module Keepachangelog
|
|
92
92
|
allow(File).to receive(:open).and_call_original
|
93
93
|
expect(File).to receive(:open).with('test.md')
|
94
94
|
.and_yield(StringIO.new(content))
|
95
|
-
|
95
|
+
expect_any_instance_of(MarkdownParser).to receive(:parse).with(content)
|
96
96
|
MarkdownParser.load('test.md')
|
97
97
|
end
|
98
98
|
|
data/spec/parser/yaml_spec.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -25,5 +25,13 @@ module Keepachangelog
|
|
25
25
|
p.to_s
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe '.to_md' do
|
30
|
+
it 'should cast parsed content into a Markdown document' do
|
31
|
+
p = Parser.new
|
32
|
+
expect_any_instance_of(MarkdownPrinter).to receive(:to_s)
|
33
|
+
p.to_md
|
34
|
+
end
|
35
|
+
end
|
28
36
|
end
|
29
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keepachangelog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Basalt AB
|
@@ -142,6 +142,19 @@ files:
|
|
142
142
|
- README.md
|
143
143
|
- bin/console
|
144
144
|
- bin/setup
|
145
|
+
- changelog/0.1.0/json.yaml
|
146
|
+
- changelog/0.1.0/tool.yaml
|
147
|
+
- changelog/0.1.0/yaml.yaml
|
148
|
+
- changelog/0.2.0/markdown-output.yaml
|
149
|
+
- changelog/0.2.0/yaml-input.yaml
|
150
|
+
- changelog/0.2.1/fix-documentation.yaml
|
151
|
+
- changelog/0.3.0/2-multiple-changes.yaml
|
152
|
+
- changelog/0.3.0/3-anchors-without-url.yaml
|
153
|
+
- changelog/0.3.0/4-document-meta.yaml
|
154
|
+
- changelog/Unreleased/2-multiple-changes.yaml
|
155
|
+
- changelog/Unreleased/3-anchors-without-url.yaml
|
156
|
+
- changelog/Unreleased/4-document-meta.yaml
|
157
|
+
- changelog/meta.yaml
|
145
158
|
- exe/keepachangelog
|
146
159
|
- features/help.feature
|
147
160
|
- features/markdown.feature
|