From 91e65e13ab9c85ba755f0f350044cbb5357863b2 Mon Sep 17 00:00:00 2001 From: Will Fleming Date: Tue, 16 Feb 2016 18:26:38 -0500 Subject: [PATCH 1/2] rake docs: pull currently used rubocop version We were hardcoding this tag, which of course led to it being forgotten for an update when we updated rubocop. Rubocop tags their repository reliably, so I think it's reasonable to use the loaded rubocop's version here to decide what tag to checkout. --- lib/tasks/docs.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tasks/docs.rake b/lib/tasks/docs.rake index 7b66c165..b03bc039 100644 --- a/lib/tasks/docs.rake +++ b/lib/tasks/docs.rake @@ -1,7 +1,8 @@ namespace :docs do desc "Scrapes documentation from the rubocop gem" task :scrape do - TAG = "v0.34.2" + require "rubocop" + TAG = "v#{RuboCop::Version.version}" COP_FOLDERS = %w[lint metrics performance rails style] %x{git clone https://github.com/bbatsov/rubocop.git rubocop-git} From 0b6175f3fdecf0f80c2450edddcf62ea1b5b5fa5 Mon Sep 17 00:00:00 2001 From: Will Fleming Date: Tue, 16 Feb 2016 19:18:57 -0500 Subject: [PATCH 2/2] Fix doc scraping for newer rubocop RuboCop has added magic comments for encoding & frozen string literals to all of their source, which breaks our attempts to extract doc comments. This changes the logic to discard all comment lines at the beginning of the file, and only use the remainder of the file after the first non-comment line to look for the doc comments. --- lib/tasks/docs.rake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tasks/docs.rake b/lib/tasks/docs.rake index b03bc039..4c6f9ae9 100644 --- a/lib/tasks/docs.rake +++ b/lib/tasks/docs.rake @@ -12,7 +12,12 @@ namespace :docs do documentation = files.each_with_object({}) do |file, hash| content = File.read(file) - class_doc = content.match(/(\s+#.*)+/).to_s + seen_non_comment_lines = false + sanitized_content = content.split("\n").reject do |line| + seen_non_comment_lines = true unless line.start_with?("#") + !seen_non_comment_lines + end.join("\n") + class_doc = sanitized_content.match(/(\s+#.*)+/).to_s doc_lines = class_doc. gsub(/^\n/,""). gsub("@example", "### Example:").