Skip to content

Commit 6d603b7

Browse files
committed
Improve handling of projects missing versions for generating docs
1 parent f15f90b commit 6d603b7

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

Rakefile

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Projects = ['rspec', 'rspec-core', 'rspec-expectations', 'rspec-mocks', 'rspec-r
1010
UnDocumentedProjects = %w[ rspec rspec-support ]
1111
BaseRspecPath = Pathname.new(Dir.pwd)
1212
ReposPath = BaseRspecPath.join('repos')
13+
MAX_PROJECT_NAME_LENGTH = Projects.map(&:length).max
1314

1415
def run_command(command, opts={})
1516
projects = if opts[:except]
@@ -71,14 +72,30 @@ desc "Updates the rspec.github.io docs"
7172
task :update_docs, [:version, :branch, :website_path] do |t, args|
7273
abort "You must have ag installed to generate docs" if `which ag` == ""
7374
args.with_defaults(:website_path => "../rspec.github.io")
74-
each_project :except => (UnDocumentedProjects) do |project|
75+
76+
projects = {}
77+
skipped = []
78+
79+
$stdout.write "Checking versions..."
80+
81+
each_project :silent => true, :except => (UnDocumentedProjects) do |project|
82+
$stdout.write "\rChecking versions... #{project}"
7583
latest_release = `git fetch --tags && git tag | grep '^v\\\d.\\\d.\\\d$' | grep v#{args[:version]} | tail -1`
7684

7785
if latest_release.empty?
78-
next "No release found for #{args[:version]} in #{`pwd`}"
86+
skipped << project
87+
else
88+
projects[project] = latest_release
7989
end
90+
$stdout.write "\rChecking versions... " + (" " * MAX_PROJECT_NAME_LENGTH)
91+
end
92+
93+
$stdout.write "\r\n"
8094

81-
`git checkout #{latest_release}`
95+
abort "No projects matched #{args[:version]}" if projects.empty?
96+
97+
each_project(:only => projects.keys) do |project|
98+
`git checkout #{projects[project]}`
8299
doc_destination_path = "#{args[:website_path]}/source/documentation/#{args[:version]}/#{project}/"
83100
cmd = "bundle update && \
84101
RUBYOPT='-I#{args[:website_path]}/lib' bundle exec yard \
@@ -97,6 +114,8 @@ task :update_docs, [:version, :branch, :website_path] do |t, args|
97114
Bundler.unbundled_system %Q{ag -l href=\\"\\\(?:..\/\\\)*css #{doc_destination_path} | xargs -I{} sed #{in_place} 's/href="\\\(..\\\/\\\)*css/href="\\\/documentation\\\/#{args[:version]}\\\/#{project}\\\/css/' {}}
98115
Bundler.unbundled_system %Q{ag --html -l . #{doc_destination_path} | xargs -I{} sed #{in_place} /^[[:space:]]*$/d {}}
99116
end
117+
118+
puts "Skipped projects: (#{skipped.join(", ")}) due to no matching version." unless skipped.empty?
100119
end
101120

102121
namespace :gem do

0 commit comments

Comments
 (0)