This outputs the results in Markdown for manual versions report updates.
Unified · Split
| @@ -17,7 +17,8 @@ class UpdatesCLI < Thor · 16 unmodified lines | |||
| 17 | super | 17 | super |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | desc 'check [--github-token] [--upload] [--verbose] [doc]...', 'Check for outdated documentations' | 20 | desc 'check [--markdown] [--github-token] [--upload] [--verbose] [doc]...', 'Check for outdated documentations' |
| 21 | option :markdown, :type => :boolean | ||
| 21 | option :github_token, :type => :string | 22 | option :github_token, :type => :string |
| 22 | option :upload, :type => :boolean | 23 | option :upload, :type => :boolean |
| 23 | option :verbose, :type => :boolean | 24 | option :verbose, :type => :boolean |
| @@ -109,6 +110,10 @@ class UpdatesCLI < Thor · 85 unmodified lines | |||
| 109 | # | 110 | # |
| 110 | 111 | ||
| 111 | def log_results(outdated_results, up_to_date_results, failed_results) | 112 | def log_results(outdated_results, up_to_date_results, failed_results) |
| 113 | if options[:markdown] | ||
| 114 | puts all_results_to_markdown(outdated_results, up_to_date_results, failed_results) | ||
| 115 | return | ||
| 116 | end | ||
| 112 | log_failed_results(failed_results) unless failed_results.empty? | 117 | log_failed_results(failed_results) unless failed_results.empty? |
| 113 | log_successful_results('Up-to-date', up_to_date_results) unless up_to_date_results.empty? | 118 | log_successful_results('Up-to-date', up_to_date_results) unless up_to_date_results.empty? |
| 114 | log_successful_results('Outdated', outdated_results) unless outdated_results.empty? | 119 | log_successful_results('Outdated', outdated_results) unless outdated_results.empty? |
| @@ -156,7 +161,10 @@ class UpdatesCLI < Thor · 41 unmodified lines | |||
| 156 | 161 | ||
| 157 | logger.info('Creating a new GitHub issue') | 162 | logger.info('Creating a new GitHub issue') |
| 158 | 163 | ||
| 159 | issue = results_to_issue(outdated_results, up_to_date_results, failed_results) | 164 | issue = { |
| 165 | title: "Documentation versions report for #{Date.today.strftime('%B %Y')}", | ||
| 166 | body: all_results_to_markdown(outdated_results, up_to_date_results, failed_results) | ||
| 167 | } | ||
| 160 | created_issue = github_post("/repos/#{UPLOAD_REPO}/issues", issue) | 168 | created_issue = github_post("/repos/#{UPLOAD_REPO}/issues", issue) |
| 161 | 169 | ||
| 162 | logger.info('Checking if the previous issue is still open') | 170 | logger.info('Checking if the previous issue is still open') |
| @@ -189,7 +197,7 @@ class UpdatesCLI < Thor · 26 unmodified lines | |||
| 189 | end | 197 | end |
| 190 | end | 198 | end |
| 191 | 199 | ||
| 192 | def results_to_issue(outdated_results, up_to_date_results, failed_results) | 200 | def all_results_to_markdown(outdated_results, up_to_date_results, failed_results) |
| 193 | results = [ | 201 | results = [ |
| 194 | successful_results_to_markdown('Outdated', outdated_results), | 202 | successful_results_to_markdown('Outdated', outdated_results), |
| 195 | successful_results_to_markdown('Up-to-date', up_to_date_results), | 203 | successful_results_to_markdown('Up-to-date', up_to_date_results), |
| @@ -199,7 +207,6 @@ class UpdatesCLI < Thor · 3 unmodified lines | |||
| 199 | results_str = results.select {|result| !result.nil?}.join("\n\n") | 207 | results_str = results.select {|result| !result.nil?}.join("\n\n") |
| 200 | travis_str = ENV['TRAVIS'].nil? ? '' : "\n\nThis issue was created by Travis CI build [##{ENV['TRAVIS_BUILD_NUMBER']}](#{ENV['TRAVIS_BUILD_WEB_URL']})." | 208 | travis_str = ENV['TRAVIS'].nil? ? '' : "\n\nThis issue was created by Travis CI build [##{ENV['TRAVIS_BUILD_NUMBER']}](#{ENV['TRAVIS_BUILD_WEB_URL']})." |
| 201 | 209 | ||
| 202 | title = "Documentation versions report for #{Date.today.strftime('%B %Y')}" | ||
| 203 | body = <<-MARKDOWN | 210 | body = <<-MARKDOWN |
| 204 | ## What is this? | 211 | ## What is this? |
| 205 | 212 | ||
| @@ -214,11 +221,7 @@ The #{outdated_results.length + up_to_date_results.length + failed_results.lengt · 8 unmodified lines | |||
| 214 | - #{up_to_date_results.length} that #{up_to_date_results.length == 1 ? 'is' : 'are'} up-to-date (patch updates are ignored) | 221 | - #{up_to_date_results.length} that #{up_to_date_results.length == 1 ? 'is' : 'are'} up-to-date (patch updates are ignored) |
| 215 | - #{failed_results.length} that could not be checked | 222 | - #{failed_results.length} that could not be checked |
| 216 | MARKDOWN | 223 | MARKDOWN |
| 217 | 224 | body.strip + "\n\n" + results_str | |
| 218 | { | ||
| 219 | title: title, | ||
| 220 | body: body.strip + "\n\n" + results_str | ||
| 221 | } | ||
| 222 | end | 225 | end |
| 223 | 226 | ||
| 224 | def successful_results_to_markdown(label, results) | 227 | def successful_results_to_markdown(label, results) |