2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: CC-BY-SA-3.0
6 # As a convenience to the documentation writer, you can touch a file
7 # called 'no-sdk' in the 'doc' directory and it will suppress
8 # generating the documentation for the SDKs, which (the R docs
9 # especially) take a fair bit of time and slow down the edit-preview
12 # To generate and view the documentation locally, run this command
14 # rake && sensible-browser .site/index.html
18 # baseurl=http://localhost:8000 rake && rake run
20 # and then visit http://localhost:8000 in a browser.
27 def can_run?(*command, **options)
30 :out => [File::NULL, "w"],
32 system(*command, **options)
41 can_run?("gradle", "--version")
51 can_run?("./pysdk_pdoc.py", "--version")
61 can_run?("make", "can_run", chdir: File.join("..", self.build_path))
66 no_sdk_env = ENV.fetch("NO_SDK", "")
67 sdks_env = ENV.fetch("sdks", "")
68 all_sdks = Hash[[JavaSDK, PythonSDK, RSDK].map { |c| [c.name, c] }]
70 if no_sdk_env != "" and sdks_env != ""
71 fail "both NO_SDK and sdks defined in environment"
74 elsif no_sdk_env != "" or File.exist?("no-sdk")
79 all_sdks.each_pair.filter_map do |name, sdk|
83 puts "Warning: cannot build #{name.gsub(/SDK$/, ' SDK')} documentation, skipping".colorize(:light_red)
88 sdks_env.split(/\s*[,\s]\s*/).each do |key|
89 key = "#{key.capitalize}SDK"
91 wanted_sdks = all_sdks.values
92 elsif key == "NoneSDK"
94 elsif sdk = all_sdks[key]
97 fail "cannot build documentation for unknown #{key}"
106 @binary_files = %w[png jpg gif eot svg ttf woff2? ico pdf m4a t?gz xlsx]
110 task :generate => [ :realclean, 'sdk/python/arvados.html', 'sdk/R/arvados/index.html', 'sdk/java-v2/javadoc/index.html' ] do
111 vars = ['baseurl', 'arvados_cluster_uuid', 'arvados_api_host', 'arvados_workbench_host']
112 if ! ENV.key?('baseurl') || ENV['baseurl'] == ""
113 if !ENV.key?('WORKSPACE') || ENV['WORKSPACE'] == ""
114 puts "The `baseurl` variable was not specified and the `WORKSPACE` environment variable is not set. Defaulting `baseurl` to file://#{pwd}/.site"
115 ENV['baseurl'] = "file://#{pwd}/.site/"
117 puts "The `baseurl` variable was not specified, defaulting to a value derived from the `WORKSPACE` environment variable"
118 ENV['baseurl'] = "file://#{ENV['WORKSPACE']}/doc/.site/"
123 website.config.h[v] = ENV[v]
128 file ["install/new_cluster_checklist_Azure.xlsx", "install/new_cluster_checklist_AWS.xlsx"] do |t|
132 file "sdk/python/arvados.html" do |t|
133 next unless $build_sdks.include?(PythonSDK)
134 raise unless system("python3", "setup.py", "build",
135 chdir: "../sdk/python", out: :err)
136 raise unless system("python3", "pysdk_pdoc.py",
140 file "sdk/R/arvados/index.html" do |t|
141 next unless $build_sdks.include?(RSDK)
143 Dir.mkdir("sdk/R/arvados")
144 cp('css/R.css', 'sdk/R/arvados')
145 raise unless system("make", "man", chdir: "../sdk/R", out: :err)
146 docnames = Dir.glob("../sdk/R/man/*.Rd").map { |rd| File.basename(rd, ".Rd") }.sort
147 docnames.each do |basename|
149 "R", "CMD", "Rdconv", "--type=html", "man/#{basename}.Rd",
151 out: ["sdk/R/arvados/#{basename}.html", "w"],
155 File.open("sdk/R/index.html.md", "w") do |fn|
161 title: "R SDK Overview"
166 File.open("../sdk/R/README.md", "r") do |rd|
171 File.open("sdk/R/arvados/index.html.textile.liquid", "w") do |fn|
180 Copyright (C) The Arvados Authors. All rights reserved.
182 SPDX-License-Identifier: CC-BY-SA-3.0
187 docnames.each do |basename|
188 fn.printf("* \"%s\":%s.html\n", basename, basename)
193 file "sdk/java-v2/javadoc/index.html" do |t|
194 next unless $build_sdks.include?(JavaSDK)
197 Dir.chdir("../sdk/java-v2") do
198 STDERR.puts `gradle javadoc 2>&1`
200 puts `sed -i "s/@import.*dejavu.css.*//g" build/docs/javadoc/stylesheet.css`
203 cp_r("../sdk/java-v2/build/docs/javadoc", "sdk/java-v2")
207 task :linkchecker => [ :generate ] do
208 # we need --check-extern to check relative links, weird but true
211 "--ignore-url=!^file://",
213 ([JavaSDK, PythonSDK, RSDK] - $build_sdks).map(&:build_path).each do |sdk_path|
214 sdk_url = URI.join(ENV["baseurl"], sdk_path)
215 url_re = Regexp.escape(sdk_url.to_s)
216 opts << "--ignore-url=^#{url_re}[./]"
219 "linkchecker", *opts, "index.html",
223 fail "could not run linkchecker command (is it installed?)"
225 fail "linkchecker exited #{$?.exitstatus}"
229 task :import_vscode_training do
231 rm_rf "arvados-vscode-cwl-training"
232 `git clone https://github.com/arvados/arvados-vscode-cwl-training`
233 githash = `git --git-dir arvados-vscode-cwl-training/.git log -n1 --format=%H HEAD`
234 File.open("cwl/arvados-vscode-training.html.md.liquid", "w") do |fn|
235 File.open("arvados-vscode-cwl-training/README.md", "r") do |rd|
239 navsection: userguide
240 title: "Developing CWL Workflows with VSCode"
243 Copyright (C) The Arvados Authors. All rights reserved.
245 SPDX-License-Identifier: CC-BY-SA-3.0
247 Imported from https://github.com/arvados/arvados-vscode-cwl-training
256 rm_rf "arvados-vscode-cwl-training"
261 rm_rf "sdk/python/arvados"
262 rm_f "sdk/python/arvados.html"
263 rm_f "sdk/python/index.html"
265 rm_rf "sdk/java-v2/javadoc"
268 require "zenweb/tasks"
269 load "zenweb-textile.rb"
270 load "zenweb-liquid.rb"
271 load "zenweb-fix-body.rb"
273 task :extra_wirings do
274 $website.pages["sdk/python/python.html.textile.liquid"].depends_on("sdk/python/arvados.html")