Take snapshot into account

This commit is contained in:
Clément Fournier
2018-08-15 03:08:46 +02:00
parent b8fb9bd63f
commit 22c143f6e6
6 changed files with 30 additions and 11 deletions

View File

@ -9,7 +9,7 @@
# ARGV[0] : location of the file to render
require "liquid"
require "yaml"
require "safe_yaml"
# include some custom liquid extensions
require_relative "../docs/_plugins/rule_tag"
@ -24,8 +24,12 @@ end
release_notes_file = ARGV[0]
# wrap the config under a "site." namespace because that's how jekyll does it
liquid_env = {'site' => YAML.load_file("docs/_config.yml")}
liquid_env = {
# wrap the config under a "site." namespace because that's how jekyll does it
'site' => YAML.load_file("docs/_config.yml"),
# This signals the links in {% rule %} tags that they should be rendered as absolute
'is_release_notes_processor' => true
}
to_render = File.read(release_notes_file)

View File

@ -2,5 +2,8 @@ source 'https://rubygems.org/'
gem 'pmdtester', '~> 1.0.0.pre.beta3'
gem 'danger', '~> 5.6', '>= 5.6'
gem 'liquid', '>=4.0.0'
gem 'safe_yaml', '>=1.0'
# vim: syntax=ruby

View File

@ -68,6 +68,19 @@ module CustomFilters
end
end
# Append the suffix only if the condition argument is truthy
def append_if(str, condition, suffix)
if condition
str + suffix
else
str
end
end
def append_unless(str, condition, suffix)
append_if(str, !condition, suffix)
end
def render_markdown(input)
if input
res = input

View File

@ -49,8 +49,10 @@ class RuleTag < Liquid::Tag
url_prefix = ""
if (version = context["site.pmd.version"])
url_prefix = "https://pmd.github.io/pmd-#{version}/"
# This is passed from the release notes processing script
# When generating links for the release notes, the links should be absolute
if context["is_release_notes_processor"]
url_prefix = "https://pmd.github.io/pmd-#{context["site.pmd.version"]}/"
end
markup_link(@rule_name, url_prefix + relativelink(@lang_name, @category_name, @rule_name))

View File

@ -25,12 +25,9 @@ Make sure code is up to date and everything is committed and pushed with git:
### The Release Notes and docs
At a very minimum, the current date must be noted in the release notes and the download section. Also, the version
must be adjusted. E.g. by removing "-SNAPSHOT".
You can find the release notes here: `docs/pages/release_notes.md`.
The date for the download section is to be entered in `docs/_config.yml`, e.g.
The date and the version must be updated in `docs/_config.yml`, e.g.
```
pmd:
@ -148,7 +145,7 @@ permalink: pmd_release_notes.html
keywords: changelog, release notes
---
## {{ site.pmd.date }} - {{ site.pmd.version }}
## {{ site.pmd.date }} - {{ site.pmd.version | append_unless: is_release_version, "-SNAPSHOT" }}
The PMD team is pleased to announce PMD {{ site.pmd.version }}.

View File

@ -4,7 +4,7 @@ permalink: pmd_release_notes.html
keywords: changelog, release notes
---
## {{ site.pmd.date }} - {{ site.pmd.version }}
## {{ site.pmd.date }} - {{ site.pmd.version | append_unless: is_release_version, "-SNAPSHOT" }}
The PMD team is pleased to announce PMD {{ site.pmd.version }}.