History

thor updates:check --markdown

This outputs the results in Markdown for manual versions report updates.

Simon Legner committed 5 years ago

Commit e8b152f1 parent b078b551 file · +12 −9Browse files

Unified · Split

lib/tasks/updates.thor+12−9
@@ -17,7 +17,8 @@ class UpdatesCLI < Thor · 16 unmodified lines
1717 super
1818 end
1919
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
2122 option :github_token, :type => :string
2223 option :upload, :type => :boolean
2324 option :verbose, :type => :boolean
@@ -109,6 +110,10 @@ class UpdatesCLI < Thor · 85 unmodified lines
109110 #
110111
111112 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
112117 log_failed_results(failed_results) unless failed_results.empty?
113118 log_successful_results('Up-to-date', up_to_date_results) unless up_to_date_results.empty?
114119 log_successful_results('Outdated', outdated_results) unless outdated_results.empty?
@@ -156,7 +161,10 @@ class UpdatesCLI < Thor · 41 unmodified lines
156161
157162 logger.info('Creating a new GitHub issue')
158163
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+ }
160168 created_issue = github_post("/repos/#{UPLOAD_REPO}/issues", issue)
161169
162170 logger.info('Checking if the previous issue is still open')
@@ -189,7 +197,7 @@ class UpdatesCLI < Thor · 26 unmodified lines
189197 end
190198 end
191199
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)
193201 results = [
194202 successful_results_to_markdown('Outdated', outdated_results),
195203 successful_results_to_markdown('Up-to-date', up_to_date_results),
@@ -199,7 +207,6 @@ class UpdatesCLI < Thor · 3 unmodified lines
199207 results_str = results.select {|result| !result.nil?}.join("\n\n")
200208 travis_str = ENV['TRAVIS'].nil? ? '' : "\n\nThis issue was created by Travis CI build [##{ENV['TRAVIS_BUILD_NUMBER']}](#{ENV['TRAVIS_BUILD_WEB_URL']})."
201209
202− title = "Documentation versions report for #{Date.today.strftime('%B %Y')}"
203210 body = <<-MARKDOWN
204211 ## What is this?
205212
@@ -214,11 +221,7 @@ The #{outdated_results.length + up_to_date_results.length + failed_results.lengt · 8 unmodified lines
214221 - #{up_to_date_results.length} that #{up_to_date_results.length == 1 ? 'is' : 'are'} up-to-date (patch updates are ignored)
215222 - #{failed_results.length} that could not be checked
216223 MARKDOWN
217−
218− {
219− title: title,
220− body: body.strip + "\n\n" + results_str
221− }
224+ body.strip + "\n\n" + results_str
222225 end
223226
224227 def successful_results_to_markdown(label, results)