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?("R", "--version")
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.replace(/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)
144 Dir.mkdir("sdk/R/arvados")
146 cp('css/R.css', 'sdk/R/arvados')
148 Dir.chdir("../sdk/R/") do
149 Dir.entries("man").each do |rd|
150 if rd[-3..-1] == ".Rd"
151 htmlfile = "#{rd[0..-4]}.html"
152 `R CMD Rdconv -t html man/#{rd} > #{tgt}/sdk/R/arvados/#{htmlfile}`
159 File.open("../sdk/R/README.md", "r") do |rd|
160 File.open("sdk/R/index.html.md", "w") do |fn|
166 title: "R SDK Overview"
175 File.open("sdk/R/arvados/index.html.textile.liquid", "w") do |fn|
184 Copyright (C) The Arvados Authors. All rights reserved.
186 SPDX-License-Identifier: CC-BY-SA-3.0
191 docfiles.sort.each do |d|
192 fn.write("* \"#{d[0..-6]}\":#{d}\n")
197 file "sdk/java-v2/javadoc/index.html" do |t|
198 next unless $build_sdks.include?(JavaSDK)
201 Dir.chdir("../sdk/java-v2") do
202 STDERR.puts `gradle javadoc 2>&1`
204 puts `sed -i "s/@import.*dejavu.css.*//g" build/docs/javadoc/stylesheet.css`
207 cp_r("../sdk/java-v2/build/docs/javadoc", "sdk/java-v2")
211 task :linkchecker => [ :generate ] do
212 # we need --check-extern to check relative links, weird but true
215 "--ignore-url=!^file://",
217 ([JavaSDK, PythonSDK, RSDK] - $build_sdks).map(&:build_path).each do |sdk_path|
218 sdk_url = URI.join(ENV["baseurl"], sdk_path)
219 url_re = Regexp.escape(sdk_url.to_s)
220 opts << "--ignore-url=^#{url_re}[./]"
223 "linkchecker", *opts, "index.html",
227 fail "could not run linkchecker command (is it installed?)"
229 fail "linkchecker exited #{$?.exitstatus}"
233 task :import_vscode_training do
235 rm_rf "arvados-vscode-cwl-training"
236 `git clone https://github.com/arvados/arvados-vscode-cwl-training`
237 githash = `git --git-dir arvados-vscode-cwl-training/.git log -n1 --format=%H HEAD`
238 File.open("cwl/arvados-vscode-training.html.md.liquid", "w") do |fn|
239 File.open("arvados-vscode-cwl-training/README.md", "r") do |rd|
243 navsection: userguide
244 title: "Developing CWL Workflows with VSCode"
247 Copyright (C) The Arvados Authors. All rights reserved.
249 SPDX-License-Identifier: CC-BY-SA-3.0
251 Imported from https://github.com/arvados/arvados-vscode-cwl-training
260 rm_rf "arvados-vscode-cwl-training"
265 rm_rf "sdk/python/arvados"
266 rm_f "sdk/python/arvados.html"
267 rm_f "sdk/python/index.html"
269 rm_rf "sdk/java-v2/javadoc"
272 require "zenweb/tasks"
273 load "zenweb-textile.rb"
274 load "zenweb-liquid.rb"
275 load "zenweb-fix-body.rb"
277 task :extra_wirings do
278 $website.pages["sdk/python/python.html.textile.liquid"].depends_on("sdk/python/arvados.html")