@@ -466,10 +466,7 @@ namespace :node do
466466 raise
467467 end
468468
469- unless arguments [ :skip_update ]
470- puts 'Updating JavaScript documentation'
471- puts update_gh_pages ? 'JavaScript Docs updated!' : 'JavaScript Doc update cancelled'
472- end
469+ update_gh_pages unless arguments [ :skip_update ]
473470 end
474471
475472 desc 'Update JavaScript changelog'
@@ -563,10 +560,7 @@ namespace :py do
563560 raise
564561 end
565562
566- unless arguments [ :skip_update ]
567- puts 'Updating Python documentation'
568- puts update_gh_pages ? 'Python Docs updated!' : 'Python Doc update cancelled'
569- end
563+ update_gh_pages unless arguments [ :skip_update ]
570564 end
571565
572566 desc 'Install Python wheel locally'
@@ -700,10 +694,7 @@ namespace :rb do
700694 FileUtils . mkdir_p ( 'build/docs/api' )
701695 FileUtils . cp_r ( 'bazel-bin/rb/docs.sh.runfiles/_main/docs/api/rb/.' , 'build/docs/api/rb' )
702696
703- unless arguments [ :skip_update ]
704- puts 'Updating Ruby documentation'
705- puts update_gh_pages ? 'Ruby Docs updated!' : 'Ruby Doc update cancelled'
706- end
697+ update_gh_pages unless arguments [ :skip_update ]
707698 end
708699
709700 desc 'Update Ruby changelog'
@@ -810,10 +801,7 @@ namespace :dotnet do
810801 end
811802 end
812803
813- unless arguments [ :skip_update ]
814- puts 'Updating .NET documentation'
815- puts update_gh_pages ? '.NET Docs updated!' : '.NET Doc update cancelled'
816- end
804+ update_gh_pages unless arguments [ :skip_update ]
817805 end
818806
819807 desc 'Update .NET changelog'
@@ -896,10 +884,7 @@ namespace :java do
896884 task :docs , [ :skip_update ] do |_task , arguments |
897885 Rake ::Task [ 'javadocs' ] . invoke
898886
899- unless arguments [ :skip_update ]
900- puts 'Updating Java documentation'
901- puts update_gh_pages ? 'Java Docs updated!' : 'Java Doc update cancelled'
902- end
887+ update_gh_pages unless arguments [ :skip_update ]
903888 end
904889
905890 desc 'Update Maven dependencies'
@@ -1013,16 +998,13 @@ end
1013998namespace :all do
1014999 desc 'Update all API Documentation'
10151000 task :docs do
1016- FileUtils . rm_rf ( 'build/docs/api' )
1017-
10181001 Rake ::Task [ 'java:docs' ] . invoke ( true )
10191002 Rake ::Task [ 'py:docs' ] . invoke ( true )
10201003 Rake ::Task [ 'rb:docs' ] . invoke ( true )
10211004 Rake ::Task [ 'dotnet:docs' ] . invoke ( true )
10221005 Rake ::Task [ 'node:docs' ] . invoke ( true )
10231006
1024- puts 'Updating All API Docs'
1025- puts update_gh_pages ? 'AP Docs updated!' : 'API Doc update cancelled'
1007+ update_gh_pages
10261008 end
10271009
10281010 desc 'Build all artifacts for all language bindings'
@@ -1052,7 +1034,7 @@ namespace :all do
10521034 Rake ::Task [ 'rb:release' ] . invoke ( *args )
10531035 Rake ::Task [ 'dotnet:release' ] . invoke ( *args )
10541036 Rake ::Task [ 'node:release' ] . invoke ( *args )
1055- Rake :: Task [ 'all:docs' ] . invoke
1037+
10561038 Rake ::Task [ 'all:version' ] . invoke ( 'nightly' )
10571039
10581040 puts 'Committing nightly version updates'
@@ -1164,70 +1146,19 @@ def updated_version(current, desired = nil, nightly = nil)
11641146 end
11651147end
11661148
1167- # TODO: make this less insane
1168- # rubocop:disable all
11691149def update_gh_pages
1170- origin_reference = @git . current_branch
1171- origin_reference ||= begin
1172- # This allows updating docs from a tagged commit instead of a branch
1173- puts 'commit is not at HEAD, checking for matching tag'
1174- tag = @git . tags . detect { |t | t . sha == @git . revparse ( 'HEAD' ) }
1175- tag ? tag . name : raise ( StandardError , 'Must be on a tagged commit or at the HEAD of a branch to update API Docs' )
1176- end
1177-
1178- puts 'Checking out gh-pages'
1179- begin
1180- @git . checkout ( 'gh-pages' )
1181- rescue Git ::FailedError => e
1182- # This happens when the working directory is not clean and things need to be stashed or committed
1183- line = e . message . lines [ 2 ] . gsub ( 'output: "error: ' , '' )
1184- puts line . gsub ( '\t' , "\t " ) . split ( '\n' ) [ 0 ...-2 ] . join ( "\n " )
1185- # TODO: we could offer to automatically fix with a stash, but there may be edge cases
1186- print 'Manually Fix and Retry? (Y/n):'
1187- response = $stdin. gets . chomp . downcase
1188- return false unless %w[ y yes ] . include? ( response )
1189-
1190- retry
1191- end
1192-
1193- puts 'Updating gh-pages branch from upstream repository'
1194- begin
1195- @git . pull
1196- rescue Git ::FailedError => e
1197- # This happens when upstream is not already set
1198- line = e . message . lines [ 2 ] . gsub ( 'output: "error: ' , '' )
1199- puts line . gsub ( '\t' , "\t " ) . split ( '\n' ) . delete_if ( &:empty? ) [ -2 ...-1 ] . join ( "\n " )
1200- print 'Manually Fix and Retry? (Y/n):'
1201- response = $stdin. gets . chomp . downcase
1202- return restore_git ( origin_reference ) unless %w[ y yes ] . include? ( response )
1203-
1204- retry
1205- end
1150+ @git . fetch ( 'origin' , { ref : 'gh-pages' } )
1151+ @git . checkout ( 'gh-pages' , force : true )
12061152
12071153 %w[ java rb py dotnet javascript ] . each do |language |
12081154 next unless Dir . exist? ( "build/docs/api/#{ language } " ) && !Dir . empty? ( "build/docs/api/#{ language } " )
12091155
1210- puts "Deleting #{ language } directory in docs/api since corresponding directory in build/docs/api is not empty"
12111156 FileUtils . rm_rf ( "docs/api/#{ language } " )
1212- puts 'Moving documentation files from untracked build directory to tracked docs directory'
12131157 FileUtils . mv ( "build/docs/api/#{ language } " , "docs/api/#{ language } " )
1214- end
1215-
1216- print 'Do you want to commit the changes? (Y/n): '
1217- response = $stdin. gets . chomp . downcase
1218- return restore_git ( origin_reference ) unless %w[ y yes ] . include? ( response )
12191158
1220- puts 'Committing changes'
1221- commit! ( 'updating all API docs' , [ 'docs/api/' ] )
1222-
1223- puts 'Pushing changes to upstream repository'
1224- @git . push
1225-
1226- puts "Checking out originating branch/tag — #{ origin_reference } "
1227- @git . checkout ( origin_reference )
1228- true
1159+ commit! ( "updating #{ language } API docs" , [ "docs/api/#{ language } /" ] )
1160+ end
12291161end
1230- # rubocop:disable all
12311162
12321163def restore_git ( origin_reference )
12331164 puts 'Stashing docs changes for gh-pages'
0 commit comments