From 810846168f8e14f63caefac534b843b7681b881f Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Thu, 22 Feb 2024 14:48:04 -0500 Subject: [PATCH] 21494: Adapt linkchecker arguments to built SDKs This lets you build a subset of SDK documentation, linkcheck it, and get an accurate result. Arvados-DCO-1.1-Signed-off-by: Brett Smith --- doc/Rakefile | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/Rakefile b/doc/Rakefile index c4e26cfb3b..3ec494f57d 100644 --- a/doc/Rakefile +++ b/doc/Rakefile @@ -19,6 +19,8 @@ # # and then visit http://localhost:8000 in a browser. +require "uri" + require "rubygems" require "colorize" @@ -31,18 +33,30 @@ def can_run?(*command, **options) end class JavaSDK + def self.build_path + "sdk/java-v2" + end + def self.can_build? can_run?("gradle", "--version") end end class PythonSDK + def self.build_path + "sdk/python/arvados" + end + def self.can_build? can_run?("./pysdk_pdoc.py", "--version") end end class RSDK + def self.build_path + "sdk/R" + end + def self.can_build? can_run?("R", "--version") end @@ -196,8 +210,17 @@ end task :linkchecker => [ :generate ] do # we need --check-extern to check relative links, weird but true + opts = [ + "--check-extern", + "--ignore-url=!^file://", + ] + ([JavaSDK, PythonSDK, RSDK] - $build_sdks).map(&:build_path).each do |sdk_path| + sdk_url = URI.join(ENV["baseurl"], sdk_path) + url_re = Regexp.escape(sdk_url.to_s) + opts << "--ignore-url=^#{url_re}[./]" + end result = system( - "linkchecker", "index.html", "--check-extern", "--ignore-url=!file://", + "linkchecker", *opts, "index.html", chdir: ".site", ) if result.nil? -- 2.30.2