diff --git a/.travis/render_release_notes.rb b/.travis/render_release_notes.rb index ec856974cc..e1dd76fa8d 100755 --- a/.travis/render_release_notes.rb +++ b/.travis/render_release_notes.rb @@ -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) diff --git a/Gemfile b/Gemfile index e83b9a4e44..021d709a97 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/docs/_plugins/custom_filters.rb b/docs/_plugins/custom_filters.rb index 3d77f8af0c..42ca4b0fef 100644 --- a/docs/_plugins/custom_filters.rb +++ b/docs/_plugins/custom_filters.rb @@ -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 diff --git a/docs/_plugins/rule_tag.rb b/docs/_plugins/rule_tag.rb index cdcf1d940f..0e81e64bdd 100644 --- a/docs/_plugins/rule_tag.rb +++ b/docs/_plugins/rule_tag.rb @@ -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)) diff --git a/docs/pages/pmd/projectdocs/committers/releasing.md b/docs/pages/pmd/projectdocs/committers/releasing.md index da930570a5..5800289cac 100644 --- a/docs/pages/pmd/projectdocs/committers/releasing.md +++ b/docs/pages/pmd/projectdocs/committers/releasing.md @@ -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 }}. diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 13f31e86d2..e9aa02fd69 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -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 }}.