jekyll-keepachangelog 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cfcdf6000c7585f0107ab41edf39c5a0a717c29555ada6b1ee93059e8c09d8c6
4
+ data.tar.gz: 30a74ff2b95e165dbf61146b20ef6921b85601fa918ec82297780147ab465fc8
5
+ SHA512:
6
+ metadata.gz: f0f4065655f0cbcc657902409326d2d7d110a64d7147a8c383fc6882fcc40e58066d4feb2c26b2739d5ddc41965b2ec68103f48400120ee552a16f9e7596fe3a
7
+ data.tar.gz: 48fb025f62dadda1f1037a63b5a0e42cd1d345f0882cf1617009839b60c6a2c2685fb0d5aebb1deeb31435e7e01037070078e6f800aa1eeb898ed7ee3d12b5fd
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jason Chance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # jekyll-keepachangelog
2
+
3
+ A Jekyll plugin that parses a [Keep a Changelog](https://keepachangelog.com)–formatted `CHANGELOG.md` and exposes it as structured data at `site.data.changelog` for use in Liquid templates.
4
+
5
+ ## Installation
6
+
7
+ Add to your site's `Gemfile`:
8
+
9
+ ```ruby
10
+ gem "jekyll-keepachangelog"
11
+ ```
12
+
13
+ Then add to `_config.yml`:
14
+
15
+ ```yaml
16
+ plugins:
17
+ - jekyll-keepachangelog
18
+ ```
19
+
20
+ Run `bundle install`.
21
+
22
+ ## Configuration
23
+
24
+ By default the plugin reads `CHANGELOG.md` from your Jekyll site root. To use a different file:
25
+
26
+ ```yaml
27
+ changelog:
28
+ file: docs/CHANGELOG.md
29
+ ```
30
+
31
+ ## Data structure
32
+
33
+ `site.data.changelog` is an array of hashes, one per version section, in the order they appear in the file:
34
+
35
+ ```ruby
36
+ [
37
+ {
38
+ "version" => "1.2.0",
39
+ "date" => "2024-03-15", # String or nil for Unreleased
40
+ "unreleased" => false, # true only for [Unreleased]
41
+ "sections" => {
42
+ "Added" => ["Feature A", "Feature B"],
43
+ "Fixed" => ["Bug fix C"]
44
+ }
45
+ },
46
+ {
47
+ "version" => "Unreleased",
48
+ "date" => nil,
49
+ "unreleased" => true,
50
+ "sections" => {
51
+ "Added" => ["Something upcoming"]
52
+ }
53
+ }
54
+ ]
55
+ ```
56
+
57
+ - `version` — the version string inside `[…]`, e.g. `"1.2.0"` or `"Unreleased"`
58
+ - `date` — the ISO 8601 date string after the ` - ` separator, or `nil`
59
+ - `unreleased` — `true` when the version label is `Unreleased` (case-insensitive)
60
+ - `sections` — hash of section name → array of item strings; only sections present in the file are included; an empty section is represented as `[]`
61
+
62
+ Only top-level list items (lines starting with `- ` or `* ` at column 0) are captured. Indented sub-bullets are ignored.
63
+
64
+ ## Liquid template example
65
+
66
+ ```liquid
67
+ {% for version in site.data.changelog %}
68
+ <h2>
69
+ {{ version.version }}
70
+ {% if version.date %} — {{ version.date }}{% endif %}
71
+ </h2>
72
+
73
+ {% for section in version.sections %}
74
+ <h3>{{ section[0] }}</h3>
75
+ <ul>
76
+ {% for item in section[1] %}
77
+ <li>{{ item }}</li>
78
+ {% endfor %}
79
+ </ul>
80
+ {% endfor %}
81
+ {% endfor %}
82
+ ```
83
+
84
+ ## CHANGELOG.md format
85
+
86
+ The plugin expects [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format:
87
+
88
+ ```markdown
89
+ # Changelog
90
+
91
+ ## [Unreleased]
92
+ ### Added
93
+ - Something coming soon
94
+
95
+ ## [1.2.0] - 2024-03-15
96
+ ### Added
97
+ - Feature A
98
+ - Feature B
99
+ ### Fixed
100
+ - Bug fix C
101
+
102
+ ## [1.1.0] - 2024-01-10
103
+ ### Changed
104
+ - Changed X
105
+ ```
106
+
107
+ ## Development
108
+
109
+ ```bash
110
+ bundle install
111
+ bundle exec ruby -Ilib test/changelog_test.rb
112
+ ```
113
+
114
+ The parser (`lib/jekyll-keepachangelog/parser.rb`) has no Jekyll dependency and can be tested in isolation. The generator (`lib/jekyll/changelog_generator.rb`) wires the parser into the Jekyll build.
115
+
116
+ ## Contributing
117
+
118
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
119
+
120
+ ## License
121
+
122
+ MIT — see [LICENSE.txt](LICENSE.txt).
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll-changelog/parser"
4
+
5
+ module Jekyll
6
+ class ChangelogGenerator < Jekyll::Generator
7
+ safe true
8
+ priority :low
9
+
10
+ def generate(site)
11
+ filename = site.config.dig("changelog", "file") || "CHANGELOG.md"
12
+ path = File.join(site.source, filename)
13
+
14
+ unless File.exist?(path)
15
+ Jekyll.logger.warn "jekyll-changelog:", "#{filename} not found — skipping."
16
+ return
17
+ end
18
+
19
+ parser = Jekyll::Keepachangelog::Parser.new
20
+ content = File.read(path, encoding: "utf-8")
21
+ site.data["changelog"] = parser.parse(content)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Keepachangelog
5
+ class Parser
6
+ VERSION_HEADING = /^##\s+\[([^\]]+)\](?:\s+-\s+(\d{4}-\d{2}-\d{2}))?/
7
+ SECTION_HEADING = /^###\s+(.+)/
8
+ BULLET_ITEM = /^[-*]\s+(.+)/
9
+
10
+ def parse(markdown_text)
11
+ return [] if markdown_text.nil? || markdown_text.strip.empty?
12
+
13
+ entries = []
14
+ current_version = nil
15
+ current_section = nil
16
+
17
+ markdown_text.each_line do |raw_line|
18
+ line = raw_line.rstrip
19
+
20
+ if (m = VERSION_HEADING.match(line))
21
+ entries << build_entry(current_version) if current_version
22
+ label = m[1]
23
+ date = m[2]
24
+ current_version = {
25
+ "version" => label,
26
+ "date" => date,
27
+ "unreleased" => label.casecmp("unreleased").zero?,
28
+ "_sections" => {},
29
+ "_section" => nil
30
+ }
31
+ current_section = nil
32
+
33
+ elsif (m = SECTION_HEADING.match(line)) && current_version
34
+ current_section = m[1].strip
35
+ current_version["_sections"][current_section] ||= []
36
+ current_version["_section"] = current_section
37
+
38
+ elsif (m = BULLET_ITEM.match(line)) && current_version && current_section
39
+ # Only capture top-level bullets (no leading spaces)
40
+ if raw_line =~ /\A[-*]\s/
41
+ current_version["_sections"][current_section] << m[1].strip
42
+ end
43
+ end
44
+ end
45
+
46
+ entries << build_entry(current_version) if current_version
47
+ entries
48
+ end
49
+
50
+ private
51
+
52
+ def build_entry(data)
53
+ {
54
+ "version" => data["version"],
55
+ "date" => data["date"],
56
+ "unreleased" => data["unreleased"],
57
+ "sections" => data["_sections"]
58
+ }
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Keepachangelog
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll-keepachangelog/version"
4
+ require "jekyll-changelog/parser"
5
+ require "jekyll/changelog_generator"
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-keepachangelog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Chance
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2026-08-21 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: jekyll
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '4.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '4.0'
26
+ description: Parses a Keep a Changelog–formatted CHANGELOG.md and exposes it as site.data.changelog
27
+ — an array of version hashes — for use in Liquid templates.
28
+ email:
29
+ - jason@jasonchance.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE.txt
35
+ - README.md
36
+ - lib/jekyll-keepachangelog.rb
37
+ - lib/jekyll-keepachangelog/parser.rb
38
+ - lib/jekyll-keepachangelog/version.rb
39
+ - lib/jekyll/changelog_generator.rb
40
+ homepage: https://github.com/jchance/jekyll-keepachangelog
41
+ licenses:
42
+ - MIT
43
+ metadata:
44
+ homepage_uri: https://github.com/jchance/jekyll-keepachangelog
45
+ source_code_uri: https://github.com/jchance/jekyll-keepachangelog
46
+ changelog_uri: https://github.com/jchance/jekyll-keepachangelog/blob/main/CHANGELOG.md
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.7.0
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.6.2
62
+ specification_version: 4
63
+ summary: Render your CHANGELOG.md as structured data in Jekyll.
64
+ test_files: []