This outputs the results in Markdown for manual versions report updates.
Unified · Split
| @@ -17,7 +17,8 @@ class UpdatesCLI < Thor · 16 unmodified lines | ||
| 17 | 17 | super |
| 18 | 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 | 22 | option :github_token, :type => :string |
| 22 | 23 | option :upload, :type => :boolean |
| 23 | 24 | option :verbose, :type => :boolean |
| @@ -109,6 +110,10 @@ class UpdatesCLI < Thor · 85 unmodified lines | ||
| 109 | 110 | # |
| 110 | 111 | |
| 111 | 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 | 117 | log_failed_results(failed_results) unless failed_results.empty? |
| 113 | 118 | log_successful_results('Up-to-date', up_to_date_results) unless up_to_date_results.empty? |
| 114 | 119 | log_successful_results('Outdated', outdated_results) unless outdated_results.empty? |
| @@ -156,7 +161,10 @@ class UpdatesCLI < Thor · 41 unmodified lines | ||
| 156 | 161 | |
| 157 | 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 | 168 | created_issue = github_post("/repos/#{UPLOAD_REPO}/issues", issue) |
| 161 | 169 | |
| 162 | 170 | logger.info('Checking if the previous issue is still open') |
| @@ -189,7 +197,7 @@ class UpdatesCLI < Thor · 26 unmodified lines | ||
| 189 | 197 | end |
| 190 | 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 | 201 | results = [ |
| 194 | 202 | successful_results_to_markdown('Outdated', outdated_results), |
| 195 | 203 | successful_results_to_markdown('Up-to-date', up_to_date_results), |
| @@ -199,7 +207,6 @@ class UpdatesCLI < Thor · 3 unmodified lines | ||
| 199 | 207 | results_str = results.select {|result| !result.nil?}.join("\n\n") |
| 200 | 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 | 210 | body = <<-MARKDOWN |
| 204 | 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 | 221 | - #{up_to_date_results.length} that #{up_to_date_results.length == 1 ? 'is' : 'are'} up-to-date (patch updates are ignored) |
| 215 | 222 | - #{failed_results.length} that could not be checked |
| 216 | 223 | MARKDOWN |
| 217 | − | |
| 218 | − { | |
| 219 | − title: title, | |
| 220 | − body: body.strip + "\n\n" + results_str | |
| 221 | − } | |
| 224 | + body.strip + "\n\n" + results_str | |
| 222 | 225 | end |
| 223 | 226 | |
| 224 | 227 | def successful_results_to_markdown(label, results) |