1
1
# -*- mode: ruby -*-
2
2
3
+ require 'English'
3
4
$LOAD_PATH. unshift File . expand_path ( '.' )
4
5
5
6
require 'rake'
@@ -257,25 +258,21 @@ ie_generator.generate_type_mapping(
257
258
out : 'cpp/iedriver/IEReturnTypes.h'
258
259
)
259
260
261
+ desc 'Generate Javadocs'
260
262
task javadocs : %i[ //java/src/org/openqa/selenium/grid:all-javadocs ] do
261
- rm_rf 'build/javadoc '
262
- mkdir_p 'build/javadoc '
263
+ rm_rf 'build/docs/api/java '
264
+ mkdir_p 'build/docs/api/java '
263
265
264
- # Temporary hack, bazel is not outputting where things are so we need to do it manually.
265
- # This will only work on Posix based OSes
266
- Rake ::Task [ '//java/src/org/openqa/selenium/grid:all-javadocs' ]
267
266
out = 'bazel-bin/java/src/org/openqa/selenium/grid/all-javadocs.jar'
268
267
269
- cmd = %{cd build/javadoc && jar xf "../../#{ out } " 2>&1}
270
- if SeleniumRake ::Checks . windows?
271
- cmd = cmd . gsub ( /\/ / , '\\' ) . gsub ( /:/ , ';' )
272
- end
268
+ cmd = %(cd build/docs/api/java && jar xf "../../../../#{ out } " 2>&1)
269
+ cmd = cmd . tr ( '/' , '\\' ) . tr ( ':' , ';' ) if SeleniumRake ::Checks . windows?
273
270
274
271
ok = system ( cmd )
275
- ok or raise " could not unpack javadocs"
272
+ ok or raise ' could not unpack javadocs'
276
273
277
- File . open ( 'build/javadoc/ stylesheet.css' , 'a' ) { |file |
278
- file . write ( <<~EOF
274
+ File . open ( 'build/docs/api/java/ stylesheet.css' , 'a' ) do |file |
275
+ file . write ( <<~STYLE
279
276
/* Custom selenium-specific styling */
280
277
.blink {
281
278
animation: 2s cubic-bezier(0.5, 0, 0.85, 0.85) infinite blink;
@@ -287,9 +284,9 @@ task javadocs: %i[//java/src/org/openqa/selenium/grid:all-javadocs] do
287
284
}
288
285
}
289
286
290
- EOF
291
- )
292
- }
287
+ STYLE
288
+ )
289
+ end
293
290
end
294
291
295
292
file 'cpp/iedriver/sizzle.h' => [ '//third_party/js/sizzle:sizzle:header' ] do
@@ -553,16 +550,23 @@ namespace :py do
553
550
end
554
551
555
552
desc 'Generate Python documentation'
556
- task docs : :update do
557
- sh 'tox -c py/tox.ini -e docs' , verbose : true
553
+ task :docs do
554
+ FileUtils . rm_r ( 'build/docs/api/py/' , force : true )
555
+ FileUtils . rm_r ( 'build/docs/doctrees/' , force : true )
556
+ begin
557
+ sh 'tox -c py/tox.ini -e docs' , verbose : true
558
+ rescue StandardError
559
+ puts 'Ensure that tox is installed on your system'
560
+ raise
561
+ end
558
562
end
559
563
560
564
desc 'Install Python wheel locally'
561
565
task :install do
562
566
Bazel . execute ( 'build' , [ ] , '//py:selenium-wheel' )
563
567
begin
564
568
sh 'pip install bazel-bin/py/selenium-*.whl'
565
- rescue
569
+ rescue StandardError
566
570
puts 'Ensure that Python and pip are installed on your system'
567
571
raise
568
572
end
@@ -590,6 +594,13 @@ namespace :rb do
590
594
Bazel . execute ( 'run' , args , '//rb:selenium-webdriver' )
591
595
Bazel . execute ( 'run' , args , '//rb:selenium-devtools' )
592
596
end
597
+
598
+ desc 'Generate Ruby documentation'
599
+ task :docs do
600
+ FileUtils . rm_r ( 'build/docs/api/rb/' , force : true )
601
+ Bazel . execute ( 'run' , [ ] , '//rb:docs' )
602
+ FileUtils . cp_r ( 'bazel-bin/rb/docs.rb.sh.runfiles/selenium/docs/api/rb/.' , 'build/docs/api/rb' )
603
+ end
593
604
end
594
605
595
606
namespace :dotnet do
@@ -635,6 +646,29 @@ namespace :dotnet do
635
646
sh "dotnet nuget push #{ asset } --api-key #{ ENV . fetch ( 'NUGET_API_KEY' , nil ) } --source https://api.nuget.org/v3/index.json"
636
647
end
637
648
end
649
+
650
+ desc 'Generate .NET documentation'
651
+ task :docs do
652
+ begin
653
+ sh 'dotnet tool update -g docfx'
654
+ rescue StandardError
655
+ puts 'Please ensure that .NET SDK is installed.'
656
+ raise
657
+ end
658
+
659
+ begin
660
+ sh 'docfx dotnet/docs/docfx.json'
661
+ rescue StandardError
662
+ case $CHILD_STATUS. exitstatus
663
+ when 127
664
+ raise 'Ensure the dotnet/tools directory is added to your PATH environment variable (e.g., `~/.dotnet/tools`)'
665
+ when 255
666
+ puts 'Build failed, likely because of DevTools namespacing. This is ok; continuing'
667
+ else
668
+ raise
669
+ end
670
+ end
671
+ end
638
672
end
639
673
640
674
namespace :java do
@@ -666,6 +700,9 @@ namespace :java do
666
700
667
701
desc 'Install jars to local m2 directory'
668
702
task install : :'maven-install'
703
+
704
+ desc 'Generate Java documentation'
705
+ task docs : :javadocs
669
706
end
670
707
671
708
namespace :rust do
@@ -681,6 +718,16 @@ namespace :rust do
681
718
end
682
719
end
683
720
721
+ namespace :all do
722
+ desc 'Update all API Documentation'
723
+ task :docs do
724
+ Rake ::Task [ 'java:docs' ] . invoke
725
+ Rake ::Task [ 'py:docs' ] . invoke
726
+ Rake ::Task [ 'rb:docs' ] . invoke
727
+ Rake ::Task [ 'dotnet:docs' ] . invoke
728
+ end
729
+ end
730
+
684
731
at_exit do
685
732
if File . exist? ( '.git' ) && !SeleniumRake ::Checks . windows?
686
733
system 'sh' , '.git-fixfiles'
0 commit comments