@@ -10,6 +10,7 @@ Projects = ['rspec', 'rspec-core', 'rspec-expectations', 'rspec-mocks', 'rspec-r
10
10
UnDocumentedProjects = %w[ rspec rspec-support ]
11
11
BaseRspecPath = Pathname . new ( Dir . pwd )
12
12
ReposPath = BaseRspecPath . join ( 'repos' )
13
+ MAX_PROJECT_NAME_LENGTH = Projects . map ( &:length ) . max
13
14
14
15
def run_command ( command , opts = { } )
15
16
projects = if opts [ :except ]
@@ -71,14 +72,30 @@ desc "Updates the rspec.github.io docs"
71
72
task :update_docs , [ :version , :branch , :website_path ] do |t , args |
72
73
abort "You must have ag installed to generate docs" if `which ag` == ""
73
74
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 "\r Checking versions... #{ project } "
75
83
latest_release = `git fetch --tags && git tag | grep '^v\\ \d .\\ \d .\\ \d $' | grep v#{ args [ :version ] } | tail -1`
76
84
77
85
if latest_release . empty?
78
- next "No release found for #{ args [ :version ] } in #{ `pwd` } "
86
+ skipped << project
87
+ else
88
+ projects [ project ] = latest_release
79
89
end
90
+ $stdout. write "\r Checking versions... " + ( " " * MAX_PROJECT_NAME_LENGTH )
91
+ end
92
+
93
+ $stdout. write "\r \n "
80
94
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 ] } `
82
99
doc_destination_path = "#{ args [ :website_path ] } /source/documentation/#{ args [ :version ] } /#{ project } /"
83
100
cmd = "bundle update && \
84
101
RUBYOPT='-I#{ args [ :website_path ] } /lib' bundle exec yard \
@@ -97,6 +114,8 @@ task :update_docs, [:version, :branch, :website_path] do |t, args|
97
114
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/' {}}
98
115
Bundler . unbundled_system %Q{ag --html -l . #{ doc_destination_path } | xargs -I{} sed #{ in_place } /^[[:space:]]*$/d {}}
99
116
end
117
+
118
+ puts "Skipped projects: (#{ skipped . join ( ", " ) } ) due to no matching version." unless skipped . empty?
100
119
end
101
120
102
121
namespace :gem do
0 commit comments